arch/arm/src/stm32f7/stm32_i2c.c: Round up stm32_i2c_toticks return value
When sending small number of bytes with larger CONFIG_USEC_PER_TICK this function should return at least 1. Solve this by rounding up the result. Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
parent
d96189ce26
commit
7d54d04613
@ -784,11 +784,12 @@ static uint32_t stm32_i2c_toticks(int msgc, struct i2c_msg_s *msgs)
|
|||||||
bytecount += msgs[i].length;
|
bytecount += msgs[i].length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then return a number of microseconds based on a user provided scaling
|
/* Then return a number of ticks based on a user provided scaling
|
||||||
* factor.
|
* factor, rounded up.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return USEC2TICK(CONFIG_STM32F7_I2C_DYNTIMEO_USECPERBYTE * bytecount);
|
return USEC2TICK(CONFIG_STM32F7_I2C_DYNTIMEO_USECPERBYTE * bytecount +
|
||||||
|
CONFIG_USEC_PER_TICK / 2 - 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user