app_task.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. #include "app_task.h"
  2. #include "J1939.H"
  3. #include "app_eeprom.h"
  4. #include "ble_core.h"
  5. #include "can_task.h"
  6. #include "cli.h"
  7. #include "dev_at24cxx.h"
  8. #include "dev_task.h"
  9. #include "gpio.h"
  10. #include "key.h"
  11. #include "led.h"
  12. #include "uart_task.h"
  13. #include <stdint.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. 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 (key_button.key_state.bits.key_up_state_flag == 1)
  69. {
  70. buf[0] = 10;
  71. ble_send();
  72. app_eeprom_write_50_zhuzu();
  73. key_button.key_state.bits.key_up_state_flag = 0;
  74. }
  75. if (key_button.key_state.bits.key0_state_flag == 1)
  76. {
  77. app_eeprom_read_50_zhuzu();
  78. key_button.key_state.bits.key0_state_flag = 0;
  79. }
  80. if (key_button.key_state.bits.key1_state_flag == 1)
  81. {
  82. dev_at24cxx_read_bytes(0, buf, 1);
  83. key_button.key_state.bits.key1_state_flag = 0;
  84. }
  85. if (key_button.key_state.bits.key2_state_flag == 1)
  86. {
  87. GPIO_BEEP(beep_status);
  88. beep_status = !beep_status;
  89. key_button.key_state.bits.key2_state_flag = 0;
  90. }
  91. }
  92. /*----------------------------------------
  93. * @函数名: app_task_100ms
  94. * @描述:
  95. * @入参:
  96. * @出参: *pArr
  97. * @返回值: NONE
  98. * @调用:
  99. * @被调用:
  100. ----------------------------------------
  101. * 作者 创建时间 操作
  102. 樊春春 2023/11/13 Create/Modify
  103. ----------------------------------------*/
  104. static void app_task_100ms(void)
  105. {
  106. }
  107. /*----------------------------------------
  108. * @函数名: app_task_200ms
  109. * @描述:
  110. * @入参:
  111. * @出参: *pArr
  112. * @返回值: NONE
  113. * @调用:
  114. * @被调用:
  115. ----------------------------------------
  116. * 作者 创建时间 操作
  117. 樊春春 2023/11/13 Create/Modify
  118. ----------------------------------------*/
  119. static void app_task_200ms(void)
  120. {
  121. }
  122. /*----------------------------------------
  123. * @函数名: app_task_500ms
  124. * @描述:
  125. * @入参:
  126. * @出参: *pArr
  127. * @返回值: NONE
  128. * @调用:
  129. * @被调用:
  130. ----------------------------------------
  131. * 作者 创建时间 操作
  132. 樊春春 2023/11/13 Create/Modify
  133. ----------------------------------------*/
  134. static void app_task_500ms(void)
  135. {
  136. }
  137. /*----------------------------------------
  138. * @函数名: app_task_1000ms
  139. * @描述:
  140. * @入参:
  141. * @出参: *pArr
  142. * @返回值: NONE
  143. * @调用:
  144. * @被调用:
  145. ----------------------------------------
  146. * 作者 创建时间 操作
  147. 樊春春 2023/11/13 Create/Modify
  148. ----------------------------------------*/
  149. static void app_task_1000ms(void)
  150. {
  151. static volatile uint8_t state = 0;
  152. led_on_off(1, state);
  153. state = !state;
  154. led_on_off(1, state);
  155. systick_ms_clock++;
  156. // printf("debug\r\n");
  157. // dev_led_on_off(1, !state);
  158. }
  159. /*----------------------------------------
  160. * @函数名: app_task_2000ms
  161. * @描述:
  162. * @入参:
  163. * @出参: *pArr
  164. * @返回值: NONE
  165. * @调用:
  166. * @被调用:
  167. ----------------------------------------
  168. * 作者 创建时间 操作
  169. 樊春春 2023/11/13 Create/Modify
  170. ----------------------------------------*/
  171. static void app_task_2000ms(void)
  172. {
  173. }
  174. void app_task_schdule(void)
  175. {
  176. if (dev_task_flag.bits.task0_flag)
  177. {
  178. app_task_5ms();
  179. dev_task_flag.bits.task0_flag = 0;
  180. }
  181. if (dev_task_flag.bits.task1_flag)
  182. {
  183. app_task_10ms();
  184. dev_task_flag.bits.task1_flag = 0;
  185. }
  186. if (dev_task_flag.bits.task2_flag)
  187. {
  188. app_task_50ms();
  189. dev_task_flag.bits.task2_flag = 0;
  190. }
  191. if (dev_task_flag.bits.task3_flag)
  192. {
  193. app_task_100ms();
  194. dev_task_flag.bits.task3_flag = 0;
  195. }
  196. if (dev_task_flag.bits.task4_flag)
  197. {
  198. app_task_200ms();
  199. dev_task_flag.bits.task4_flag = 0;
  200. }
  201. if (dev_task_flag.bits.task5_flag)
  202. {
  203. app_task_500ms();
  204. dev_task_flag.bits.task5_flag = 0;
  205. }
  206. if (dev_task_flag.bits.task6_flag)
  207. {
  208. app_task_1000ms();
  209. dev_task_flag.bits.task6_flag = 0;
  210. }
  211. if (dev_task_flag.bits.task7_flag)
  212. {
  213. app_task_2000ms();
  214. dev_task_flag.bits.task7_flag = 0;
  215. }
  216. }