1.优化代码。
This commit is contained in:
@@ -190,15 +190,12 @@ static mr_err_t mr_i2c_device_ioctl(mr_device_t device, int cmd, void *args)
|
||||
|
||||
if (config->host_slave != i2c_device->config.host_slave)
|
||||
{
|
||||
if (config->host_slave == MR_I2C_HOST)
|
||||
if (i2c_device->bus != MR_NULL)
|
||||
{
|
||||
if (i2c_device->bus != MR_NULL)
|
||||
if (config->host_slave == MR_I2C_HOST)
|
||||
{
|
||||
mr_i2c_device_release_bus(i2c_device);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (i2c_device->bus != MR_NULL)
|
||||
} else
|
||||
{
|
||||
/* Slave mode monopolizes the bus */
|
||||
ret = mr_i2c_device_take_bus(i2c_device);
|
||||
|
||||
10
device/spi.c
10
device/spi.c
@@ -381,15 +381,13 @@ static mr_err_t mr_spi_device_ioctl(mr_device_t device, int cmd, void *args)
|
||||
|
||||
if (config->host_slave != spi_device->config.host_slave)
|
||||
{
|
||||
if (config->host_slave == MR_SPI_HOST)
|
||||
if (spi_device->bus != MR_NULL)
|
||||
{
|
||||
if (spi_device->bus != MR_NULL)
|
||||
if (config->host_slave == MR_SPI_HOST)
|
||||
{
|
||||
mr_spi_device_release_bus(spi_device);
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (spi_device->bus != MR_NULL)
|
||||
|
||||
} else
|
||||
{
|
||||
/* Slave mode monopolizes the bus */
|
||||
ret = mr_spi_device_take_bus(spi_device);
|
||||
|
||||
Reference in New Issue
Block a user