[FL-952] I2C: correctly handle STOP flags. Apps: increase cli_app stack size. (#408)
* I2C: correctly handle STOP flags. Apps: increase cli_app stack size. * API HAL Power: simplify api_hal_power_dump_state. Format sources.
This commit is contained in:
@@ -50,6 +50,9 @@ bool api_hal_i2c_tx(
|
||||
uint32_t time_left = timeout;
|
||||
bool ret = true;
|
||||
|
||||
while(LL_I2C_IsActiveFlag_BUSY(instance))
|
||||
;
|
||||
|
||||
LL_I2C_HandleTransfer(
|
||||
instance,
|
||||
address,
|
||||
@@ -58,9 +61,11 @@ bool api_hal_i2c_tx(
|
||||
LL_I2C_MODE_AUTOEND,
|
||||
LL_I2C_GENERATE_START_WRITE);
|
||||
|
||||
while(!LL_I2C_IsActiveFlag_STOP(instance)) {
|
||||
while(!LL_I2C_IsActiveFlag_STOP(instance) || size > 0) {
|
||||
if(LL_I2C_IsActiveFlag_TXIS(instance)) {
|
||||
LL_I2C_TransmitData8(instance, (*data++));
|
||||
LL_I2C_TransmitData8(instance, (*data));
|
||||
data++;
|
||||
size--;
|
||||
time_left = timeout;
|
||||
}
|
||||
|
||||
@@ -73,6 +78,7 @@ bool api_hal_i2c_tx(
|
||||
}
|
||||
|
||||
LL_I2C_ClearFlag_STOP(instance);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -85,6 +91,9 @@ bool api_hal_i2c_rx(
|
||||
uint32_t time_left = timeout;
|
||||
bool ret = true;
|
||||
|
||||
while(LL_I2C_IsActiveFlag_BUSY(instance))
|
||||
;
|
||||
|
||||
LL_I2C_HandleTransfer(
|
||||
instance,
|
||||
address,
|
||||
@@ -93,9 +102,11 @@ bool api_hal_i2c_rx(
|
||||
LL_I2C_MODE_AUTOEND,
|
||||
LL_I2C_GENERATE_START_READ);
|
||||
|
||||
while(!LL_I2C_IsActiveFlag_STOP(instance)) {
|
||||
while(!LL_I2C_IsActiveFlag_STOP(instance) || size > 0) {
|
||||
if(LL_I2C_IsActiveFlag_RXNE(instance)) {
|
||||
*data++ = LL_I2C_ReceiveData8(instance);
|
||||
*data = LL_I2C_ReceiveData8(instance);
|
||||
data++;
|
||||
size--;
|
||||
time_left = timeout;
|
||||
}
|
||||
|
||||
@@ -108,6 +119,7 @@ bool api_hal_i2c_rx(
|
||||
}
|
||||
|
||||
LL_I2C_ClearFlag_STOP(instance);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user