[spi] rt_spi_configure 增加对cs_pin处理

This commit is contained in:
liYony 2023-02-23 08:28:38 +08:00 committed by Man, Jianting (Meco)
parent 1533b88390
commit b3b8c2362d
1 changed files with 8 additions and 0 deletions

View File

@ -95,6 +95,14 @@ rt_err_t rt_spi_configure(struct rt_spi_device *device,
device->config.mode = cfg->mode & RT_SPI_MODE_MASK ;
device->config.max_hz = cfg->max_hz ;
if (device->cs_pin != PIN_NONE)
{
if (device->config.mode & RT_SPI_CS_HIGH)
rt_pin_write(device->cs_pin, PIN_LOW);
else
rt_pin_write(device->cs_pin, PIN_HIGH);
}
if (device->bus != RT_NULL)
{
result = rt_mutex_take(&(device->bus->lock), RT_WAITING_FOREVER);