app_task.c 5.5 KB

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