board.h 5.2 KB

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