mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-28 16:14:20 +08:00
[spi] optimize the spi transfer speed.
If the configurations are the same, we don't need to set again.
This commit is contained in:
committed by
Man, Jianting (Meco)
parent
78ad327ff1
commit
8d6e536e88
@@ -94,11 +94,20 @@ rt_err_t rt_spi_configure(struct rt_spi_device *device,
|
|||||||
|
|
||||||
RT_ASSERT(device != RT_NULL);
|
RT_ASSERT(device != RT_NULL);
|
||||||
|
|
||||||
|
/* If the configurations are the same, we don't need to set again. */
|
||||||
|
if(device->config.data_width == cfg->data_width &&
|
||||||
|
device->config.mode == (cfg->mode & RT_SPI_MODE_MASK) &&
|
||||||
|
device->config.max_hz == cfg->max_hz)
|
||||||
|
{
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
/* set configuration */
|
/* set configuration */
|
||||||
device->config.data_width = cfg->data_width;
|
device->config.data_width = cfg->data_width;
|
||||||
device->config.mode = cfg->mode & RT_SPI_MODE_MASK ;
|
device->config.mode = cfg->mode & RT_SPI_MODE_MASK;
|
||||||
device->config.max_hz = cfg->max_hz ;
|
device->config.max_hz = cfg->max_hz;
|
||||||
|
|
||||||
|
/* reset the CS pin */
|
||||||
if (device->cs_pin != PIN_NONE)
|
if (device->cs_pin != PIN_NONE)
|
||||||
{
|
{
|
||||||
if (device->config.mode & RT_SPI_CS_HIGH)
|
if (device->config.mode & RT_SPI_CS_HIGH)
|
||||||
|
|||||||
Reference in New Issue
Block a user