mirror of https://github.com/ARMmbed/mbed-os.git
Merge branch 'fix_int_handler' of https://github.com/svastm/mbed into svastm-fix_int_handler
Conflicts: hal/targets/hal/TARGET_STM/TARGET_STM32F0/pwmout_api.c hal/targets/hal/TARGET_STM/TARGET_STM32F7/pwmout_api.cpull/2166/head
commit
c8fc07928a
|
@ -51,9 +51,11 @@ void timer_update_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++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used for mbed timeout (channel 1) and HAL tick (channel 2)
|
// Used for mbed timeout (channel 1) and HAL tick (channel 2)
|
||||||
|
@ -64,7 +66,8 @@ void timer_oc_irq_handler(void)
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -78,10 +81,12 @@ void timer_oc_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
|
||||||
|
@ -91,6 +96,7 @@ void timer_oc_irq_handler(void)
|
||||||
PreviousVal = val;
|
PreviousVal = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -77,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -77,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -51,9 +51,11 @@ void timer_update_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++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used for mbed timeout (channel 1) and HAL tick (channel 2)
|
// Used for mbed timeout (channel 1) and HAL tick (channel 2)
|
||||||
|
@ -64,7 +66,8 @@ void timer_oc_irq_handler(void)
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -78,10 +81,12 @@ void timer_oc_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
|
||||||
|
@ -94,6 +99,7 @@ void timer_oc_irq_handler(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -78,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -78,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -51,13 +51,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;
|
||||||
|
@ -71,10 +74,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
|
||||||
|
@ -84,6 +89,7 @@ void timer_irq_handler(void) {
|
||||||
PreviousVal = val;
|
PreviousVal = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -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
|
||||||
|
@ -85,6 +90,7 @@ void timer_irq_handler(void) {
|
||||||
PreviousVal = val;
|
PreviousVal = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -56,9 +59,10 @@ void timer_irq_handler(void) {
|
||||||
// Prepare next interrupt
|
// Prepare next interrupt
|
||||||
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_2, val + HAL_TICK_DELAY);
|
__HAL_TIM_SetCompare(&TimMasterHandle, TIM_CHANNEL_2, val + HAL_TICK_DELAY);
|
||||||
PreviousVal = val;
|
PreviousVal = val;
|
||||||
#if 0 // For DEBUG only
|
#if 0 // For DEBUG only
|
||||||
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_6);
|
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_6);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -44,12 +44,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -63,6 +67,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -78,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -76,9 +80,9 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
if ( SystemCoreClock == 16000000 ) {
|
if ( SystemCoreClock == 16000000 ) {
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)( SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)( SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
} else {
|
} else {
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)( SystemCoreClock / 2 / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)( SystemCoreClock / 2 / 1000000) - 1; // 1 us tick
|
||||||
}
|
}
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -77,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -77,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -75,7 +79,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -77,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -78,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -77,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -77,7 +82,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -44,12 +44,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -63,6 +67,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -44,12 +44,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -63,6 +67,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -76,9 +80,9 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
if ( SystemCoreClock == 16000000 ) {
|
if ( SystemCoreClock == 16000000 ) {
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)( SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)( SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
} else {
|
} else {
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)( SystemCoreClock / 2 / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)( SystemCoreClock / 2 / 1000000) - 1; // 1 us tick
|
||||||
}
|
}
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
|
|
@ -41,13 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -61,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
@ -75,7 +79,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
TimMasterHandle.Init.Period = 0xFFFFFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)( SystemCoreClock / 1000000) - 1; // 1 µs tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)( SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
TimMasterHandle.Init.RepetitionCounter = 0;
|
TimMasterHandle.Init.RepetitionCounter = 0;
|
||||||
|
|
|
@ -45,13 +45,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -65,6 +68,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -45,13 +45,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -65,6 +68,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -45,13 +45,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -65,6 +68,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -51,13 +51,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;
|
||||||
|
@ -71,10 +74,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
|
||||||
|
@ -84,6 +89,7 @@ void timer_irq_handler(void) {
|
||||||
PreviousVal = val;
|
PreviousVal = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -51,8 +51,7 @@ 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) {
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_UPDATE) == SET)
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_UPDATE) == SET) {
|
||||||
{
|
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_UPDATE);
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_UPDATE);
|
||||||
SlaveCounter++;
|
SlaveCounter++;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +59,7 @@ void timer_irq_handler(void) {
|
||||||
|
|
||||||
// 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) {
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET)
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
{
|
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
__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
|
||||||
|
@ -80,8 +78,7 @@ 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) {
|
||||||
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET)
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
{
|
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
|
|
@ -51,13 +51,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;
|
||||||
|
@ -71,10 +74,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
|
||||||
|
@ -84,6 +89,7 @@ void timer_irq_handler(void) {
|
||||||
PreviousVal = val;
|
PreviousVal = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -51,13 +51,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;
|
||||||
|
@ -71,10 +74,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
|
||||||
|
@ -84,6 +89,7 @@ void timer_irq_handler(void) {
|
||||||
PreviousVal = val;
|
PreviousVal = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -51,13 +51,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;
|
||||||
|
@ -71,10 +74,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
|
||||||
|
@ -84,6 +89,7 @@ void timer_irq_handler(void) {
|
||||||
PreviousVal = val;
|
PreviousVal = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -41,12 +41,16 @@ void us_ticker_irq_handler(void);
|
||||||
|
|
||||||
void timer_irq_handler(void) {
|
void timer_irq_handler(void) {
|
||||||
// Channel 1 for mbed timeout
|
// Channel 1 for mbed timeout
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC1) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC1) == SET) {
|
||||||
|
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC1);
|
||||||
us_ticker_irq_handler();
|
us_ticker_irq_handler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Channel 2 for HAL tick
|
// Channel 2 for HAL tick
|
||||||
if (__HAL_TIM_GET_ITSTATUS(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
if (__HAL_TIM_GET_FLAG(&TimMasterHandle, TIM_FLAG_CC2) == SET) {
|
||||||
|
if (__HAL_TIM_GET_IT_SOURCE(&TimMasterHandle, TIM_IT_CC2) == SET) {
|
||||||
__HAL_TIM_CLEAR_IT(&TimMasterHandle, TIM_IT_CC2);
|
__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) {
|
||||||
|
@ -60,6 +64,7 @@ void timer_irq_handler(void) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconfigure the HAL tick using a standard timer instead of systick.
|
// Reconfigure the HAL tick using a standard timer instead of systick.
|
||||||
|
|
|
@ -180,7 +180,7 @@ void us_ticker_init(void) {
|
||||||
// Configure time base
|
// Configure time base
|
||||||
TimMasterHandle.Instance = TIM_MST;
|
TimMasterHandle.Instance = TIM_MST;
|
||||||
TimMasterHandle.Init.Period = 0xFFFF;
|
TimMasterHandle.Init.Period = 0xFFFF;
|
||||||
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 <EFBFBD>s tick
|
TimMasterHandle.Init.Prescaler = (uint32_t)(SystemCoreClock / 1000000) - 1; // 1 us tick
|
||||||
TimMasterHandle.Init.ClockDivision = 0;
|
TimMasterHandle.Init.ClockDivision = 0;
|
||||||
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimMasterHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
HAL_TIM_Base_Init(&TimMasterHandle);
|
HAL_TIM_Base_Init(&TimMasterHandle);
|
||||||
|
|
Loading…
Reference in New Issue