foc_irqs.c 672 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "stm32f3xx_hal.h"
  2. #include "stm32f3xx_ll_tim.h"
  3. #include "stm32f3xx_ll_adc.h"
  4. __weak void foc_brake_handler(void) {}
  5. __weak void foc_pwm_up_handler(void) {}
  6. __weak void system_tick_handler(void){}
  7. __weak void current_sample_handler(void){}
  8. void TIM1_BRK_TIM15_IRQHandler(void){
  9. if (LL_TIM_IsActiveFlag_BRK2(TIM1))
  10. {
  11. LL_TIM_ClearFlag_BRK2(TIM1);
  12. TIM1->BDTR |= LL_TIM_OSSI_ENABLE;
  13. foc_brake_handler();
  14. }
  15. }
  16. void TIM1_UP_TIM16_IRQHandler(void){
  17. LL_TIM_ClearFlag_UPDATE(TIM1);
  18. foc_pwm_up_handler();
  19. }
  20. void ADC1_IRQHandler(void) {
  21. LL_ADC_ClearFlag_JEOS( ADC1 );
  22. current_sample_handler();
  23. }
  24. void SysTick_Handler(void)
  25. {
  26. system_tick_handler();
  27. }