Merge pull request #2194 from zgoda/BLUEPILL_fix_int_handler

[BLUEPILL_F103C8] Fix interrupt handler
pull/2098/head
Martin Kojtal 2016-07-21 10:56:21 +01:00 committed by GitHub
commit c9d8690fa9
1 changed files with 26 additions and 20 deletions

View File

@ -52,13 +52,16 @@ void timer_irq_handler(void) {
// Clear Update interrupt flag // Clear Update interrupt flag
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_UPDATE) == SET) { if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_UPDATE) == SET) {
__HAL_TIM_CLEAR_FLAG(&TimMasterHandle, TIM_FLAG_UPDATE); if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_UPDATE) == SET) {
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_UPDATE);
SlaveCounter++; SlaveCounter++;
} }
}
// Channel 1 for mbed timeout // Channel 1 for mbed timeout
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) { if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
__HAL_TIM_CLEAR_FLAG(&TimMasterHandle, TIM_FLAG_CC1); if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
if (oc_rem_part > 0) { if (oc_rem_part > 0) {
set_compare(oc_rem_part); // Finish the remaining time left set_compare(oc_rem_part); // Finish the remaining time left
oc_rem_part = 0; oc_rem_part = 0;
@ -72,10 +75,12 @@ void timer_irq_handler(void) {
} }
} }
} }
}
// Channel 2 for HAL tick // Channel 2 for HAL tick
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) { if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
__HAL_TIM_CLEAR_FLAG(&TimMasterHandle, TIM_FLAG_CC2); if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
uint32_t val = __HAL_TIM_GetCounter(&TimMasterHandle); uint32_t val = __HAL_TIM_GetCounter(&TimMasterHandle);
if ((val - PreviousVal) >= HAL_TICK_DELAY) { if ((val - PreviousVal) >= HAL_TICK_DELAY) {
// Increment HAL variable // Increment HAL variable
@ -86,6 +91,7 @@ void timer_irq_handler(void) {
} }
} }
} }
}
// Reconfigure the HAL tick using a standard timer instead of systick. // Reconfigure the HAL tick using a standard timer instead of systick.
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) { HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {