foc_irqs.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "stm32f3xx_hal.h"
  2. #include "stm32f3xx_ll_tim.h"
  3. #include "stm32f3xx_ll_adc.h"
  4. #include "stm32f3xx_ll_exti.h"
  5. __weak void foc_brake_handler(void) {}
  6. __weak void foc_pwm_up_handler(void) {}
  7. __weak void system_tick_handler(void){}
  8. __weak void current_sample_handler(void){}
  9. __weak void hall_sensor_handler(void){}
  10. __weak void uart2_irq_handler(void) {}
  11. void TIM1_BRK_TIM15_IRQHandler(void){
  12. if (LL_TIM_IsActiveFlag_BRK2(TIM1))
  13. {
  14. LL_TIM_ClearFlag_BRK2(TIM1);
  15. TIM1->BDTR |= LL_TIM_OSSI_ENABLE;
  16. foc_brake_handler();
  17. }
  18. }
  19. void TIM1_UP_TIM16_IRQHandler(void){
  20. LL_TIM_ClearFlag_UPDATE(TIM1);
  21. foc_pwm_up_handler();
  22. }
  23. void ADC1_IRQHandler(void) {
  24. LL_ADC_ClearFlag_JEOS( ADC1 );
  25. current_sample_handler();
  26. }
  27. void SysTick_Handler(void)
  28. {
  29. system_tick_handler();
  30. }
  31. void EXTI3_IRQHandler(void) {
  32. if ( LL_EXTI_ReadFlag_0_31(LL_EXTI_LINE_3) )
  33. {
  34. LL_EXTI_ClearFlag_0_31 (LL_EXTI_LINE_3);
  35. hall_sensor_handler();
  36. }
  37. }
  38. void EXTI15_10_IRQHandler(void) {
  39. if ( LL_EXTI_ReadFlag_0_31(LL_EXTI_LINE_10) )
  40. {
  41. LL_EXTI_ClearFlag_0_31 (LL_EXTI_LINE_10);
  42. hall_sensor_handler();
  43. }
  44. if ( LL_EXTI_ReadFlag_0_31(LL_EXTI_LINE_15) )
  45. {
  46. LL_EXTI_ClearFlag_0_31 (LL_EXTI_LINE_15);
  47. hall_sensor_handler();
  48. }
  49. }
  50. void USART2_IRQHandler(void) {
  51. uart2_irq_handler();
  52. }