diff --git a/network/robus_network/HAL/STM32F0/robus_hal.c b/network/robus_network/HAL/STM32F0/robus_hal.c index 7e5b7d2d9..84e5482b2 100644 --- a/network/robus_network/HAL/STM32F0/robus_hal.c +++ b/network/robus_network/HAL/STM32F0/robus_hal.c @@ -389,6 +389,11 @@ static void RobusHAL_TimeoutInit(void) ******************************************************************************/ _CRITICAL void RobusHAL_ResetTimeout(uint16_t nbrbit) { + /* TODO: optimize further by getting rid of the need to reach for the ARR value. + The same result can be achieved by only setting the start value of the counter and letting it count down toward 0. + An IRQ can then be generated when reaching 0. This way diff = counter_value. + */ + uint32_t arr_val, diff; arr_val = LL_TIM_ReadReg(ROBUS_TIMER, ARR); // Get actual timeout value diff = arr_val-LL_TIM_ReadReg(ROBUS_TIMER, CNT); // Compute remaining time before timeout diff --git a/network/robus_network/HAL/STM32F4/robus_hal.c b/network/robus_network/HAL/STM32F4/robus_hal.c index 29e7eac32..744fc6752 100644 --- a/network/robus_network/HAL/STM32F4/robus_hal.c +++ b/network/robus_network/HAL/STM32F4/robus_hal.c @@ -393,6 +393,11 @@ static void RobusHAL_TimeoutInit(void) ******************************************************************************/ _CRITICAL void RobusHAL_ResetTimeout(uint16_t nbrbit) { + /* TODO: optimize further by getting rid of the need to reach for the ARR value. + The same result can be achieved by only setting the start value of the counter and letting it count down toward 0. + An IRQ can then be generated when reaching 0. This way diff = counter_value. + */ + uint32_t arr_val, diff; arr_val = LL_TIM_ReadReg(ROBUS_TIMER, ARR); // Get actual timeout value diff = arr_val-LL_TIM_ReadReg(ROBUS_TIMER, CNT); // Compute remaining time before timeout diff --git a/network/robus_network/HAL/STM32G4/robus_hal.c b/network/robus_network/HAL/STM32G4/robus_hal.c index 8ff8e7fec..a99270688 100644 --- a/network/robus_network/HAL/STM32G4/robus_hal.c +++ b/network/robus_network/HAL/STM32G4/robus_hal.c @@ -390,6 +390,11 @@ static void RobusHAL_TimeoutInit(void) ******************************************************************************/ _CRITICAL void RobusHAL_ResetTimeout(uint16_t nbrbit) { + /* TODO: optimize further by getting rid of the need to reach for the ARR value. + The same result can be achieved by only setting the start value of the counter and letting it count down toward 0. + An IRQ can then be generated when reaching 0. This way diff = counter_value. + */ + uint32_t arr_val, diff; arr_val = LL_TIM_ReadReg(ROBUS_TIMER, ARR); // Get actual timeout value diff = arr_val-LL_TIM_ReadReg(ROBUS_TIMER, CNT); // Compute remaining time before timeout diff --git a/network/robus_network/HAL/STM32L0/robus_hal.c b/network/robus_network/HAL/STM32L0/robus_hal.c index 6c946d076..5d9f7a2de 100644 --- a/network/robus_network/HAL/STM32L0/robus_hal.c +++ b/network/robus_network/HAL/STM32L0/robus_hal.c @@ -388,6 +388,11 @@ static void RobusHAL_TimeoutInit(void) ******************************************************************************/ _CRITICAL void RobusHAL_ResetTimeout(uint16_t nbrbit) { + /* TODO: optimize further by getting rid of the need to reach for the ARR value. + The same result can be achieved by only setting the start value of the counter and letting it count down toward 0. + An IRQ can then be generated when reaching 0. This way diff = counter_value. + */ + uint32_t arr_val, diff; arr_val = LL_TIM_ReadReg(ROBUS_TIMER, ARR); // Get actual timeout value diff = arr_val-LL_TIM_ReadReg(ROBUS_TIMER, CNT); // Compute remaining time before timeout diff --git a/network/robus_network/HAL/STM32L4/robus_hal.c b/network/robus_network/HAL/STM32L4/robus_hal.c index fbe673a3e..a06c9a333 100644 --- a/network/robus_network/HAL/STM32L4/robus_hal.c +++ b/network/robus_network/HAL/STM32L4/robus_hal.c @@ -390,6 +390,10 @@ static void RobusHAL_TimeoutInit(void) ******************************************************************************/ _CRITICAL void RobusHAL_ResetTimeout(uint16_t nbrbit) { + /* TODO: optimize further by getting rid of the need to reach for the ARR value. + The same result can be achieved by only setting the start value of the counter and letting it count down toward 0. + An IRQ can then be generated when reaching 0. This way diff = counter_value. + */ uint32_t arr_val, diff; arr_val = LL_TIM_ReadReg(ROBUS_TIMER, ARR); // Get actual timeout value diff = arr_val-LL_TIM_ReadReg(ROBUS_TIMER, CNT); // Compute remaining time before timeout