summaryrefslogtreecommitdiff
path: root/bsp/stm32
diff options
context:
space:
mode:
authorliukangcc <[email protected]>2021-10-11 17:12:42 +0800
committerliukangcc <[email protected]>2021-10-11 17:13:33 +0800
commit3c32e0168d1ebbac5d6e5749eaf804fc268dd460 (patch)
tree97b883f021a9e6ec1e45d8f962a40f91537b53d7 /bsp/stm32
parent24f2ce62ba471fc5a24db0f9af8dd99a59aa5adf (diff)
[drv_spi.c] 修复 stm32 drv_spi.c文件中的 spixfer 未实现片选为高电平的 spi 设备
Diffstat (limited to 'bsp/stm32')
-rw-r--r--bsp/stm32/libraries/HAL_Drivers/drv_spi.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_spi.c b/bsp/stm32/libraries/HAL_Drivers/drv_spi.c
index 4e98218c90..4cbf4cf194 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_spi.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_spi.c
@@ -293,7 +293,10 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
if (message->cs_take && !(device->config.mode & RT_SPI_NO_CS))
{
- HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_RESET);
+ if(device->config.mode & RT_SPI_CS_HIGH)
+ HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_SET);
+ else
+ HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_RESET);
}
LOG_D("%s transfer prepare and start", spi_drv->config->bus_name);
@@ -387,7 +390,10 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
if (message->cs_release && !(device->config.mode & RT_SPI_NO_CS))
{
- HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_SET);
+ if(device->config.mode & RT_SPI_CS_HIGH)
+ HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_RESET);
+ else
+ HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_SET);
}
return message->length;