2014-01-09 06:20:26 -08:00
|
|
|
/*
|
2016-11-04 07:18:34 -07:00
|
|
|
Copyright 2016 Benjamin Vedder benjamin@vedder.se
|
2014-01-09 06:20:26 -08:00
|
|
|
|
2016-11-04 07:18:34 -07:00
|
|
|
This file is part of the VESC firmware.
|
|
|
|
|
|
|
|
The VESC firmware is free software: you can redistribute it and/or modify
|
2014-01-09 06:20:26 -08:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
2016-11-04 07:18:34 -07:00
|
|
|
The VESC firmware is distributed in the hope that it will be useful,
|
2014-01-09 06:20:26 -08:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ch.h"
|
|
|
|
#include "hal.h"
|
|
|
|
#include "stm32f4xx_conf.h"
|
2015-10-08 14:09:39 -07:00
|
|
|
#include "isr_vector_table.h"
|
2015-12-08 12:01:23 -08:00
|
|
|
#include "mc_interface.h"
|
2017-09-04 12:12:43 -07:00
|
|
|
#include "mcpwm_foc.h"
|
2015-04-11 01:07:36 -07:00
|
|
|
#include "hw.h"
|
2015-12-08 12:01:23 -08:00
|
|
|
#include "encoder.h"
|
2014-01-09 06:20:26 -08:00
|
|
|
|
|
|
|
CH_IRQ_HANDLER(ADC1_2_3_IRQHandler) {
|
2014-02-15 14:36:50 -08:00
|
|
|
CH_IRQ_PROLOGUE();
|
2014-01-09 06:20:26 -08:00
|
|
|
ADC_ClearITPendingBit(ADC1, ADC_IT_JEOC);
|
2015-12-08 12:01:23 -08:00
|
|
|
mc_interface_adc_inj_int_handler();
|
2014-02-15 14:36:50 -08:00
|
|
|
CH_IRQ_EPILOGUE();
|
2014-01-09 06:20:26 -08:00
|
|
|
}
|
2015-04-11 01:07:36 -07:00
|
|
|
|
|
|
|
CH_IRQ_HANDLER(HW_ENC_EXTI_ISR_VEC) {
|
|
|
|
if (EXTI_GetITStatus(HW_ENC_EXTI_LINE) != RESET) {
|
2015-12-08 12:01:23 -08:00
|
|
|
encoder_reset();
|
2015-04-11 01:07:36 -07:00
|
|
|
|
|
|
|
// Clear the EXTI line pending bit
|
|
|
|
EXTI_ClearITPendingBit(HW_ENC_EXTI_LINE);
|
|
|
|
}
|
|
|
|
}
|
2016-04-27 06:32:32 -07:00
|
|
|
|
|
|
|
CH_IRQ_HANDLER(HW_ENC_TIM_ISR_VEC) {
|
|
|
|
if (TIM_GetITStatus(HW_ENC_TIM, TIM_IT_Update) != RESET) {
|
|
|
|
encoder_tim_isr();
|
|
|
|
|
|
|
|
// Clear the IT pending bit
|
|
|
|
TIM_ClearITPendingBit(HW_ENC_TIM, TIM_IT_Update);
|
|
|
|
}
|
|
|
|
}
|
2017-09-04 12:12:43 -07:00
|
|
|
|
|
|
|
CH_IRQ_HANDLER(TIM8_CC_IRQHandler) {
|
|
|
|
if (TIM_GetITStatus(TIM8, TIM_IT_CC1) != RESET) {
|
|
|
|
mcpwm_foc_tim_sample_int_handler();
|
|
|
|
|
|
|
|
// Clear the IT pending bit
|
|
|
|
TIM_ClearITPendingBit(TIM8, TIM_IT_CC1);
|
|
|
|
}
|
|
|
|
}
|