Key.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*********************************************************************************************************
  2. * 模块名称:Key.h
  3. * 摘 要:Key模块,进行独立按键初始化,以及按键扫描函数实现
  4. * 当前版本:1.0.0
  5. * 作 者:Leyutek(COPYRIGHT 2018 - 2021 Leyutek. All rights reserved.)
  6. * 完成日期:2021年07月01日
  7. * 内 容:
  8. * 注 意:
  9. **********************************************************************************************************
  10. * 取代版本:
  11. * 作 者:
  12. * 完成日期:
  13. * 修改内容:
  14. * 修改文件:
  15. *********************************************************************************************************/
  16. #ifndef _KEY_H_
  17. #define _KEY_H_
  18. /*********************************************************************************************************
  19. * 包含头文件
  20. *********************************************************************************************************/
  21. #include "gd32e230x_conf.h"
  22. /*********************************************************************************************************
  23. * 宏定义
  24. *********************************************************************************************************/
  25. #include "Main.h"
  26. #define KEY_1_2_RCU GPIOF
  27. #define KEY_3_4_RCU GPIOA
  28. #define KEY1 GPIO_PIN_7
  29. #define KEY2 GPIO_PIN_6
  30. #define KEY3 GPIO_PIN_12
  31. #define KEY4 GPIO_PIN_8
  32. #define KEY_ON 0
  33. #define KEY_OFF 1
  34. #define KEY_NAME_MAX 4
  35. #if ACSingPhSmaCurr
  36. #define DERECTION_GPIO GPIOA
  37. #define DERECTION_IO_1 GPIO_PIN_1
  38. #endif
  39. #if ACSingPhHigCurr
  40. #define DERECTION_GPIO GPIOB
  41. #define DERECTION_IO_1 GPIO_PIN_10
  42. #endif
  43. /*********************************************************************************************************
  44. * 枚举结构体
  45. *********************************************************************************************************/
  46. /*********************************************************************************************************
  47. * API函数声明
  48. *********************************************************************************************************/
  49. void InitKey(void); //初始化Key模块
  50. unsigned char ScanKey(unsigned int gpio_periph,unsigned int pin); //
  51. unsigned char ReadKeyValue(void); //上电读取一次modbus的地址
  52. unsigned char get_detection();
  53. #endif