Skip to content

Commit

Permalink
add optimization description comment in RobusHAL_ResetTimeout() function
Browse files Browse the repository at this point in the history
  • Loading branch information
houkhouk committed May 23, 2024
1 parent 65aa38a commit aece26b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions network/robus_network/HAL/STM32F0/robus_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions network/robus_network/HAL/STM32F4/robus_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions network/robus_network/HAL/STM32G4/robus_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions network/robus_network/HAL/STM32L0/robus_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions network/robus_network/HAL/STM32L4/robus_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aece26b

Please sign in to comment.