@@ -200,7 +200,7 @@ class I2cClass {
200
200
return begin ((i2cInitStruct_.I2CMaster == I2C_MASTER_MODE) ? I2C_MODE_MASTER : I2C_MODE_SLAVE, i2cInitStruct_.I2CAckAddr );
201
201
}
202
202
203
- void reset () {
203
+ uint8_t reset () {
204
204
end ();
205
205
206
206
// Just in case make sure that the pins are correctly configured (they should anyway be at this point)
@@ -214,9 +214,8 @@ class I2cClass {
214
214
hal_gpio_configure (sdaPin_, &conf, nullptr );
215
215
216
216
// Check if slave is stretching the SCL
217
- if (!WAIT_TIMED (transConfig_.timeout_ms , hal_gpio_read (sclPin_) == 0 )) {
218
- // We can't proceed because there is probably hardware issue.
219
- SPARK_ASSERT (false );
217
+ if (!WAIT_TIMED (HAL_I2C_DEFAULT_TIMEOUT_MS, hal_gpio_read (sclPin_) == 0 )) {
218
+ return 1 ;
220
219
}
221
220
222
221
// Generate up to 9 pulses on SCL to tell slave to release the bus
@@ -246,6 +245,7 @@ class I2cClass {
246
245
247
246
hal_i2c_mode_t mode = (i2cInitStruct_.I2CMaster == I2C_MASTER_MODE) ? I2C_MODE_MASTER : I2C_MODE_SLAVE;
248
247
begin (mode, i2cInitStruct_.I2CAckAddr );
248
+ return !isEnabled (); // 0 for success, to be consistent with other Gen3 platforms
249
249
}
250
250
251
251
int setSpeed (uint32_t speed) {
@@ -733,8 +733,7 @@ void hal_i2c_enable_dma_mode(hal_i2c_interface_t i2c, bool enable, void* reserve
733
733
uint8_t hal_i2c_reset (hal_i2c_interface_t i2c, uint32_t reserved, void * reserved1) {
734
734
auto instance = CHECK_TRUE_RETURN (I2cClass::getInstance (i2c), 1 );
735
735
I2cLock lk (instance);
736
- instance->reset ();
737
- return 0 ;
736
+ return instance->reset ();
738
737
}
739
738
740
739
int32_t hal_i2c_lock (hal_i2c_interface_t i2c, void * reserved) {
0 commit comments