jlaitine commented on code in PR #8303:
URL: https://github.com/apache/nuttx/pull/8303#discussion_r1089117000
##########
arch/arm/src/stm32f7/stm32_i2c.c:
##########
@@ -784,11 +784,13 @@ static uint32_t stm32_i2c_toticks(int msgc, struct
i2c_msg_s *msgs)
bytecount += msgs[i].length;
}
- /* Then return a number of microseconds based on a user provided scaling
- * factor.
+ /* Then return a number of ticks based on a user provided scaling
+ * factor, rounded up.
*/
- return USEC2TICK(CONFIG_STM32F7_I2C_DYNTIMEO_USECPERBYTE * bytecount);
+ return USEC2TICK(CONFIG_STM32F7_I2C_DYNTIMEO_USECPERBYTE * bytecount +
Review Comment:
That makes quite large error, imagine calculation result being e.g. 1.9; it
would be rounded down to 1. As this is a timeout value it is better to always
round up. Of course, a simple + 1 for ticks would work, I am not sure if I was
just making it too exact in rounding up and made it look complex ?
For runtime the apparent complexity doesn't matter, it is calculated by
preprocessor. And I think the equation is correct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]