Skip to content

Commit 460af2e

Browse files
Fix I2C Slave Compile (#6108)
I2C Slave currently doesn't compile for projects where Arduino is an IDF component. This adds missing conditionals. Co-authored-by: Me No Dev <[email protected]>
1 parent 48a722a commit 460af2e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: cores/esp32/esp32-hal-i2c-slave.c

+4
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,12 @@ esp_err_t i2cSlaveDeinit(uint8_t num){
360360
}
361361

362362
i2c_slave_struct_t * i2c = &_i2c_bus_array[num];
363+
#if !CONFIG_DISABLE_HAL_LOCKS
363364
if(!i2c->lock){
364365
log_e("Lock is not initialized! Did you call i2c_slave_init()?");
365366
return ESP_ERR_NO_MEM;
366367
}
368+
#endif
367369
I2C_SLAVE_MUTEX_LOCK();
368370
i2c_slave_free_resources(i2c);
369371
I2C_SLAVE_MUTEX_UNLOCK();
@@ -377,10 +379,12 @@ size_t i2cSlaveWrite(uint8_t num, const uint8_t *buf, uint32_t len, uint32_t tim
377379
}
378380
size_t to_queue = 0, to_fifo = 0;
379381
i2c_slave_struct_t * i2c = &_i2c_bus_array[num];
382+
#if !CONFIG_DISABLE_HAL_LOCKS
380383
if(!i2c->lock){
381384
log_e("Lock is not initialized! Did you call i2c_slave_init()?");
382385
return ESP_ERR_NO_MEM;
383386
}
387+
#endif
384388
if(!i2c->tx_queue){
385389
return 0;
386390
}

0 commit comments

Comments
 (0)