furi_hal_resources.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #pragma once
  2. #include <furi.h>
  3. #include <stm32wbxx.h>
  4. #include <stm32wbxx_ll_gpio.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. /* Input Related Constants */
  9. #define INPUT_DEBOUNCE_TICKS 4
  10. /* Input Keys */
  11. typedef enum {
  12. InputKeyUp,
  13. InputKeyDown,
  14. InputKeyRight,
  15. InputKeyLeft,
  16. InputKeyOk,
  17. InputKeyBack,
  18. InputKeyMAX, /**< Special value */
  19. } InputKey;
  20. /* Light */
  21. typedef enum {
  22. LightRed = (1 << 0),
  23. LightGreen = (1 << 1),
  24. LightBlue = (1 << 2),
  25. LightBacklight = (1 << 3),
  26. } Light;
  27. typedef struct {
  28. const GpioPin* gpio;
  29. const InputKey key;
  30. const bool inverted;
  31. const char* name;
  32. } InputPin;
  33. typedef struct {
  34. const GpioPin* pin;
  35. const char* name;
  36. const bool debug;
  37. } GpioPinRecord;
  38. extern const InputPin input_pins[];
  39. extern const size_t input_pins_count;
  40. extern const GpioPinRecord gpio_pins[];
  41. extern const size_t gpio_pins_count;
  42. extern const GpioPin vibro_gpio;
  43. extern const GpioPin ibutton_gpio;
  44. extern const GpioPin gpio_display_cs;
  45. extern const GpioPin gpio_display_rst_n;
  46. extern const GpioPin gpio_display_di;
  47. extern const GpioPin gpio_sdcard_cs;
  48. extern const GpioPin gpio_sdcard_cd;
  49. extern const GpioPin gpio_button_up;
  50. extern const GpioPin gpio_button_down;
  51. extern const GpioPin gpio_button_right;
  52. extern const GpioPin gpio_button_left;
  53. extern const GpioPin gpio_button_ok;
  54. extern const GpioPin gpio_button_back;
  55. extern const GpioPin gpio_spi_d_miso;
  56. extern const GpioPin gpio_spi_d_mosi;
  57. extern const GpioPin gpio_spi_d_sck;
  58. extern const GpioPin gpio_ext_pc0;
  59. extern const GpioPin gpio_ext_pc1;
  60. extern const GpioPin gpio_ext_pc3;
  61. extern const GpioPin gpio_ext_pb2;
  62. extern const GpioPin gpio_ext_pb3;
  63. extern const GpioPin gpio_ext_pa4;
  64. extern const GpioPin gpio_ext_pa6;
  65. extern const GpioPin gpio_ext_pa7;
  66. extern const GpioPin gpio_ext_pc5;
  67. extern const GpioPin gpio_ext_pc4;
  68. extern const GpioPin gpio_ext_pa5;
  69. extern const GpioPin gpio_ext_pb9;
  70. extern const GpioPin gpio_ext_pa0;
  71. extern const GpioPin gpio_ext_pa1;
  72. extern const GpioPin gpio_ext_pa15;
  73. extern const GpioPin gpio_ext_pe4;
  74. extern const GpioPin gpio_ext_pa2;
  75. extern const GpioPin gpio_ext_pb4;
  76. extern const GpioPin gpio_ext_pb5;
  77. extern const GpioPin gpio_ext_pd0;
  78. extern const GpioPin gpio_ext_pb13;
  79. extern const GpioPin gpio_usart_tx;
  80. extern const GpioPin gpio_usart_rx;
  81. extern const GpioPin gpio_i2c_power_sda;
  82. extern const GpioPin gpio_i2c_power_scl;
  83. extern const GpioPin gpio_speaker;
  84. extern const GpioPin periph_power;
  85. extern const GpioPin gpio_usb_dm;
  86. extern const GpioPin gpio_usb_dp;
  87. void furi_hal_resources_init_early();
  88. void furi_hal_resources_deinit_early();
  89. void furi_hal_resources_init();
  90. /**
  91. * Get a corresponding external connector pin number for a gpio
  92. * @param gpio GpioPin
  93. * @return pin number or -1 if gpio is not on the external connector
  94. */
  95. int32_t furi_hal_resources_get_ext_pin_number(const GpioPin* gpio);
  96. #ifdef __cplusplus
  97. }
  98. #endif