risc-v/esp32c3: Make the semaphore timeout on I2C configurable
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
This commit is contained in:
parent
b33ccd01cf
commit
52cea558af
|
@ -375,6 +375,14 @@ config ESP32C3_I2C0_SDAPIN
|
||||||
|
|
||||||
endif # ESP32C3_I2C0
|
endif # ESP32C3_I2C0
|
||||||
|
|
||||||
|
config ESP32C3_I2CTIMEOSEC
|
||||||
|
int "Timeout seconds"
|
||||||
|
default 0
|
||||||
|
|
||||||
|
config ESP32C3_I2CTIMEOMS
|
||||||
|
int "Timeout milliseconds"
|
||||||
|
default 500
|
||||||
|
|
||||||
endmenu # I2C configuration
|
endmenu # I2C configuration
|
||||||
|
|
||||||
menu "SPI configuration"
|
menu "SPI configuration"
|
||||||
|
|
|
@ -799,8 +799,18 @@ static int esp32c3_i2c_sem_waitdone(struct esp32c3_i2c_priv_s *priv)
|
||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &abstime);
|
clock_gettime(CLOCK_REALTIME, &abstime);
|
||||||
|
|
||||||
abstime.tv_sec += 10;
|
#if CONFIG_ESP32C3_I2CTIMEOSEC > 0
|
||||||
abstime.tv_nsec += 0;
|
abstime.tv_sec += CONFIG_ESP32C3_I2CTIMEOSEC;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_ESP32C3_I2CTIMEOMS > 0
|
||||||
|
abstime.tv_nsec += CONFIG_ESP32C3_I2CTIMEOMS * NSEC_PER_MSEC;
|
||||||
|
if (abstime.tv_nsec >= 1000 * NSEC_PER_MSEC)
|
||||||
|
{
|
||||||
|
abstime.tv_sec++;
|
||||||
|
abstime.tv_nsec -= 1000 * NSEC_PER_MSEC;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
ret = nxsem_timedwait_uninterruptible(&priv->sem_isr, &abstime);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue