furi_hal_resources.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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_cc1101_g0;
  45. extern const GpioPin gpio_rf_sw_0;
  46. extern const GpioPin gpio_subghz_cs;
  47. extern const GpioPin gpio_display_cs;
  48. extern const GpioPin gpio_display_rst_n;
  49. extern const GpioPin gpio_display_di;
  50. extern const GpioPin gpio_sdcard_cs;
  51. extern const GpioPin gpio_sdcard_cd;
  52. extern const GpioPin gpio_nfc_cs;
  53. extern const GpioPin gpio_button_up;
  54. extern const GpioPin gpio_button_down;
  55. extern const GpioPin gpio_button_right;
  56. extern const GpioPin gpio_button_left;
  57. extern const GpioPin gpio_button_ok;
  58. extern const GpioPin gpio_button_back;
  59. extern const GpioPin gpio_spi_d_miso;
  60. extern const GpioPin gpio_spi_d_mosi;
  61. extern const GpioPin gpio_spi_d_sck;
  62. extern const GpioPin gpio_spi_r_miso;
  63. extern const GpioPin gpio_spi_r_mosi;
  64. extern const GpioPin gpio_spi_r_sck;
  65. extern const GpioPin gpio_ext_pc0;
  66. extern const GpioPin gpio_ext_pc1;
  67. extern const GpioPin gpio_ext_pc3;
  68. extern const GpioPin gpio_ext_pb2;
  69. extern const GpioPin gpio_ext_pb3;
  70. extern const GpioPin gpio_ext_pa4;
  71. extern const GpioPin gpio_ext_pa6;
  72. extern const GpioPin gpio_ext_pa7;
  73. extern const GpioPin gpio_nfc_irq_rfid_pull;
  74. extern const GpioPin gpio_rfid_carrier_out;
  75. extern const GpioPin gpio_rfid_data_in;
  76. extern const GpioPin gpio_rfid_carrier;
  77. extern const GpioPin gpio_infrared_rx;
  78. extern const GpioPin gpio_infrared_tx;
  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. #define BUTTON_BACK_GPIO_Port GPIOC
  88. #define BUTTON_BACK_Pin LL_GPIO_PIN_13
  89. #define BUTTON_DOWN_GPIO_Port GPIOC
  90. #define BUTTON_DOWN_Pin LL_GPIO_PIN_6
  91. #define BUTTON_LEFT_GPIO_Port GPIOB
  92. #define BUTTON_LEFT_Pin LL_GPIO_PIN_11
  93. #define BUTTON_OK_GPIO_Port GPIOH
  94. #define BUTTON_OK_Pin LL_GPIO_PIN_3
  95. #define BUTTON_RIGHT_GPIO_Port GPIOB
  96. #define BUTTON_RIGHT_Pin LL_GPIO_PIN_12
  97. #define BUTTON_UP_GPIO_Port GPIOB
  98. #define BUTTON_UP_Pin LL_GPIO_PIN_10
  99. #define CC1101_CS_GPIO_Port GPIOD
  100. #define CC1101_CS_Pin LL_GPIO_PIN_0
  101. #define CC1101_G0_GPIO_Port GPIOA
  102. #define CC1101_G0_Pin LL_GPIO_PIN_1
  103. #define DISPLAY_CS_GPIO_Port GPIOC
  104. #define DISPLAY_CS_Pin LL_GPIO_PIN_11
  105. #define DISPLAY_DI_GPIO_Port GPIOB
  106. #define DISPLAY_DI_Pin LL_GPIO_PIN_1
  107. #define DISPLAY_RST_GPIO_Port GPIOB
  108. #define DISPLAY_RST_Pin LL_GPIO_PIN_0
  109. #define IR_RX_GPIO_Port GPIOA
  110. #define IR_RX_Pin LL_GPIO_PIN_0
  111. #define IR_TX_GPIO_Port GPIOB
  112. #define IR_TX_Pin LL_GPIO_PIN_9
  113. #define NFC_CS_GPIO_Port GPIOE
  114. #define NFC_CS_Pin LL_GPIO_PIN_4
  115. #define PA4_GPIO_Port GPIOA
  116. #define PA4_Pin LL_GPIO_PIN_4
  117. #define PA6_GPIO_Port GPIOA
  118. #define PA6_Pin LL_GPIO_PIN_6
  119. #define PA7_GPIO_Port GPIOA
  120. #define PA7_Pin LL_GPIO_PIN_7
  121. #define PB2_GPIO_Port GPIOB
  122. #define PB2_Pin LL_GPIO_PIN_2
  123. #define PB3_GPIO_Port GPIOB
  124. #define PB3_Pin LL_GPIO_PIN_3
  125. #define PC0_GPIO_Port GPIOC
  126. #define PC0_Pin LL_GPIO_PIN_0
  127. #define PC1_GPIO_Port GPIOC
  128. #define PC1_Pin LL_GPIO_PIN_1
  129. #define PC3_GPIO_Port GPIOC
  130. #define PC3_Pin LL_GPIO_PIN_3
  131. #define QUARTZ_32MHZ_IN_GPIO_Port GPIOC
  132. #define QUARTZ_32MHZ_IN_Pin LL_GPIO_PIN_14
  133. #define QUARTZ_32MHZ_OUT_GPIO_Port GPIOC
  134. #define QUARTZ_32MHZ_OUT_Pin LL_GPIO_PIN_15
  135. #define RFID_OUT_GPIO_Port GPIOB
  136. #define RFID_OUT_Pin LL_GPIO_PIN_13
  137. #define RFID_PULL_GPIO_Port GPIOA
  138. #define RFID_PULL_Pin LL_GPIO_PIN_2
  139. #define RFID_RF_IN_GPIO_Port GPIOC
  140. #define RFID_RF_IN_Pin LL_GPIO_PIN_5
  141. #define RFID_CARRIER_GPIO_Port GPIOA
  142. #define RFID_CARRIER_Pin LL_GPIO_PIN_15
  143. #define RF_SW_0_GPIO_Port GPIOC
  144. #define RF_SW_0_Pin LL_GPIO_PIN_4
  145. #define SD_CD_GPIO_Port GPIOC
  146. #define SD_CD_Pin LL_GPIO_PIN_10
  147. #define SD_CS_GPIO_Port GPIOC
  148. #define SD_CS_Pin LL_GPIO_PIN_12
  149. #define SPEAKER_GPIO_Port GPIOB
  150. #define SPEAKER_Pin LL_GPIO_PIN_8
  151. #define VIBRO_GPIO_Port GPIOA
  152. #define VIBRO_Pin LL_GPIO_PIN_8
  153. #define iBTN_GPIO_Port GPIOB
  154. #define iBTN_Pin LL_GPIO_PIN_14
  155. #define USART1_TX_Pin LL_GPIO_PIN_6
  156. #define USART1_TX_Port GPIOB
  157. #define USART1_RX_Pin LL_GPIO_PIN_7
  158. #define USART1_RX_Port GPIOB
  159. #define SPI_D_MISO_GPIO_Port GPIOC
  160. #define SPI_D_MISO_Pin LL_GPIO_PIN_2
  161. #define SPI_D_MOSI_GPIO_Port GPIOB
  162. #define SPI_D_MOSI_Pin LL_GPIO_PIN_15
  163. #define SPI_D_SCK_GPIO_Port GPIOD
  164. #define SPI_D_SCK_Pin LL_GPIO_PIN_1
  165. #define SPI_R_MISO_GPIO_Port GPIOB
  166. #define SPI_R_MISO_Pin LL_GPIO_PIN_4
  167. #define SPI_R_MOSI_GPIO_Port GPIOB
  168. #define SPI_R_MOSI_Pin LL_GPIO_PIN_5
  169. #define SPI_R_SCK_GPIO_Port GPIOA
  170. #define SPI_R_SCK_Pin LL_GPIO_PIN_5
  171. #define NFC_IRQ_Pin RFID_PULL_Pin
  172. #define NFC_IRQ_GPIO_Port RFID_PULL_GPIO_Port
  173. void furi_hal_resources_init_early();
  174. void furi_hal_resources_deinit_early();
  175. void furi_hal_resources_init();
  176. /**
  177. * Get a corresponding external connector pin number for a gpio
  178. * @param gpio GpioPin
  179. * @return pin number or -1 if gpio is not on the external connector
  180. */
  181. int32_t furi_hal_resources_get_ext_pin_number(const GpioPin* gpio);
  182. #ifdef __cplusplus
  183. }
  184. #endif