it.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #include "include.h"
  2. u8 hv_motor1_data[8];
  3. u8 hv_motor2_data[8];
  4. u8 hv_motor3_data[8];
  5. int cntBLight=0, cntSLight=0, cntUSBL=0, cntCamera1=0, cntCamera2=0, cntCamera3=0, cntCamera4=0, cntMotor1=0, cntMotor2=0;
  6. void SysTick_Handler(void)
  7. {
  8. sysTickUptime++;
  9. static u32 countbiglight = 0;
  10. static u32 countbiglightshut = 0;
  11. //两线大灯
  12. if(Read_BIG_LIGHT)
  13. {
  14. if(++cntBLight>3) {
  15. CUT_BIG_LIGHT;
  16. LightOvercurrent = 1;
  17. }
  18. }
  19. else
  20. {
  21. cntBLight = 0;
  22. if(LightOvercurrent == 0){
  23. BIG_LIGHT_ON;
  24. }
  25. }
  26. //三线小灯
  27. if(Read_SMG_LIGHT)
  28. {
  29. if(++cntSLight>3) CUT_SMG_LIGHT;
  30. }
  31. else
  32. {
  33. cntSLight = 0;
  34. if(light_pwm)
  35. {
  36. SMG_LIGHT_ON;
  37. }
  38. else
  39. {
  40. SMG_LIGHT_OFF;
  41. }
  42. }
  43. //USBL
  44. if(Read_USBL)
  45. {
  46. if(++cntUSBL>3) CUT_USBL;
  47. }
  48. else
  49. {
  50. cntUSBL = 0;
  51. if(usbl_opendown)
  52. {
  53. USBL_ON;
  54. }
  55. else
  56. {
  57. USBL_OFF;
  58. }
  59. }
  60. //camera1
  61. if(Read_CAMERA1)
  62. {
  63. if(++cntCamera1>3) CUT_CAMERA1;
  64. }
  65. else cntCamera1 = 0;
  66. //camera2
  67. if(Read_CAMERA2)
  68. {
  69. if(++cntCamera2>3) CUT_CAMERA2;
  70. }
  71. else cntCamera2 = 0;
  72. //camera3
  73. if(Read_CAMERA3)
  74. {
  75. if(++cntCamera3>3) CUT_CAMERA3;
  76. }
  77. else cntCamera3 = 0;
  78. //camera4
  79. if(Read_CAMERA4)
  80. {
  81. if(++cntCamera4>3) CUT_CAMERA4;
  82. }
  83. else cntCamera4 = 0;
  84. //motor1
  85. if(Read_MOTOR1)
  86. {
  87. if(++cntMotor1>3) CUT_Motor1;
  88. }
  89. else cntMotor1 = 0;
  90. //motor2
  91. if(Read_MOTOR2)
  92. {
  93. if(++cntMotor2>3) CUT_Motor2;
  94. }
  95. else cntMotor2 = 0;
  96. }
  97. void TIM1_UP_TIM10_IRQHandler(void)
  98. {
  99. if(TIM_GetITStatus(TIM1, TIM_IT_Update)) //判断发生update事件中断
  100. {
  101. TIM_ClearITPendingBit(TIM1, TIM_IT_Update); //清除update事件中断标志
  102. }
  103. }
  104. int u1Rx = 0;
  105. void USART1_IRQHandler(void)
  106. {
  107. if(USART_GetITStatus(USART1,USART_IT_RXNE)!=RESET)
  108. {
  109. //GetMotorData(USART1, &left_track_motor);
  110. u1Rx = USART_ReceiveData(USART1);
  111. USART_ClearITPendingBit(USART1, USART_IT_RXNE);
  112. }
  113. else if(USART_GetITStatus(USART1,USART_IT_IDLE)!=RESET)
  114. {
  115. USART1->SR;
  116. USART1->DR;
  117. //AnaMotorData(&left_track_motor);
  118. }
  119. }
  120. int u4Rx = 0;
  121. void UART4_IRQHandler(void)
  122. {
  123. if(USART_GetITStatus(UART4,USART_IT_RXNE)!=RESET)
  124. {
  125. //GetMotorData(UART4, &left_track_motor);
  126. u4Rx = USART_ReceiveData(UART4);
  127. USART_ClearITPendingBit(UART4, USART_IT_RXNE);
  128. }
  129. else if(USART_GetITStatus(UART4,USART_IT_IDLE)!=RESET)
  130. {
  131. UART4->SR;
  132. UART4->DR;
  133. //AnaMotorData(&left_track_motor);
  134. }
  135. }
  136. void CAN1_RX0_IRQHandler(void)
  137. {
  138. u8 RecData[8];
  139. u8 RecNum;
  140. u32 id = 0;
  141. IWDG_Feed();
  142. RecNum = CAN1_Receive_Msg(RecData,&id);
  143. if(id == 0X014E550A && RecNum == 7)
  144. {
  145. light_pwm = (RecData[1]<<8)|RecData[0];//灯 PWM
  146. light_step = (RecData[3]<<8)|RecData[2];//灯 PWM
  147. usbl_opendown = (RecData[5]<<8)|RecData[4];//usbl
  148. }
  149. }
  150. void ADC_IRQHandler(void)
  151. {
  152. if(ADC_GetFlagStatus(ADC1,ADC_FLAG_EOC)!=RESET)
  153. {
  154. Rntc = ADC_GetConversionValue(ADC1);
  155. }
  156. ADC_ClearITPendingBit(ADC1,ADC_FLAG_EOC);
  157. }
  158. void HardFault_Handler(void)
  159. {
  160. /* Go to infinite loop when Hard Fault exception occurs */
  161. while (1)
  162. {
  163. }
  164. }