mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/delete_i2c_cmd_mux_semaphore_more_cleanly' into 'master'
dreiver/i2c: delete i2c cmd_mux semaphore more cleanly Closes IDFGH-5062 See merge request espressif/esp-idf!13399
This commit is contained in:
commit
dd0c1c7d95
@ -401,7 +401,9 @@ esp_err_t i2c_driver_delete(i2c_port_t i2c_num)
|
|||||||
p_i2c->intr_handle = NULL;
|
p_i2c->intr_handle = NULL;
|
||||||
|
|
||||||
if (p_i2c->cmd_mux) {
|
if (p_i2c->cmd_mux) {
|
||||||
|
// Let any command in progress finish.
|
||||||
xSemaphoreTake(p_i2c->cmd_mux, portMAX_DELAY);
|
xSemaphoreTake(p_i2c->cmd_mux, portMAX_DELAY);
|
||||||
|
xSemaphoreGive(p_i2c->cmd_mux);
|
||||||
vSemaphoreDelete(p_i2c->cmd_mux);
|
vSemaphoreDelete(p_i2c->cmd_mux);
|
||||||
}
|
}
|
||||||
if (p_i2c_obj[i2c_num]->cmd_evt_queue) {
|
if (p_i2c_obj[i2c_num]->cmd_evt_queue) {
|
||||||
|
@ -97,6 +97,9 @@ esp_err_t i2c_driver_install(i2c_port_t i2c_num, i2c_mode_t mode, size_t slv_rx_
|
|||||||
/**
|
/**
|
||||||
* @brief I2C driver delete
|
* @brief I2C driver delete
|
||||||
*
|
*
|
||||||
|
* @note This function does not guarantee thread safety.
|
||||||
|
* Please make sure that no thread will continuously hold semaphores before calling the delete function.
|
||||||
|
*
|
||||||
* @param i2c_num I2C port number
|
* @param i2c_num I2C port number
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
|
@ -351,6 +351,7 @@ Delete Driver
|
|||||||
|
|
||||||
When the I2C communication is established with the function :cpp:func:`i2c_driver_install` and is not required for some substantial amount of time, the driver may be deinitialized to release allocated resources by calling :cpp:func:`i2c_driver_delete`.
|
When the I2C communication is established with the function :cpp:func:`i2c_driver_install` and is not required for some substantial amount of time, the driver may be deinitialized to release allocated resources by calling :cpp:func:`i2c_driver_delete`.
|
||||||
|
|
||||||
|
Before calling :cpp:func:`i2c_driver_delete` to remove i2c driver, please make sure that all threads have stopped using the driver in any way, because this function does not guarantee thread safety.
|
||||||
|
|
||||||
Application Example
|
Application Example
|
||||||
-------------------
|
-------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user