minor fix
This commit is contained in:
parent
fa9678812c
commit
f1c078c721
|
@ -99,10 +99,10 @@ bool i2c_master_read(uint8_t slave, const uint8_t* address, size_t address_size,
|
|||
// sanity check
|
||||
if (address==NULL || address_size==0 || data==NULL || data_size==0) { // input data is erroneous
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (I2C_SR2(I2C(I2C_MASTER_I2C)) & I2C_SR2_BUSY) { // I2C device is busy
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (I2C_SR2(I2C(I2C_MASTER_I2C)) & I2C_SR2_MSL) { // I2C device is already in master mode
|
||||
return false;
|
||||
}
|
||||
|
@ -201,9 +201,6 @@ bool i2c_master_read(uint8_t slave, const uint8_t* address, size_t address_size,
|
|||
to_return = true;
|
||||
|
||||
error:
|
||||
if (I2C_SR2(I2C(I2C_MASTER_I2C)) & I2C_SR2_BUSY) { // release bus if busy
|
||||
// i2c_send_stop(I2C(I2C_MASTER_I2C)); // send stop to release bus
|
||||
}
|
||||
i2c_send_stop(I2C(I2C_MASTER_I2C)); // send stop to release bus
|
||||
timer_set_counter(TIM(I2C_MASTER_TIMER),0); // restart timer
|
||||
timer_clear_flag(TIM(I2C_MASTER_TIMER), TIM_SR_UIF); // clear flag
|
||||
|
@ -221,10 +218,10 @@ bool i2c_master_write(uint8_t slave, const uint8_t* address, size_t address_size
|
|||
// sanity check
|
||||
if (address==NULL || address_size==0 || data==NULL || data_size==0) { // input data is erroneous
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (I2C_SR2(I2C(I2C_MASTER_I2C)) & I2C_SR2_BUSY) { // I2C device is busy
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (I2C_SR2(I2C(I2C_MASTER_I2C)) & I2C_SR2_MSL) { // I2C device is already in master mode
|
||||
return false;
|
||||
}
|
||||
|
@ -293,9 +290,7 @@ bool i2c_master_write(uint8_t slave, const uint8_t* address, size_t address_size
|
|||
to_return = true;
|
||||
|
||||
error:
|
||||
if (I2C_SR2(I2C(I2C_MASTER_I2C)) & I2C_SR2_BUSY) { // release bus if busy
|
||||
i2c_send_stop(I2C(I2C_MASTER_I2C)); // send stop to release bus
|
||||
}
|
||||
i2c_send_stop(I2C(I2C_MASTER_I2C)); // send stop to release bus
|
||||
timer_set_counter(TIM(I2C_MASTER_TIMER),0); // restart timer
|
||||
timer_clear_flag(TIM(I2C_MASTER_TIMER), TIM_SR_UIF); // clear flag
|
||||
timer_enable_counter(TIM(I2C_MASTER_TIMER)); // enable timer for timeouts
|
||||
|
|
Loading…
Reference in New Issue