app_task.c 5.3 KB

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