mirror of https://github.com/ARMmbed/mbed-os.git
STM32 I2C - 1MHZ frequency is allowed
So make the assert to cover all possible values Also assert applies only for I2C_IP_VERSION_V2. Also in case of I2C_IP_VERSION_V1, the HAL makes the proper checks and can dynamically scale the frequency in case of intermediate value.pull/3324/head
parent
0505a5274d
commit
29b32b84b3
|
@ -296,8 +296,6 @@ void i2c_frequency(i2c_t *obj, int hz)
|
||||||
struct i2c_s *obj_s = I2C_S(obj);
|
struct i2c_s *obj_s = I2C_S(obj);
|
||||||
I2C_HandleTypeDef *handle = &(obj_s->handle);
|
I2C_HandleTypeDef *handle = &(obj_s->handle);
|
||||||
|
|
||||||
MBED_ASSERT((hz > 0) && (hz <= 400000));
|
|
||||||
|
|
||||||
// wait before init
|
// wait before init
|
||||||
timeout = BYTE_TIMEOUT;
|
timeout = BYTE_TIMEOUT;
|
||||||
while ((__HAL_I2C_GET_FLAG(handle, I2C_FLAG_BUSY)) && (--timeout != 0));
|
while ((__HAL_I2C_GET_FLAG(handle, I2C_FLAG_BUSY)) && (--timeout != 0));
|
||||||
|
@ -307,6 +305,8 @@ void i2c_frequency(i2c_t *obj, int hz)
|
||||||
handle->Init.DutyCycle = I2C_DUTYCYCLE_2;
|
handle->Init.DutyCycle = I2C_DUTYCYCLE_2;
|
||||||
#endif
|
#endif
|
||||||
#ifdef I2C_IP_VERSION_V2
|
#ifdef I2C_IP_VERSION_V2
|
||||||
|
/* Only predefined timing for below frequencies are supported */
|
||||||
|
MBED_ASSERT((hz == 100000) || (hz == 400000) || (hz == 1000000));
|
||||||
handle->Init.Timing = get_i2c_timing(hz);
|
handle->Init.Timing = get_i2c_timing(hz);
|
||||||
|
|
||||||
// Enable the Fast Mode Plus capability
|
// Enable the Fast Mode Plus capability
|
||||||
|
|
Loading…
Reference in New Issue