app_task.c 5.6 KB

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