foc_irqs.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. void TIM1_BRK_TIM15_IRQHandler(void){
  11. if (LL_TIM_IsActiveFlag_BRK2(TIM1))
  12. {
  13. LL_TIM_ClearFlag_BRK2(TIM1);
  14. TIM1->BDTR |= LL_TIM_OSSI_ENABLE;
  15. foc_brake_handler();
  16. }
  17. }
  18. void TIM1_UP_TIM16_IRQHandler(void){
  19. LL_TIM_ClearFlag_UPDATE(TIM1);
  20. foc_pwm_up_handler();
  21. }
  22. void ADC1_IRQHandler(void) {
  23. LL_ADC_ClearFlag_JEOS( ADC1 );
  24. current_sample_handler();
  25. }
  26. void SysTick_Handler(void)
  27. {
  28. system_tick_handler();
  29. }
  30. void EXTI3_IRQHandler(void) {
  31. if ( LL_EXTI_ReadFlag_0_31(LL_EXTI_LINE_3) )
  32. {
  33. LL_EXTI_ClearFlag_0_31 (LL_EXTI_LINE_3);
  34. hall_sensor_handler();
  35. }
  36. }
  37. void EXTI15_10_IRQHandler(void) {
  38. if ( LL_EXTI_ReadFlag_0_31(LL_EXTI_LINE_10) )
  39. {
  40. LL_EXTI_ClearFlag_0_31 (LL_EXTI_LINE_10);
  41. hall_sensor_handler();
  42. }
  43. if ( LL_EXTI_ReadFlag_0_31(LL_EXTI_LINE_15) )
  44. {
  45. LL_EXTI_ClearFlag_0_31 (LL_EXTI_LINE_15);
  46. hall_sensor_handler();
  47. }
  48. }