furi_hal_resources.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 20
  10. /* Input Keys */
  11. typedef enum {
  12. InputKeyUp,
  13. InputKeyDown,
  14. InputKeyRight,
  15. InputKeyLeft,
  16. InputKeyOk,
  17. InputKeyBack,
  18. } InputKey;
  19. /* Light */
  20. typedef enum {
  21. LightRed,
  22. LightGreen,
  23. LightBlue,
  24. LightBacklight,
  25. } Light;
  26. typedef struct {
  27. const GpioPin* gpio;
  28. const InputKey key;
  29. const bool inverted;
  30. const char* name;
  31. } InputPin;
  32. extern const InputPin input_pins[];
  33. extern const size_t input_pins_count;
  34. extern const GpioPin vibro_gpio;
  35. extern const GpioPin ibutton_gpio;
  36. extern const GpioPin gpio_cc1101_g0;
  37. extern const GpioPin gpio_rf_sw_0;
  38. extern const GpioPin gpio_subghz_cs;
  39. extern const GpioPin gpio_display_cs;
  40. extern const GpioPin gpio_display_rst;
  41. extern const GpioPin gpio_display_di;
  42. extern const GpioPin gpio_sdcard_cs;
  43. extern const GpioPin gpio_sdcard_cd;
  44. extern const GpioPin gpio_nfc_cs;
  45. extern const GpioPin gpio_button_up;
  46. extern const GpioPin gpio_button_down;
  47. extern const GpioPin gpio_button_right;
  48. extern const GpioPin gpio_button_left;
  49. extern const GpioPin gpio_button_ok;
  50. extern const GpioPin gpio_button_back;
  51. extern const GpioPin gpio_spi_d_miso;
  52. extern const GpioPin gpio_spi_d_mosi;
  53. extern const GpioPin gpio_spi_d_sck;
  54. extern const GpioPin gpio_spi_r_miso;
  55. extern const GpioPin gpio_spi_r_mosi;
  56. extern const GpioPin gpio_spi_r_sck;
  57. extern const GpioPin gpio_ext_pc0;
  58. extern const GpioPin gpio_ext_pc1;
  59. extern const GpioPin gpio_ext_pc3;
  60. extern const GpioPin gpio_ext_pb2;
  61. extern const GpioPin gpio_ext_pb3;
  62. extern const GpioPin gpio_ext_pa4;
  63. extern const GpioPin gpio_ext_pa6;
  64. extern const GpioPin gpio_ext_pa7;
  65. extern const GpioPin gpio_rfid_pull;
  66. extern const GpioPin gpio_rfid_carrier_out;
  67. extern const GpioPin gpio_rfid_data_in;
  68. extern const GpioPin gpio_rfid_carrier;
  69. extern const GpioPin gpio_infrared_rx;
  70. extern const GpioPin gpio_infrared_tx;
  71. extern const GpioPin gpio_usart_tx;
  72. extern const GpioPin gpio_usart_rx;
  73. extern const GpioPin gpio_i2c_power_sda;
  74. extern const GpioPin gpio_i2c_power_scl;
  75. extern const GpioPin gpio_speaker;
  76. extern const GpioPin periph_power;
  77. extern const GpioPin gpio_usb_dm;
  78. extern const GpioPin gpio_usb_dp;
  79. #define BUTTON_BACK_GPIO_Port GPIOC
  80. #define BUTTON_BACK_Pin LL_GPIO_PIN_13
  81. #define BUTTON_DOWN_GPIO_Port GPIOC
  82. #define BUTTON_DOWN_Pin LL_GPIO_PIN_6
  83. #define BUTTON_LEFT_GPIO_Port GPIOB
  84. #define BUTTON_LEFT_Pin LL_GPIO_PIN_11
  85. #define BUTTON_OK_GPIO_Port GPIOH
  86. #define BUTTON_OK_Pin LL_GPIO_PIN_3
  87. #define BUTTON_RIGHT_GPIO_Port GPIOB
  88. #define BUTTON_RIGHT_Pin LL_GPIO_PIN_12
  89. #define BUTTON_UP_GPIO_Port GPIOB
  90. #define BUTTON_UP_Pin LL_GPIO_PIN_10
  91. #define CC1101_CS_GPIO_Port GPIOD
  92. #define CC1101_CS_Pin LL_GPIO_PIN_0
  93. #define CC1101_G0_GPIO_Port GPIOA
  94. #define CC1101_G0_Pin LL_GPIO_PIN_1
  95. #define DISPLAY_CS_GPIO_Port GPIOC
  96. #define DISPLAY_CS_Pin LL_GPIO_PIN_11
  97. #define DISPLAY_DI_GPIO_Port GPIOB
  98. #define DISPLAY_DI_Pin LL_GPIO_PIN_1
  99. #define DISPLAY_RST_GPIO_Port GPIOB
  100. #define DISPLAY_RST_Pin LL_GPIO_PIN_0
  101. #define IR_RX_GPIO_Port GPIOA
  102. #define IR_RX_Pin LL_GPIO_PIN_0
  103. #define IR_TX_GPIO_Port GPIOB
  104. #define IR_TX_Pin LL_GPIO_PIN_9
  105. #define NFC_CS_GPIO_Port GPIOE
  106. #define NFC_CS_Pin LL_GPIO_PIN_4
  107. #define PA4_GPIO_Port GPIOA
  108. #define PA4_Pin LL_GPIO_PIN_4
  109. #define PA6_GPIO_Port GPIOA
  110. #define PA6_Pin LL_GPIO_PIN_6
  111. #define PA7_GPIO_Port GPIOA
  112. #define PA7_Pin LL_GPIO_PIN_7
  113. #define PB2_GPIO_Port GPIOB
  114. #define PB2_Pin LL_GPIO_PIN_2
  115. #define PB3_GPIO_Port GPIOB
  116. #define PB3_Pin LL_GPIO_PIN_3
  117. #define PC0_GPIO_Port GPIOC
  118. #define PC0_Pin LL_GPIO_PIN_0
  119. #define PC1_GPIO_Port GPIOC
  120. #define PC1_Pin LL_GPIO_PIN_1
  121. #define PC3_GPIO_Port GPIOC
  122. #define PC3_Pin LL_GPIO_PIN_3
  123. #define PERIPH_POWER_GPIO_Port GPIOA
  124. #define PERIPH_POWER_Pin LL_GPIO_PIN_3
  125. #define QUARTZ_32MHZ_IN_GPIO_Port GPIOC
  126. #define QUARTZ_32MHZ_IN_Pin LL_GPIO_PIN_14
  127. #define QUARTZ_32MHZ_OUT_GPIO_Port GPIOC
  128. #define QUARTZ_32MHZ_OUT_Pin LL_GPIO_PIN_15
  129. #define RFID_OUT_GPIO_Port GPIOB
  130. #define RFID_OUT_Pin LL_GPIO_PIN_13
  131. #define RFID_PULL_GPIO_Port GPIOA
  132. #define RFID_PULL_Pin LL_GPIO_PIN_2
  133. #define RFID_RF_IN_GPIO_Port GPIOC
  134. #define RFID_RF_IN_Pin LL_GPIO_PIN_5
  135. #define RFID_CARRIER_GPIO_Port GPIOA
  136. #define RFID_CARRIER_Pin LL_GPIO_PIN_15
  137. #define RF_SW_0_GPIO_Port GPIOC
  138. #define RF_SW_0_Pin LL_GPIO_PIN_4
  139. #define SD_CD_GPIO_Port GPIOC
  140. #define SD_CD_Pin LL_GPIO_PIN_10
  141. #define SD_CS_GPIO_Port GPIOC
  142. #define SD_CS_Pin LL_GPIO_PIN_12
  143. #define SPEAKER_GPIO_Port GPIOB
  144. #define SPEAKER_Pin LL_GPIO_PIN_8
  145. #define VIBRO_GPIO_Port GPIOA
  146. #define VIBRO_Pin LL_GPIO_PIN_8
  147. #define iBTN_GPIO_Port GPIOB
  148. #define iBTN_Pin LL_GPIO_PIN_14
  149. #define USART1_TX_Pin LL_GPIO_PIN_6
  150. #define USART1_TX_Port GPIOB
  151. #define USART1_RX_Pin LL_GPIO_PIN_7
  152. #define USART1_RX_Port GPIOB
  153. #define SPI_D_MISO_GPIO_Port GPIOC
  154. #define SPI_D_MISO_Pin LL_GPIO_PIN_2
  155. #define SPI_D_MOSI_GPIO_Port GPIOB
  156. #define SPI_D_MOSI_Pin LL_GPIO_PIN_15
  157. #define SPI_D_SCK_GPIO_Port GPIOD
  158. #define SPI_D_SCK_Pin LL_GPIO_PIN_1
  159. #define SPI_R_MISO_GPIO_Port GPIOB
  160. #define SPI_R_MISO_Pin LL_GPIO_PIN_4
  161. #define SPI_R_MOSI_GPIO_Port GPIOB
  162. #define SPI_R_MOSI_Pin LL_GPIO_PIN_5
  163. #define SPI_R_SCK_GPIO_Port GPIOA
  164. #define SPI_R_SCK_Pin LL_GPIO_PIN_5
  165. #define NFC_IRQ_Pin RFID_PULL_Pin
  166. #define NFC_IRQ_GPIO_Port RFID_PULL_GPIO_Port
  167. void furi_hal_resources_init_early();
  168. void furi_hal_resources_deinit_early();
  169. void furi_hal_resources_init();
  170. #ifdef __cplusplus
  171. }
  172. #endif