board.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef __BOARD_H
  2. #define __BOARD_H
  3. #include "stm32f10x.h"
  4. #include "stm32f10x_gpio.h"
  5. //--------------------------------------------
  6. #define BOARD_PIN_SPI_CLK GPIO_Pin_5 //SPI1_SCK(8)
  7. #define BOARD_PORT_SPI_CLK GPIOA //DAC_OUT2 ADC12_IN5
  8. #define BOARD_GPIO_SPI_CLK BOARD_PORT_SPI_CLK, BOARD_PIN_SPI_CLK //
  9. #define BOARD_PIN_SPI_MISO GPIO_Pin_6 //SPI1_MISO(8)
  10. #define BOARD_PORT_SPI_MISO GPIOA // TIM8_BKIN/ADC12_IN6
  11. // TIM3_CH1(8)
  12. #define BOARD_GPIO_SPI_MISO BOARD_PORT_SPI_MISO, BOARD_PIN_SPI_MISO //
  13. #define BOARD_PIN_SPI_MOSI GPIO_Pin_7 //SPI1_MOSI(8)/
  14. #define BOARD_PORT_SPI_MOSI GPIOA // TIM8_CH1N/ADC12_IN7
  15. // TIM3_CH2(8)
  16. #define BOARD_GPIO_SPI_MOSI BOARD_PORT_SPI_MOSI, BOARD_PIN_SPI_MOSI //
  17. #define BOARD_PIN_SPI_CSN GPIO_Pin_4 //SPI1_NSS(8)/
  18. #define BOARD_PORT_SPI_CSN GPIOA // USART2_CK(8)
  19. // DAC_OUT1/ADC12_IN4
  20. #define BOARD_GPIO_SPI_CSN BOARD_PORT_SPI_CSN, BOARD_PIN_SPI_CSN //
  21. #define BOARD_PIN_SPI_GPIOA GPIO_Pin_5 //ADC12_IN15
  22. #define BOARD_PORT_SPI_GPIOA GPIOC
  23. #define BOARD_GPIO_SPI_GPIOA BOARD_PORT_SPI_GPIOA, BOARD_PIN_SPI_GPIOA //
  24. #define BOARD_PIN_SPI_GPIOB GPIO_Pin_0 //ADC12_IN8/TIM3_CH3 TIM1_CH2N
  25. #define BOARD_PORT_SPI_GPIOB GPIOB // TIM8_CH2N,N表示互补输出功能
  26. #define BOARD_GPIO_SPI_GPIOB BOARD_PORT_SPI_GPIOB, BOARD_PIN_SPI_GPIOB //
  27. #define BOARD_PIN_SPI_GPIOC GPIO_Pin_1 //ADC12_IN9/TIM3_CH4(8)
  28. #define BOARD_PORT_SPI_GPIOC GPIOB // TIM8_CH3N,N表示互补输出功能
  29. #define BOARD_GPIO_SPI_GPIOC BOARD_PORT_SPI_GPIOC, BOARD_PIN_SPI_GPIOC //
  30. #define BOARD_PIN_SPI_GPIOD GPIO_Pin_2 //USART2_TX(8)/TIM5_CH3
  31. #define BOARD_PORT_SPI_GPIOD GPIOA // ADC123_IN2/
  32. #define BOARD_GPIO_SPI_GPIOD BOARD_PORT_SPI_GPIOD, BOARD_PIN_SPI_GPIOD //
  33. // TIM2_CH3 (8)
  34. #define BOARD_PIN_SPI_GPIOE GPIO_Pin_10 //I2C2_SCL/USART3_TX(8) TIM2_CH3
  35. #define BOARD_PORT_SPI_GPIOE GPIOB
  36. #define BOARD_GPIO_SPI_GPIOE BOARD_PORT_SPI_GPIOE, BOARD_PIN_SPI_GPIOE //
  37. #define BOARD_PIN_SPI_GPIOF GPIO_Pin_11 //I2C2_SDA/USART3_RX(8) TIM2_CH4
  38. #define BOARD_PORT_SPI_GPIOF GPIOB
  39. #define BOARD_GPIO_SPI_GPIOF BOARD_PORT_SPI_GPIOF, BOARD_PIN_SPI_GPIOF //
  40. #define BOARD_PIN_SPI_GPIOG GPIO_Pin_12 //SPI2_NSS/I2S2_WS/
  41. #define BOARD_PORT_SPI_GPIOG GPIOB // I2C2_SMBA/
  42. // USART3_CK(8)/
  43. // TIM1_BKIN(8)
  44. #define BOARD_GPIO_SPI_GPIOG BOARD_PORT_SPI_GPIOG, BOARD_PIN_SPI_GPIOG //
  45. #define BOARD_PIN_SPI_GPIOH GPIO_Pin_13 //SPI2_SCK/I2S2_CK
  46. #define BOARD_PORT_SPI_GPIOH GPIOB // USART3_CTS(8)/
  47. // TIM1_CH1N
  48. #define BOARD_GPIO_SPI_GPIOH BOARD_PORT_SPI_GPIOH, BOARD_PIN_SPI_GPIOH //
  49. #define BOARD_PIN_H Bit_SET
  50. #define BOARD_PIN_L Bit_RESET
  51. //-----------------------LED指示灯,低电平驱动
  52. #define BOARD_PIN_LED1 GPIO_Pin_3 //
  53. #define BOARD_PORT_LED1 GPIOA
  54. #define BOARD_GPIO_LED1 BOARD_PORT_LED1, BOARD_PIN_LED1 //
  55. #define BOARD_PIN_LED2 GPIO_Pin_3
  56. #define BOARD_PORT_LED2 GPIOC
  57. #define BOARD_GPIO_LED2 BOARD_PORT_LED2, BOARD_PIN_LED2 //
  58. #define LED_ON Bit_RESET
  59. #define LED_OFF Bit_SET
  60. #define BOARD_PIN_BEEP GPIO_Pin_12
  61. #define BOARD_PORT_BEEP GPIOA
  62. #define BOARD_GPIO_BEEP BOARD_PORT_BEEP, BOARD_PIN_BEEP //
  63. #define BEEP_ON Bit_SET
  64. #define BEEP_OFF Bit_RESET
  65. //-----------------------------------------LED指示灯,END
  66. //-----------------------LCD显示器驱动IO口
  67. #define BG_LED_ON Bit_RESET
  68. #define BG_LED_OFF Bit_SET
  69. #define BOARD_PIN_LCD_BG_LED GPIO_Pin_4 //
  70. #define BOARD_PORT_LCD_BG_LED GPIOB
  71. #define BOARD_GPIO_LCD_BG_LED BOARD_PORT_LCD_BG_LED, BOARD_PIN_LCD_BG_LED //
  72. #define BOARD_PIN_LCD_SDA GPIO_Pin_7 //
  73. #define BOARD_PORT_LCD_SDA GPIOB
  74. #define BOARD_GPIO_LCD_SDA BOARD_PORT_LCD_SDA, BOARD_PIN_LCD_SDA //
  75. #define BOARD_PIN_LCD_CLK GPIO_Pin_6 //
  76. #define BOARD_PORT_LCD_CLK GPIOB
  77. #define BOARD_GPIO_LCD_CLK BOARD_PORT_LCD_CLK, BOARD_PIN_LCD_CLK //
  78. #define BOARD_PIN_LCD_RST GPIO_Pin_5 //
  79. #define BOARD_PORT_LCD_RST GPIOB
  80. #define BOARD_GPIO_LCD_RST BOARD_PORT_LCD_RST, BOARD_PIN_LCD_RST //
  81. #define LCD_SDA_H() GPIO_WriteBit(BOARD_GPIO_LCD_SDA, Bit_SET)
  82. #define LCD_SDA_L() GPIO_WriteBit(BOARD_GPIO_LCD_SDA, Bit_RESET)
  83. #define READ_LCD_SDA() GPIO_ReadInputDataBit(BOARD_GPIO_LCD_SDA)
  84. #define LCD_CLK_H() GPIO_WriteBit(BOARD_GPIO_LCD_CLK, Bit_SET)
  85. #define LCD_CLK_L() GPIO_WriteBit(BOARD_GPIO_LCD_CLK, Bit_RESET)
  86. #define LCD_RST_ENABLE() GPIO_WriteBit(BOARD_GPIO_LCD_RST, Bit_RESET)
  87. #define LCD_RST_DISABLE() GPIO_WriteBit(BOARD_GPIO_LCD_RST, Bit_SET)
  88. #define LCD_BG_LED_ON() GPIO_WriteBit(BOARD_GPIO_LCD_BG_LED, BG_LED_OFF)
  89. #define LCD_BG_LED_OFF() GPIO_WriteBit(BOARD_GPIO_LCD_BG_LED, BG_LED_ON)
  90. //-----------------------------------------LCD显示器驱动IO口,END
  91. #define BOARD_PIN_KEY1 GPIO_Pin_0
  92. #define BOARD_PORT_KEY1 GPIOA
  93. #define BOARD_GPIO_KEY1 BOARD_PORT_KEY1, BOARD_PIN_KEY1 //
  94. #define BOARD_PIN_KEY2 GPIO_Pin_14
  95. #define BOARD_PORT_KEY2 GPIOB
  96. #define BOARD_GPIO_KEY2 BOARD_PORT_KEY2, BOARD_PIN_KEY2 //
  97. #define BOARD_PIN_KEY3 GPIO_Pin_15
  98. #define BOARD_PORT_KEY3 GPIOB
  99. #define BOARD_GPIO_KEY3 BOARD_PORT_KEY3, BOARD_PIN_KEY3 //
  100. #define BOARD_PIN_KEY4 GPIO_Pin_6
  101. #define BOARD_PORT_KEY4 GPIOC
  102. #define BOARD_GPIO_KEY4 BOARD_PORT_KEY4, BOARD_PIN_KEY4 //
  103. #define BOARD_PIN_KEY5 GPIO_Pin_7
  104. #define BOARD_PORT_KEY5 GPIOC
  105. #define BOARD_GPIO_KEY5 BOARD_PORT_KEY5, BOARD_PIN_KEY5 //
  106. #define BOARD_PIN_CURRENT_AD GPIO_Pin_1 //对应ADC1
  107. #define BOARD_PORT_CURRENT_AD GPIOA
  108. #define BOARD_GPIO_CURRENT_AD BOARD_PORT_CURRENT_AD, BOARD_PIN_CURRENT_AD //
  109. #endif