Skip to content

Commit f5f9448

Browse files
authored
Merge pull request #5143 from liukangcc/spi
2 parents 0f8c465 + 93792b2 commit f5f9448

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

bsp/stm32/libraries/HAL_Drivers/drv_spi.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
293293

294294
if (message->cs_take && !(device->config.mode & RT_SPI_NO_CS))
295295
{
296-
HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_RESET);
296+
if (device->config.mode & RT_SPI_CS_HIGH)
297+
HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_SET);
298+
else
299+
HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_RESET);
297300
}
298301

299302
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 *
387390

388391
if (message->cs_release && !(device->config.mode & RT_SPI_NO_CS))
389392
{
390-
HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_SET);
393+
if (device->config.mode & RT_SPI_CS_HIGH)
394+
HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_RESET);
395+
else
396+
HAL_GPIO_WritePin(cs->GPIOx, cs->GPIO_Pin, GPIO_PIN_SET);
391397
}
392398

393399
return message->length;

0 commit comments

Comments
 (0)