interface.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. // #ifndef __INTERFACE_H
  2. // #define __INTERFACE_H
  3. // #include <stm32f4xx.h>
  4. // #include "stm32f4xx_rcu.h"
  5. // #include "includes.h"
  6. // typedef enum
  7. // {
  8. // kI2C0 = 0,
  9. // kI2C1,
  10. // kI2C2,
  11. // kADC0,
  12. // kADC2,
  13. // kSPI2,
  14. // kUart0,
  15. // kUart5,
  16. // kCAN0,
  17. // kCAN1,
  18. // kEthernet,
  19. // kInput,
  20. // kOutput,
  21. // kPMU,
  22. // kDMA1,
  23. // // kTIMER1,
  24. // kInterfaceEnd,
  25. // } interface_type;
  26. // typedef enum
  27. // {
  28. // kRunLed,
  29. // kPRelayCtr,
  30. // kNRelayCtr,
  31. // kPreRelayCtr,
  32. // kFanCtr,
  33. // kOut1Ctr, // charger
  34. // kOut2Ctr, // charger heat
  35. // kExtWatchDog,
  36. // kExtRelayLed,
  37. // kExtFaultLed,
  38. // kISOPRelayCtr,
  39. // kISONRelayCtr,
  40. // kSoftI2C3_SDA,
  41. // kSoftI2C3_SCL,
  42. // kSoftI2C4_SDA,
  43. // kSoftI2C4_SCL,
  44. // kOutputEnd,
  45. // } Output_Type;
  46. // typedef enum
  47. // {
  48. // kLDetect,
  49. // kInputEnd,
  50. // } Input_type;
  51. // typedef struct
  52. // {
  53. // INT32U GPIOx;
  54. // INT32U GPIO_Pin;
  55. // INT8U GPIO_AF;
  56. // } GPIO_AF_Info;
  57. // typedef struct
  58. // {
  59. // interface_type type;
  60. // Output_Type Out_Type;
  61. // Input_type In_Type;
  62. // INT32U GPIOx;
  63. // INT32U GPIO_Pin;
  64. // INT32U GPIO_Mode;
  65. // GPIO_AF_Info AF_Info;
  66. // INT8U GPIO_OType;
  67. // INT32U GPIO_Speed;
  68. // INT32U GPIO_PuPd;
  69. // } Interface_struct;
  70. // typedef struct
  71. // {
  72. // interface_type type;
  73. // rcu_periph_enum AXBPeriph_Clock;
  74. // } Gpio_Clock;
  75. // // soft I2C
  76. // #define SI2C3_SDA_PIN GPIO_PIN_3
  77. // #define SI2C3_SDA_PORT GPIOD
  78. // #define SI2C3_SCL_PIN GPIO_PIN_2
  79. // #define SI2C3_SCL_PORT GPIOD
  80. // #define SI2C4_SDA_PIN GPIO_PIN_15
  81. // #define SI2C4_SDA_PORT GPIOE
  82. // #define SI2C4_SCL_PIN GPIO_PIN_14
  83. // #define SI2C4_SCL_PORT GPIOE
  84. // #define SI2C3_SDA_HIGH gpio_bit_set(SI2C3_SDA_PORT, SI2C3_SDA_PIN)
  85. // #define SI2C3_SDA_LOW gpio_bit_reset(SI2C3_SDA_PORT, SI2C3_SDA_PIN)
  86. // #define SI2C3_SCL_HIGH gpio_bit_set(SI2C3_SCL_PORT, SI2C3_SCL_PIN)
  87. // #define SI2C3_SCL_LOW gpio_bit_reset(SI2C3_SCL_PORT, SI2C3_SCL_PIN)
  88. // #define SI2C4_SDA_HIGH gpio_bit_set(SI2C4_SDA_PORT, SI2C4_SDA_PIN)
  89. // #define SI2C4_SDA_LOW gpio_bit_reset(SI2C4_SDA_PORT, SI2C4_SDA_PIN)
  90. // #define SI2C4_SCL_HIGH gpio_bit_set(SI2C4_SCL_PORT, SI2C4_SCL_PIN)
  91. // #define SI2C4_SCL_LOW gpio_bit_reset(SI2C4_SCL_PORT, SI2C4_SCL_PIN)
  92. // #define SI2C3_SDA_OUT gpio_mode_set(SI2C3_SDA_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, SI2C3_SDA_PIN)
  93. // #define SI2C3_SDA_IN gpio_mode_set(SI2C3_SDA_PORT, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, SI2C3_SDA_PIN)
  94. // #define SI2C3_SDA_READ gpio_input_bit_get(SI2C3_SDA_PORT, SI2C3_SDA_PIN)
  95. // #define SI2C4_SDA_OUT gpio_mode_set(SI2C4_SDA_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP, SI2C4_SDA_PIN)
  96. // #define SI2C4_SDA_IN gpio_mode_set(SI2C4_SDA_PORT, GPIO_MODE_INPUT, GPIO_PUPD_PULLUP, SI2C4_SDA_PIN)
  97. // #define SI2C4_SDA_READ gpio_input_bit_get(SI2C4_SDA_PORT, SI2C4_SDA_PIN)
  98. // // uart
  99. // #define UART0_ENABLE_PORT GPIOE
  100. // #define UART0_ENABLE_PIN GPIO_PIN_5
  101. // #define UART5_ENABLE_PORT GPIOE
  102. // #define UART5_ENABLE_PIN GPIO_PIN_6
  103. // #define UART0_TX_ENABLE gpio_bit_set(UART0_ENABLE_PORT, UART0_ENABLE_PIN)
  104. // #define UART0_RX_ENABLE gpio_bit_reset(UART0_ENABLE_PORT, UART0_ENABLE_PIN)
  105. // #define UART5_TX_ENABLE gpio_bit_set(UART5_ENABLE_PORT, UART5_ENABLE_PIN)
  106. // #define UART5_RX_ENABLE gpio_bit_reset(UART5_ENABLE_PORT, UART5_ENABLE_PIN)
  107. // // SPI
  108. // #define SPI2_CS_PORT GPIOA
  109. // #define SPI2_CS_PIN GPIO_PIN_15
  110. // #define SPI2_CS_HIGH gpio_bit_set(SPI2_CS_PORT, SPI2_CS_PIN)
  111. // #define SPI2_CS_LOW gpio_bit_reset(SPI2_CS_PORT, SPI2_CS_PIN)
  112. // // ethernet
  113. // //#define ENET_REF_CLK GPIO_PIN_1
  114. // //#define ENET_REF_CLK_Port GPIOA
  115. // //#define ENET_MDC GPIO_PIN_1
  116. // //#define ENET_MDC_Port GPIOC
  117. // //#define ENET_MDIO GPIO_PIN_2
  118. // //#define ENET_MDIO_Port GPIOA
  119. // //#define ENET_CRSDV GPIO_PIN_7
  120. // //#define ENET_CRSDV_Port GPIOA
  121. // //#define ENET_RXD0 GPIO_PIN_4
  122. // //#define ENET_RXD0_Port GPIOC
  123. // //#define ENET_RXD1 GPIO_PIN_5
  124. // //#define ENET_RXD1_Port GPIOC
  125. // //#define ENET_TXEN GPIO_PIN_11
  126. // //#define ENET_TXEN_Port GPIOG
  127. // //#define ENET_RXER GPIO_PIN_12
  128. // //#define ENET_RXER_Port GPIOG
  129. // //#define ENET_TXD0 GPIO_PIN_13
  130. // //#define ENET_TXD0_Port GPIOG
  131. // //#define ENET_TXD1 GPIO_PIN_14
  132. // //#define ENET_TXD1_Port GPIOG
  133. // #define ETH_RESET_PORT GPIOE
  134. // #define ETH_RESET_PIN GPIO_PIN_2
  135. // #define ETH_RXER_PORT GPIOG
  136. // #define ETH_RXER_PIN GPIO_PIN_12
  137. // #define ETH_RESET_ON gpio_bit_reset(ETH_RESET_PORT, ETH_RESET_PIN)
  138. // #define ETH_RESET_OFF gpio_bit_set(ETH_RESET_PORT, ETH_RESET_PIN)
  139. // // output
  140. // #define LED_RUN_PORT GPIOE
  141. // #define LED_RUN_PIN GPIO_PIN_3
  142. // #define PRelayCtr_PORT GPIOD
  143. // #define PRelayCtr_PIN GPIO_PIN_6
  144. // #define NRelayCtr_PORT GPIOD
  145. // #define NRelayCtr_PIN GPIO_PIN_5
  146. // #define PreRelayCtr_PORT GPIOG
  147. // #define PreRelayCtr_PIN GPIO_PIN_9
  148. // #define Fan_PORT GPIOG
  149. // #define Fan_PIN GPIO_PIN_10
  150. // #define OUT1CTR_PORT GPIOD
  151. // #define OUT1CTR_PIN GPIO_PIN_7
  152. // #define OUT2CTR_PORT GPIOE
  153. // #define OUT2CTR_PIN GPIO_PIN_1
  154. // #define EXTWATCHDOG_PORT GPIOC
  155. // #define EXTWATCHDOG_PIN GPIO_PIN_3
  156. // #define ExtRelayLed_PORT GPIOD
  157. // #define ExtRelayLed_PIN GPIO_PIN_11
  158. // #define ExtFaultLed_PORT GPIOD
  159. // #define ExtFaultLed_PIN GPIO_PIN_10
  160. // #define ISOPRelayCtr_PORT GPIOF
  161. // #define ISOPRelayCtr_PIN GPIO_PIN_14
  162. // #define ISONRelayCtr_PORT GPIOF
  163. // #define ISONRelayCtr_PIN GPIO_PIN_15
  164. // // input
  165. // #define LDetect1_PORT GPIOD
  166. // #define LDetect1_PIN GPIO_PIN_13
  167. // // output operation
  168. // #define LED_RUN_ON gpio_bit_set(LED_RUN_PORT, LED_RUN_PIN)
  169. // #define LED_RUN_OFF gpio_bit_reset(LED_RUN_PORT, LED_RUN_PIN)
  170. // #define LED_RUN_TOGGLE gpio_bit_write(LED_RUN_PORT, LED_RUN_PIN, (FlagStatus)(1 - (gpio_output_bit_get(LED_RUN_PORT, LED_RUN_PIN))))
  171. // #define PRelayCtr_ON gpio_bit_set(PRelayCtr_PORT, PRelayCtr_PIN)
  172. // #define PRelayCtr_OFF gpio_bit_reset(PRelayCtr_PORT, PRelayCtr_PIN)
  173. // #define NRelayCtr_ON gpio_bit_set(NRelayCtr_PORT, NRelayCtr_PIN)
  174. // #define NRelayCtr_OFF gpio_bit_reset(NRelayCtr_PORT, NRelayCtr_PIN)
  175. // #define PreRelayCtr_ON gpio_bit_set(PreRelayCtr_PORT, PreRelayCtr_PIN)
  176. // #define PreRelayCtr_OFF gpio_bit_reset(PreRelayCtr_PORT, PreRelayCtr_PIN)
  177. // #define FAN_ON gpio_bit_set(Fan_PORT, Fan_PIN)
  178. // #define FAN_OFF gpio_bit_reset(Fan_PORT, Fan_PIN)
  179. // #define OUT1CTR_ON gpio_bit_set(OUT1CTR_PORT, OUT1CTR_PIN)
  180. // #define OUT1CTR_OFF gpio_bit_reset(OUT1CTR_PORT, OUT1CTR_PIN)
  181. // #define OUT2CTR_ON gpio_bit_set(OUT2CTR_PORT, OUT2CTR_PIN)
  182. // #define OUT2CTR_OFF gpio_bit_reset(OUT2CTR_PORT, OUT2CTR_PIN)
  183. // #define FEED_DOG_ON gpio_bit_set(EXTWATCHDOG_PORT, EXTWATCHDOG_PIN)
  184. // #define FEED_DOG_OFF gpio_bit_reset(EXTWATCHDOG_PORT, EXTWATCHDOG_PIN)
  185. // #define FEED_DOG_TOGGLE gpio_bit_write(EXTWATCHDOG_PORT, EXTWATCHDOG_PIN, (FlagStatus)(1 - (gpio_output_bit_get(EXTWATCHDOG_PORT, EXTWATCHDOG_PIN))))
  186. // #define ExtRelayLed_ON gpio_bit_set(ExtRelayLed_PORT, ExtRelayLed_PIN)
  187. // #define ExtRelayLed_OFF gpio_bit_reset(ExtRelayLed_PORT, ExtRelayLed_PIN)
  188. // #define ExtFaultLed_ON gpio_bit_set(ExtFaultLed_PORT, ExtFaultLed_PIN)
  189. // #define ExtFaultLed_OFF gpio_bit_reset(ExtFaultLed_PORT, ExtFaultLed_PIN)
  190. // #define ISOPRelay_ON gpio_bit_set(ISOPRelayCtr_PORT, ISOPRelayCtr_PIN)
  191. // #define ISOPRelay_OFF gpio_bit_reset(ISOPRelayCtr_PORT, ISOPRelayCtr_PIN)
  192. // #define ISONRelay_ON gpio_bit_set(ISONRelayCtr_PORT, ISONRelayCtr_PIN)
  193. // #define ISONRelay_OFF gpio_bit_reset(ISONRelayCtr_PORT, ISONRelayCtr_PIN)
  194. // // input result
  195. // #define L_IN1_IS_LOW (gpio_input_bit_get(LDetect1_PORT, LDetect1_PIN) == RESET)
  196. // void gpio_clock_init(void);
  197. // void interface_init(void);
  198. // #endif