ConfigMacros.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #ifndef __CONFIGMACROS_H
  2. #define __CONFIGMACROS_H
  3. #include "oled.h"
  4. #include "key.h"
  5. #include "interface.h"
  6. /**
  7. * @breaf 定义测试开关
  8. */
  9. #define Test_old 0 //演示入口
  10. #define keyDebuginfo 1
  11. /**
  12. * @breaf 简化函数单体
  13. */
  14. #define open16 11 //开字
  15. #define close16 12 //关字
  16. #define resetDevAddr ((uint32_t)0x8075000)
  17. #define TIM_Start(htim) HAL_TIM_Base_Start_IT(htim)
  18. #define LED_TOGGLE(pin) HAL_GPIO_TogglePin(GPIOC, (pin)) //运行灯
  19. #define UART_PRINT(huart) HAL_UART_Transmit(huart, (uint8_t *)&ch, 1, 0xFFFF);
  20. #define PRINT_MENU_STATUS(key) printf("--->%s pressed\t%d %d %d %d\n", key, menu.current, menu.up, menu.next, menu.enter)
  21. #define HELLO(message) printf("%s\r\n", message)
  22. #define PRINT_UUID(message) printf("#%s符合设置项\n",message)
  23. #define PRINT_NUUID(message) printf("%s不符合\n",message)
  24. #define RXNE_UART(huart) __HAL_UART_ENABLE_IT(huart, UART_IT_RXNE)
  25. /**
  26. * @breaf BT模组测试重启 */
  27. #define RESET_BT_MODULE_demo() \
  28. if(resetBTmodule) { \
  29. resetBTmodule = false; \
  30. MBA32A_Init_demo(); \
  31. }
  32. /**
  33. * @breaf BT模组重启 */
  34. #define RESET_BT_MODULE() \
  35. if(resetBTmodule) { \
  36. resetBTmodule = false; \
  37. MBA32A_Init(); \
  38. }
  39. /**
  40. * @breaf 4G模组重启 */
  41. #define RESET_4G_MODULE() \
  42. if(reset4Gmodule) { \
  43. reset4Gmodule = false; \
  44. ML307A_Init(); \
  45. }
  46. /**
  47. * @breaf 简化函数多体
  48. */
  49. /* OLED显示 */
  50. #define OLED_DISPLAY(color, display) do { \
  51. OLED_Init(); \
  52. OLED_ColorTurn(color); \
  53. OLED_DisplayTurn(display); \
  54. } while(0)
  55. /* 设置键值 */
  56. #define SET_MENU_STATUS(current_value, up_value, next_value, enter_value) \
  57. do { \
  58. menu.current = current_value; \
  59. menu.up = up_value; \
  60. menu.next = next_value; \
  61. menu.enter = enter_value; \
  62. refresh = true;\
  63. } while(0)
  64. /* WDI */
  65. #define TOGGLE_WDI_PIN(htim_instance) \
  66. do { \
  67. if ((htim_instance)->Instance == TIM2) { \
  68. HAL_GPIO_TogglePin(WDI_GPIO_Port, WDI_Pin); \
  69. } \
  70. } while(0)
  71. /* 扫描按键刷新屏幕 */
  72. #define UPDATE_EXECUTE_REFRESH() \
  73. do { \
  74. updatekeystate(); \
  75. execute_interface(menu); \
  76. OLED_Refresh(); \
  77. } while(0)
  78. /* U1-U4 DMA */
  79. #define IDLE_DMA_UART(huart) \
  80. do {\
  81. __HAL_UART_ENABLE_IT(huart, UART_IT_IDLE); \
  82. HAL_UART_Receive_DMA(huart, recvBuff, 2048); \
  83. } while(0)
  84. /* 蓝牙参数初始化(流水号/dtu1/自动施封时间) */
  85. #define INIT_BT_FRAME() \
  86. do { \
  87. btframe.serialNum = 0x00000001; \
  88. btframe.userId = 0x64747531; \
  89. btframe.Autoseal = 0x01; \
  90. printf("\t###01\tBT_init%d...\r\n", resetcount_bt); \
  91. } while (0)
  92. /* 4G参数初始化*/
  93. #define INIT_4G_FRAME() \
  94. do { \
  95. printf("\t###02\t4G_init%d...\r\n",resetcount_4g); \
  96. } while (0)
  97. /**
  98. * @breaf 结构体定义
  99. */
  100. /* 界面参数结构体 */
  101. typedef struct
  102. {
  103. uint8_t current; //当前状态索引号
  104. uint8_t up; //向下一个
  105. uint8_t next; //向下一个
  106. uint8_t enter; //确定
  107. unsigned char* sn; //sn
  108. uint32_t home;
  109. } Menu_table;
  110. /* 按键参数结构体 */
  111. struct keys
  112. {
  113. unsigned char judge_sta; //判断按键按键按下的动作到了第几步
  114. bool key_sta; //如果按键被按下,为0
  115. bool key_flag; //如果确认被按下,为1
  116. };
  117. /* 蓝牙锁信息帧参数结构体 */
  118. typedef struct
  119. {
  120. uint32_t serialNum; //4字节流水号
  121. uint32_t userId; //4字节userid
  122. uint32_t Ntime; //4字节时间
  123. uint8_t Autoseal; //1字节自动施封
  124. } BtFrame;
  125. typedef enum {
  126. BtStepDefault = 0,
  127. UUIDS = 1,
  128. UUIDN = 2,
  129. UUIDW = 3,
  130. } BtStep;
  131. typedef enum {
  132. Default = 0,
  133. InProgress = 1,
  134. Abnormal_motor = 2
  135. } TipsFlag;
  136. #endif /*__CONFIGMACROS_H*/