foc_irqs.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. __weak void foc_slow_task_handler(void){}
  12. __weak void start_stop_handler(void) {}
  13. void TIM1_BRK_TIM15_IRQHandler(void){
  14. if (LL_TIM_IsActiveFlag_BRK2(TIM1))
  15. {
  16. LL_TIM_ClearFlag_BRK2(TIM1);
  17. TIM1->BDTR |= LL_TIM_OSSI_ENABLE;
  18. foc_brake_handler();
  19. }
  20. }
  21. void TIM1_UP_TIM16_IRQHandler(void){
  22. if (LL_TIM_IsActiveFlag_UPDATE(TIM1))
  23. {
  24. LL_TIM_ClearFlag_UPDATE(TIM1);
  25. foc_pwm_up_handler();
  26. }
  27. }
  28. void ADC1_IRQHandler(void) {
  29. LL_ADC_ClearFlag_JEOS( ADC1 );
  30. current_sample_handler();
  31. }
  32. void TIM6_DAC_IRQHandler(void) {
  33. if (LL_TIM_IsActiveFlag_UPDATE(TIM6))
  34. {
  35. LL_TIM_ClearFlag_UPDATE(TIM6);
  36. foc_slow_task_handler();
  37. }
  38. }
  39. void SysTick_Handler(void)
  40. {
  41. system_tick_handler();
  42. }
  43. void EXTI3_IRQHandler(void) {
  44. if ( LL_EXTI_ReadFlag_0_31(LL_EXTI_LINE_3) )
  45. {
  46. LL_EXTI_ClearFlag_0_31 (LL_EXTI_LINE_3);
  47. hall_sensor_handler();
  48. }
  49. }
  50. void EXTI15_10_IRQHandler(void) {
  51. if ( LL_EXTI_ReadFlag_0_31(LL_EXTI_LINE_10) )
  52. {
  53. LL_EXTI_ClearFlag_0_31 (LL_EXTI_LINE_10);
  54. hall_sensor_handler();
  55. }
  56. if ( LL_EXTI_ReadFlag_0_31(LL_EXTI_LINE_13) )
  57. {
  58. LL_EXTI_ClearFlag_0_31 (LL_EXTI_LINE_13);
  59. start_stop_handler();
  60. }
  61. if ( LL_EXTI_ReadFlag_0_31(LL_EXTI_LINE_15) )
  62. {
  63. LL_EXTI_ClearFlag_0_31 (LL_EXTI_LINE_15);
  64. hall_sensor_handler();
  65. }
  66. }
  67. void USART2_IRQHandler(void) {
  68. uart2_irq_handler();
  69. }