diff options
| author | guo <[email protected]> | 2021-10-12 10:11:25 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-12 10:11:25 +0800 |
| commit | f5f944897e99467df429133816f3e406fec78239 (patch) | |
| tree | d6db1d85e9283cc58fa186c760695e984c3d60cf /bsp | |
| parent | 0f8c4653521f7f3491407f74aa677267e87872d0 (diff) | |
| parent | 93792b2c8493c262246de4407ba2ad1c66ef52c3 (diff) | |
Merge pull request #5143 from liukangcc/spi
Diffstat (limited to 'bsp')
| -rw-r--r-- | bsp/stm32/libraries/HAL_Drivers/drv_spi.c | 10 |
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..9b5dcc0885 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; |
