DIP_switch.h 925 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @Author: 李建
  3. * @Date: 2024/8/13 11:20
  4. * Description: 拨码开关
  5. * Copyright: Copyright (©) 2024 永续绿建. All rights reserved.
  6. */
  7. #ifndef FFX_BOARD_DIP_SWITCH_H
  8. #define FFX_BOARD_DIP_SWITCH_H
  9. #include "main.h"
  10. #define DIP_GPIO_PORT GPIOB
  11. // 定义4位拨码开关的引脚
  12. #define DIP_4_1_PIN GPIO_PIN_4
  13. #define DIP_4_2_PIN GPIO_PIN_5
  14. #define DIP_4_3_PIN GPIO_PIN_8
  15. #define DIP_4_4_PIN GPIO_PIN_9
  16. // 读取拨码开关状态
  17. #define DIP_4_1_State HAL_GPIO_ReadPin(DIP_GPIO_PORT, DIP_4_1_PIN)
  18. #define DIP_4_2_State HAL_GPIO_ReadPin(DIP_GPIO_PORT, DIP_4_2_PIN)
  19. #define DIP_4_3_State HAL_GPIO_ReadPin(DIP_GPIO_PORT, DIP_4_3_PIN)
  20. #define DIP_4_4_State HAL_GPIO_ReadPin(DIP_GPIO_PORT, DIP_4_4_PIN)
  21. /**
  22. * 读取4位拨码开关的数字
  23. * @return
  24. */
  25. uint8_t read_dip_4_number(void);
  26. /**
  27. * 读取2位拨码开关的数字
  28. * @return
  29. */
  30. uint8_t read_dip_2_number(void);
  31. #endif //FFX_BOARD_DIP_SWITCH_H