@@ -332,34 +332,35 @@ bool TwoWire::begin(int sdaPin, int sclPin, uint32_t frequency)
332
332
333
333
}
334
334
335
- void TwoWire::end ()
335
+ bool TwoWire::end ()
336
336
{
337
+ esp_err_t err = ESP_OK;
337
338
#if !CONFIG_DISABLE_HAL_LOCKS
338
339
if (lock != NULL ){
339
340
// acquire lock
340
341
if (xSemaphoreTake (lock, portMAX_DELAY) != pdTRUE){
341
342
log_e (" could not acquire lock" );
342
- return ;
343
+ return false ;
343
344
}
344
345
#endif
345
346
#if SOC_I2C_SUPPORT_SLAVE
346
347
if (is_slave){
347
- esp_err_t err = i2cSlaveDeinit (num);
348
+ err = i2cSlaveDeinit (num);
348
349
if (err == ESP_OK){
349
350
is_slave = false ;
350
351
}
351
352
} else
352
353
#endif /* SOC_I2C_SUPPORT_SLAVE */
353
354
if (i2cIsInit (num)){
354
- i2cDeinit (num);
355
+ err = i2cDeinit (num);
355
356
}
356
357
freeWireBuffer ();
357
358
#if !CONFIG_DISABLE_HAL_LOCKS
358
359
// release lock
359
360
xSemaphoreGive (lock);
360
361
}
361
362
#endif
362
- return ;
363
+ return (err == ESP_OK) ;
363
364
}
364
365
365
366
uint32_t TwoWire::getClock ()
@@ -389,25 +390,28 @@ uint32_t TwoWire::getClock()
389
390
390
391
void TwoWire::setClock (uint32_t frequency)
391
392
{
393
+ esp_err_t err = ESP_OK;
392
394
#if !CONFIG_DISABLE_HAL_LOCKS
393
395
// acquire lock
394
396
if (lock == NULL || xSemaphoreTake (lock, portMAX_DELAY) != pdTRUE){
395
397
log_e (" could not acquire lock" );
396
- return ;
398
+ return false ;
397
399
}
398
400
#endif
399
401
#if SOC_I2C_SUPPORT_SLAVE
400
402
if (is_slave){
401
403
log_e (" Bus is in Slave Mode" );
404
+ err = ESP_FAIL;
402
405
} else
403
406
#endif /* SOC_I2C_SUPPORT_SLAVE */
404
407
{
405
- i2cSetClock (num, frequency);
408
+ err = i2cSetClock (num, frequency);
406
409
}
407
410
#if !CONFIG_DISABLE_HAL_LOCKS
408
411
// release lock
409
412
xSemaphoreGive (lock);
410
413
#endif
414
+ return (err == ESP_OK);
411
415
}
412
416
413
417
void TwoWire::setTimeOut (uint16_t timeOutMillis)
0 commit comments