soft_timer.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include "soft_timer.h"
  2. #include "main.h"
  3. #include "stdbool.h"
  4. #include "soft_flow.h"
  5. #include "soft_can.h"
  6. #include "tim.h"
  7. #include "can_debug.h"
  8. #include "soft_p_2_c.h"
  9. extern uint32_t user_timer_cnt;
  10. /**
  11. * @file timer_function
  12. * @brief 发送给控制的定时器
  13. * @param
  14. * @details
  15. * @author Zhang Sir
  16. **/
  17. bool vol_flag = false, devtype_flag = false, engine_flag = false,
  18. can_debug_flag = false, dev_version_flag = false, mimo360_radar_flag = false,DM_radar_flag = false,
  19. pmu_heart_flag = false;
  20. Dev_timer devinfo_time;
  21. void timer_function()
  22. {
  23. static uint32_t time_1hz = 0;
  24. static uint32_t time_2hz = 0;
  25. static uint32_t time_5hz = 0;
  26. static uint32_t time_10hz = 0;
  27. static uint32_t time_20hz = 0;
  28. static uint32_t time_50hz = 0;
  29. static uint32_t time_100hz = 0;
  30. static uint32_t time_200hz = 0;
  31. if ( Check_Timer_Ready(&time_1hz,_1_HZ_) )
  32. {
  33. devinfo_time.arm = true;
  34. }
  35. if ( Check_Timer_Ready(&time_2hz,_2_HZ_) )
  36. {
  37. devinfo_time.pump = true;
  38. devinfo_time.nozzle = true;
  39. devinfo_time.seed = true;
  40. devinfo_time.checklow = true;
  41. devinfo_time.current = true;
  42. dev_version_flag = true;
  43. }
  44. if ( Check_Timer_Ready(&time_5hz,_5_HZ_))
  45. {
  46. engine_flag = true;
  47. devinfo_time.bms = true;
  48. if(planep.Candebug_flag == true)
  49. {
  50. can_debug_flag = true;
  51. }
  52. else
  53. {
  54. can_debug_flag = false;
  55. }
  56. }
  57. if ( Check_Timer_Ready(&time_10hz,_10_HZ_) )
  58. {
  59. }
  60. if ( Check_Timer_Ready(&time_20hz,_20_HZ_) )
  61. {
  62. vol_flag = true;
  63. mimo360_radar_flag = true;
  64. DM_radar_flag = true;
  65. devinfo_time.weight = true;
  66. devinfo_time.L_pump1 = true;
  67. devinfo_time.L_pump2 = true;
  68. devinfo_time.radar = true;
  69. devinfo_time.part_radar = true;
  70. devinfo_time.flow = true;
  71. }
  72. if ( Check_Timer_Ready(&time_50hz,_50_HZ_) )
  73. {
  74. }
  75. if(Check_Timer_Ready(&time_100hz,_100_HZ_))
  76. {
  77. }
  78. if(Check_Timer_Ready(&time_200hz,_200_HZ_))
  79. {
  80. devtype_flag = true;
  81. }
  82. }
  83. /**
  84. * @file Get_Systimer_Us
  85. * @brief 获取系统当前时间us
  86. * @param
  87. * @details
  88. * @author Zhang Sir
  89. **/
  90. uint32_t Get_Systimer_Us(void)
  91. {
  92. //return htim4.Instance->CNT + user_timer_cnt * 0xffff;
  93. return htim4.Instance->CNT + user_timer_cnt * 20000;
  94. }