You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "davids5 (via GitHub)" <gi...@apache.org> on 2023/01/27 15:16:41 UTC

[GitHub] [nuttx] davids5 commented on a diff in pull request #8303: arch/arm/src/stm32f7/stm32_i2c.c: Round up stm32_i2c_toticks return v…

davids5 commented on code in PR #8303:
URL: https://github.com/apache/nuttx/pull/8303#discussion_r1089078075


##########
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:
   Why not be more deliberate. v != 0 ? v : 1 and not tie it to the other values.



##########
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:
   Why not be more deliberate. v != 0 ? v : 1 and not tie it to the other values?



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org