app_task.c 5.2 KB

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