app_task.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. #include "app_task.h"
  2. #include "app_eeprom.h"
  3. #include "cli.h"
  4. #include "dev_at24cxx.h"
  5. #include "dev_can.h"
  6. #include "hal_systick.h"
  7. #include <stdint.h>
  8. #include <stdio.h>
  9. uint8_t beep_status = 1;
  10. static uint32_t systick_ms_clock = 0;
  11. /*----------------------------------------
  12. * @函数名: app_task_5ms
  13. * @描述:
  14. * @入参:
  15. * @出参: *pArr
  16. * @返回值: NONE
  17. * @调用:
  18. * @被调用:
  19. ----------------------------------------
  20. * 作者 创建时间 操作
  21. 樊春春 2023/11/13 Create/Modify
  22. ----------------------------------------*/
  23. static void app_task_5ms(void)
  24. {
  25. dev_key_button_task();
  26. can_process();
  27. cli_loop();
  28. }
  29. /*----------------------------------------
  30. * @函数名: app_task_10ms
  31. * @描述:
  32. * @入参:
  33. * @出参: *pArr
  34. * @返回值: NONE
  35. * @调用:
  36. * @被调用:
  37. ----------------------------------------
  38. * 作者 创建时间 操作
  39. 樊春春 2023/11/13 Create/Modify
  40. ----------------------------------------*/
  41. static void app_task_10ms(void)
  42. {
  43. app_eeprom_read_task();
  44. app_eeprom_write_task();
  45. }
  46. /*----------------------------------------
  47. * @函数名: app_task_50ms
  48. * @描述:
  49. * @入参:
  50. * @出参: *pArr
  51. * @返回值: NONE
  52. * @调用:
  53. * @被调用:
  54. ----------------------------------------
  55. * 作者 创建时间 操作
  56. 樊春春 2023/11/13 Create/Modify
  57. ----------------------------------------*/
  58. static void app_task_50ms(void)
  59. {
  60. uint8_t buf[200] = {0};
  61. if (dev_key.dev_key_state.bits.key_up_state_flag == 1)
  62. {
  63. buf[0] = 10;
  64. // dev_at24cxx_write_bytes(0, &buf[99], 1);
  65. app_eeprom_write_50_zhuzu();
  66. dev_key.dev_key_state.bits.key_up_state_flag = 0;
  67. }
  68. if (dev_key.dev_key_state.bits.key0_state_flag == 1)
  69. {
  70. app_eeprom_read_50_zhuzu();
  71. // printf("%d\r\n", read_buf[33]);
  72. dev_key.dev_key_state.bits.key0_state_flag = 0;
  73. }
  74. if (dev_key.dev_key_state.bits.key1_state_flag == 1)
  75. {
  76. dev_at24cxx_read_bytes(0, buf, 1);
  77. printf("%d\r\n,%d\r\n", buf[0], buf[0]);
  78. dev_key.dev_key_state.bits.key1_state_flag = 0;
  79. }
  80. if (dev_key.dev_key_state.bits.key2_state_flag == 1)
  81. {
  82. printf("33333333\r\n");
  83. HAL_GPIO_BEEP(beep_status);
  84. beep_status = !beep_status;
  85. dev_key.dev_key_state.bits.key2_state_flag = 0;
  86. }
  87. }
  88. /*----------------------------------------
  89. * @函数名: app_task_100ms
  90. * @描述:
  91. * @入参:
  92. * @出参: *pArr
  93. * @返回值: NONE
  94. * @调用:
  95. * @被调用:
  96. ----------------------------------------
  97. * 作者 创建时间 操作
  98. 樊春春 2023/11/13 Create/Modify
  99. ----------------------------------------*/
  100. static void app_task_100ms(void)
  101. {
  102. }
  103. /*----------------------------------------
  104. * @函数名: app_task_200ms
  105. * @描述:
  106. * @入参:
  107. * @出参: *pArr
  108. * @返回值: NONE
  109. * @调用:
  110. * @被调用:
  111. ----------------------------------------
  112. * 作者 创建时间 操作
  113. 樊春春 2023/11/13 Create/Modify
  114. ----------------------------------------*/
  115. static void app_task_200ms(void)
  116. {
  117. }
  118. /*----------------------------------------
  119. * @函数名: app_task_500ms
  120. * @描述:
  121. * @入参:
  122. * @出参: *pArr
  123. * @返回值: NONE
  124. * @调用:
  125. * @被调用:
  126. ----------------------------------------
  127. * 作者 创建时间 操作
  128. 樊春春 2023/11/13 Create/Modify
  129. ----------------------------------------*/
  130. static void app_task_500ms(void)
  131. {
  132. }
  133. /*----------------------------------------
  134. * @函数名: app_task_1000ms
  135. * @描述:
  136. * @入参:
  137. * @出参: *pArr
  138. * @返回值: NONE
  139. * @调用:
  140. * @被调用:
  141. ----------------------------------------
  142. * 作者 创建时间 操作
  143. 樊春春 2023/11/13 Create/Modify
  144. ----------------------------------------*/
  145. static void app_task_1000ms(void)
  146. {
  147. static volatile uint8_t state = 0;
  148. dev_led_on_off(1, state);
  149. state = !state;
  150. dev_led_on_off(0, state);
  151. systick_ms_clock++;
  152. // printf("debug\r\n");
  153. // dev_led_on_off(1, !state);
  154. }
  155. /*----------------------------------------
  156. * @函数名: app_task_2000ms
  157. * @描述:
  158. * @入参:
  159. * @出参: *pArr
  160. * @返回值: NONE
  161. * @调用:
  162. * @被调用:
  163. ----------------------------------------
  164. * 作者 创建时间 操作
  165. 樊春春 2023/11/13 Create/Modify
  166. ----------------------------------------*/
  167. static void app_task_2000ms(void)
  168. {
  169. }
  170. void SysTick_Handler(void)
  171. {
  172. dev_task_clock();
  173. dev_systick_decrement();
  174. dev_systick_increase();
  175. systick_handler();
  176. jump_boot_time_ctrl();
  177. }
  178. void app_task_schdule(void)
  179. {
  180. if (dev_task_flag.bits.task0_flag)
  181. {
  182. app_task_5ms();
  183. dev_task_flag.bits.task0_flag = 0;
  184. }
  185. // if (dev_task_flag.bits.task1_flag && (!(dev_task_flag.all & task1_mask)))
  186. // {
  187. // app_task_10ms();
  188. // dev_task_flag.bits.task1_flag = 0;
  189. // }
  190. if (dev_task_flag.bits.task1_flag)
  191. {
  192. app_task_10ms();
  193. dev_task_flag.bits.task1_flag = 0;
  194. }
  195. if (dev_task_flag.bits.task2_flag)
  196. {
  197. app_task_50ms();
  198. dev_task_flag.bits.task2_flag = 0;
  199. }
  200. if (dev_task_flag.bits.task3_flag)
  201. {
  202. app_task_100ms();
  203. dev_task_flag.bits.task3_flag = 0;
  204. }
  205. if (dev_task_flag.bits.task4_flag)
  206. {
  207. app_task_200ms();
  208. dev_task_flag.bits.task4_flag = 0;
  209. }
  210. if (dev_task_flag.bits.task5_flag)
  211. {
  212. app_task_500ms();
  213. dev_task_flag.bits.task5_flag = 0;
  214. }
  215. if (dev_task_flag.bits.task6_flag)
  216. {
  217. app_task_1000ms();
  218. dev_task_flag.bits.task6_flag = 0;
  219. }
  220. if (dev_task_flag.bits.task7_flag)
  221. {
  222. app_task_2000ms();
  223. dev_task_flag.bits.task7_flag = 0;
  224. }
  225. }