You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.4 KiB

  1. /*
  2. * @Author: sunlight 2524828700@qq.com
  3. * @Date: 2024-09-18 20:58:48
  4. * @LastEditors: sunlight 2524828700@qq.com
  5. * @LastEditTime: 2024-09-21 11:35:50
  6. * @FilePath: \auxiliary_addition\Usr\time_slice\time_slice.c
  7. * @Description: Ĭ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  8. */
  9. #include "time_slice.h"
  10. #include "tim.h"
  11. static uint32_t time1;
  12. static uint32_t time2;
  13. static uint32_t time3;
  14. static bool tjc_process_flag = false;
  15. static bool low_power_flag = false;
  16. static bool debug_light_flag = false;
  17. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
  18. time1++;
  19. time2++;
  20. time3++;
  21. if (time1 == 2) {
  22. tjc_process_flag = true;
  23. time1 = 0;
  24. }
  25. if (time2 == 1000) {
  26. low_power_flag = true;
  27. time2 = 0;
  28. }
  29. if (time3 == 500) {
  30. debug_light_flag = true;
  31. time3 = 0;
  32. }
  33. }
  34. bool GetFlag(uint32_t slice_flag) {
  35. switch (slice_flag) {
  36. case tjc_process:
  37. return tjc_process_flag;
  38. case low_power:
  39. return low_power_flag;
  40. case debug_light:
  41. return debug_light_flag;
  42. }
  43. }
  44. void ClearFlag(uint32_t slice_flag) {
  45. switch (slice_flag) {
  46. case tjc_process:
  47. tjc_process_flag = false;
  48. break;
  49. case low_power:
  50. low_power_flag = false;
  51. break;
  52. case debug_light:
  53. debug_light_flag = false;
  54. break;
  55. }
  56. }