summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRbb666 <[email protected]>2023-03-29 18:48:01 +0800
committerguo <[email protected]>2023-03-29 20:35:39 +0800
commitb8988227d70c3b1595cd70ca615ef47a8b4b3d39 (patch)
tree065fc789368015d2051e62955d8167dbec42c597
parent9f38248f11f2678aed4f693ee567b2f0b129d9e8 (diff)
[Infineon]Fix spi cs problem
-rw-r--r--bsp/Infineon/libraries/HAL_Drivers/drv_spi.c20
-rw-r--r--bsp/Infineon/psoc6-evaluationkit-062S2/board/Kconfig8
2 files changed, 13 insertions, 15 deletions
diff --git a/bsp/Infineon/libraries/HAL_Drivers/drv_spi.c b/bsp/Infineon/libraries/HAL_Drivers/drv_spi.c
index 18e9403a58..cdd1cfa357 100644
--- a/bsp/Infineon/libraries/HAL_Drivers/drv_spi.c
+++ b/bsp/Infineon/libraries/HAL_Drivers/drv_spi.c
@@ -38,7 +38,7 @@ struct ifx_sw_spi_cs
#endif
static struct ifx_spi spi_bus_obj[] =
{
- #ifdef BSP_USING_SPI0
+ #if defined(BSP_USING_SPI0)
{
.bus_name = "spi0",
.spi_bus = &spi_bus0,
@@ -47,7 +47,7 @@ static struct ifx_spi spi_bus_obj[] =
.mosi_pin = GET_PIN(0, 2),
},
#endif
- #ifdef BSP_USING_SPI3
+ #if defined(BSP_USING_SPI3)
{
.bus_name = "spi3",
.spi_bus = &spi_bus3,
@@ -56,7 +56,7 @@ static struct ifx_spi spi_bus_obj[] =
.mosi_pin = GET_PIN(6, 0),
},
#endif
- #ifdef BSP_USING_SPI6
+ #if defined(BSP_USING_SPI6)
{
.bus_name = "spi6",
.spi_bus = &spi_bus6,
@@ -69,7 +69,7 @@ static struct ifx_spi spi_bus_obj[] =
/* private rt-thread spi ops function */
static rt_err_t spi_configure(struct rt_spi_device *device, struct rt_spi_configuration *configuration);
-static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *message);
+static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *message);
static struct rt_spi_ops ifx_spi_ops =
{
@@ -146,7 +146,7 @@ static rt_err_t spi_configure(struct rt_spi_device *device,
return RT_EOK;
}
-static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *message)
+static rt_ssize_t spixfer(struct rt_spi_device *device, struct rt_spi_message *message)
{
RT_ASSERT(device != NULL);
RT_ASSERT(message != NULL);
@@ -158,9 +158,9 @@ static rt_uint32_t spixfer(struct rt_spi_device *device, struct rt_spi_message *
struct ifx_sw_spi_cs *cs = device->parent.user_data;
/* take CS */
- if (message->cs_take)
+ if (message->cs_take && !(device->config.mode & RT_SPI_NO_CS) && (device->cs_pin != PIN_NONE))
{
- cyhal_gpio_write(cs->pin, PIN_LOW);
+ cyhal_gpio_write(device->cs_pin, PIN_LOW);
LOG_D("spi take cs\n");
}
@@ -185,12 +185,12 @@ 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))
+ if (message->cs_release && !(device->config.mode & RT_SPI_NO_CS) && (device->cs_pin != PIN_NONE))
{
if (device->config.mode & RT_SPI_CS_HIGH)
- cyhal_gpio_write(cs->pin, PIN_LOW);
+ cyhal_gpio_write(device->cs_pin, PIN_LOW);
else
- cyhal_gpio_write(cs->pin, PIN_HIGH);
+ cyhal_gpio_write(device->cs_pin, PIN_HIGH);
}
return message->length;
diff --git a/bsp/Infineon/psoc6-evaluationkit-062S2/board/Kconfig b/bsp/Infineon/psoc6-evaluationkit-062S2/board/Kconfig
index 42f1acfdcd..cb989c32c6 100644
--- a/bsp/Infineon/psoc6-evaluationkit-062S2/board/Kconfig
+++ b/bsp/Infineon/psoc6-evaluationkit-062S2/board/Kconfig
@@ -112,11 +112,6 @@ menu "On-chip Peripheral Drivers"
menuconfig BSP_USING_SPI0
bool "Enable SPI0 BUS"
default n
- if BSP_USING_SPI0
- config BSP_USING_SPI0_SAMPLE
- bool "Enable SPI0 BUS Sample"
- default n
- endif
menuconfig BSP_USING_SPI3
bool "Enable SPI3 BUS"
default n
@@ -125,6 +120,9 @@ menu "On-chip Peripheral Drivers"
bool "Enable SPI3 BUS Sample"
default n
endif
+ menuconfig BSP_USING_SPI6
+ bool "Enable SPI6 BUS"
+ default n
endif
menuconfig BSP_USING_ADC