Skip to content

Commit 4fcc03c

Browse files
committed
feat:[drivers][spi] rt_spi_bus_configure 添加 -RT_EBUSY 返回值,并增加说明注释
1 parent ff6d5b1 commit 4fcc03c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

components/drivers/include/drivers/dev_spi.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ rt_err_t rt_spi_bus_attach_device_cspin(struct rt_spi_device *device,
184184
rt_base_t cs_pin,
185185
void *user_data);
186186

187-
/* re-configure SPI bus */
187+
/**
188+
* @brief This function can re-configure SPI bus.
189+
* @param device: the SPI device attached to SPI bus
190+
* @retval RT_EOK on release SPI device successfully.
191+
* RT_EBUSY is not an error condition and the configuration will take effect once the device has the bus
192+
* others on taken SPI bus failed.
193+
*/
188194
rt_err_t rt_spi_bus_configure(struct rt_spi_device *device);
189195

190196
/**
@@ -223,7 +229,14 @@ rt_err_t rt_spi_take(struct rt_spi_device *device);
223229
*/
224230
rt_err_t rt_spi_release(struct rt_spi_device *device);
225231

226-
/* set configuration on SPI device */
232+
/**
233+
* @brief This function can set configuration on SPI device.
234+
* @param device: the SPI device attached to SPI bus
235+
* @param cfg: the configuration pointer.
236+
* @retval RT_EOK on release SPI device successfully.
237+
* RT_EBUSY is not an error condition and the configuration will take effect once the device has the bus
238+
* others on taken SPI bus failed.
239+
*/
227240
rt_err_t rt_spi_configure(struct rt_spi_device *device,
228241
struct rt_spi_configuration *cfg);
229242

components/drivers/spi/dev_spi_core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ rt_err_t rt_spi_bus_configure(struct rt_spi_device *device)
106106
LOG_E("SPI device %s configuration failed", device->parent.parent.name);
107107
}
108108
}
109+
else
110+
{
111+
/* RT_EBUSY is not an error condition and
112+
* the configuration will take effect once the device has the bus
113+
*/
114+
return -RT_EBUSY;
115+
}
109116

110117
/* release lock */
111118
rt_mutex_release(&(device->bus->lock));

0 commit comments

Comments
 (0)