soft_timer.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. devinfo_time.tempSensor = true;
  35. }
  36. if ( Check_Timer_Ready(&time_2hz,_2_HZ_) )
  37. {
  38. devinfo_time.pump = true;
  39. devinfo_time.nozzle = true;
  40. devinfo_time.seed = true;
  41. devinfo_time.checklow = true;
  42. devinfo_time.current = true;
  43. dev_version_flag = true;
  44. }
  45. if ( Check_Timer_Ready(&time_5hz,_5_HZ_))
  46. {
  47. engine_flag = true;
  48. devinfo_time.bms = true;
  49. if(planep.Candebug_flag == true)
  50. {
  51. can_debug_flag = true;
  52. }
  53. else
  54. {
  55. can_debug_flag = false;
  56. }
  57. }
  58. if ( Check_Timer_Ready(&time_10hz,_10_HZ_) )
  59. {
  60. }
  61. if ( Check_Timer_Ready(&time_20hz,_20_HZ_) )
  62. {
  63. vol_flag = true;
  64. mimo360_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.part_Fradar = true;
  71. devinfo_time.flow = true;
  72. devinfo_time.part_Bradar = true;
  73. }
  74. if ( Check_Timer_Ready(&time_50hz,_50_HZ_) )
  75. {
  76. DM_radar_flag = true;
  77. }
  78. if(Check_Timer_Ready(&time_100hz,_100_HZ_))
  79. {
  80. }
  81. if(Check_Timer_Ready(&time_200hz,_200_HZ_))
  82. {
  83. devtype_flag = true;
  84. }
  85. }
  86. /**
  87. * @file Get_Systimer_Us
  88. * @brief 获取系统当前时间us
  89. * @param
  90. * @details
  91. * @author Zhang Sir
  92. **/
  93. uint32_t Get_Systimer_Us(void)
  94. {
  95. //return htim4.Instance->CNT + user_timer_cnt * 0xffff;
  96. return htim4.Instance->CNT + user_timer_cnt * 20000;
  97. }