瀏覽代碼

[bsp]: fix spi chipselect in Infineon (#7234)

1. compatible for HIGH ACTIVE SPI CHIP_SELECT
Lu_Reaper 2 年之前
父節點
當前提交
af914a1690
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      bsp/Infineon/libraries/HAL_Drivers/drv_spi.c

+ 8 - 1
bsp/Infineon/libraries/HAL_Drivers/drv_spi.c

@@ -180,7 +180,14 @@ static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *m
     /* take CS */
     if (message->cs_take && !(device->config.mode & RT_SPI_NO_CS) && (device->cs_pin != PIN_NONE))
     {
-        cyhal_gpio_write(device->cs_pin, PIN_LOW);
+        if (device->config.mode & RT_SPI_CS_HIGH)
+        {
+            cyhal_gpio_write(device->cs_pin, PIN_HIGH);
+        }
+        else
+        {
+            cyhal_gpio_write(device->cs_pin, PIN_LOW);
+        }
         LOG_D("spi take cs\n");
     }