board.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #ifndef _BOARD_H_
  3. #define _BOARD_H_
  4. /* Includes */
  5. #include "main.h"
  6. /* Type Defs */
  7. typedef enum {
  8. Disable = 0,
  9. Emable = 1
  10. } dis_en_t;
  11. /* Defines */
  12. #define BTN_NUM 3
  13. #define SWITCH_NUM 5
  14. #define BTN_PORT GPIOA
  15. #define SWITCH_PORT GPIOA
  16. #define BTN1_PIN GPIO_IDR_0
  17. #define BTN2_PIN GPIO_IDR_1
  18. #define BTN3_PIN GPIO_IDR_4
  19. #define SW1_PIN GPIO_IDR_2
  20. #define SW2_PIN GPIO_IDR_3
  21. #define SW3_PIN GPIO_IDR_5
  22. #define SW4_PIN GPIO_IDR_7
  23. #define SW5_PIN GPIO_IDR_6
  24. /* Exported macros */
  25. #define BUZER_ON TIM1->CR1 |= TIM_CR1_CEN
  26. #define BUZER_OFF TIM1->CR1 &= ~TIM_CR1_CEN
  27. #define BTN1_STATE (BTN_PORT->IDR & BTN1_PIN)
  28. #define BTN2_STATE (BTN_PORT->IDR & BTN2_PIN)
  29. #define BTN3_STATE (BTN_PORT->IDR & BTN3_PIN)
  30. #define SW1_STATE (SWITCH_PORT->IDR & SW1_PIN)
  31. #define SW2_STATE (SWITCH_PORT->IDR & SW2_PIN)
  32. #define SW3_STATE (SWITCH_PORT->IDR & SW3_PIN)
  33. #define SW4_STATE (SWITCH_PORT->IDR & SW4_PIN)
  34. #define SW5_STATE (SWITCH_PORT->IDR & SW5_PIN)
  35. #define BTNS_STATE (BTN_PORT->IDR & (BTN1_PIN | BTN2_PIN | BTN3_PIN))
  36. #define SWS_STATE (SWITCH_PORT->IDR & (SW1_PIN | SW2_PIN | SW3_PIN | SW4_PIN | SW5_PIN))
  37. /* Display macros */
  38. #define HT1632C_CS_ON GPIOA->BRR = (1<<15)
  39. #define HT1632C_CS_OFF GPIOA->BSRR = (1<<15)
  40. #define HT1632C_WR_LOW GPIOB->BRR = (1<<3)
  41. #define HT1632C_WR_HGH GPIOB->BSRR = (1<<3)
  42. #define HT1632C_DATA_0 GPIOB->BRR = (1<<5)
  43. #define HT1632C_DATA_1 GPIOB->BSRR = (1<<5)
  44. /* Exported funcions */
  45. void Board_Init(void);
  46. void DMA1_Channel2_3_IRQHandler(void);
  47. void I2C1_IRQHandler(void);
  48. void GPIO_SPI_SW(void);
  49. void GPIO_SPI_HW(void);
  50. #endif /* _BOARD_H_ */