浏览代码

[spi] rt_spi_configure 增加对cs_pin处理

liYony 2 年之前
父节点
当前提交
b3b8c2362d
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      components/drivers/spi/spi_core.c

+ 8 - 0
components/drivers/spi/spi_core.c

@@ -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);