soft_timer.c 2.6 KB

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