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
Laurent MEUNIER 2016-12-01 14:47:44 +01:00
parent 0505a5274d
commit 29b32b84b3
1 changed files with 2 additions and 2 deletions

View File

@ -296,8 +296,6 @@ void i2c_frequency(i2c_t *obj, int hz)
struct i2c_s *obj_s = I2C_S(obj);
I2C_HandleTypeDef *handle = &(obj_s->handle);
MBED_ASSERT((hz > 0) && (hz <= 400000));
// wait before init
timeout = BYTE_TIMEOUT;
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;
#endif
#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);
// Enable the Fast Mode Plus capability