mirror of https://github.com/ARMmbed/mbed-os.git
[STM32F4XX] Fix timer interrupt handler
parent
307a13c095
commit
db49b362e9
|
@ -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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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 <EFBFBD>s 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;
|
||||||
|
|
Loading…
Reference in New Issue