From e3f3484ea4a0afc9e1c418d52a0148cab32453c8 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 22 Oct 2021 09:51:41 +0000 Subject: [PATCH] Few fixes, SPI v2 enabled on STM32G4xx experimentally. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14937 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/hal/include/hal_spi_v2.h | 2 +- os/hal/ports/STM32/STM32G4xx/hal_lld.h | 5 +++++ os/hal/ports/STM32/STM32G4xx/platform.mk | 2 +- os/hal/src/hal_spi_v2.inc | 2 +- testhal/STM32/multi/SPI/cfg/stm32g474re_nucleo64/portab.c | 6 +++--- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/os/hal/include/hal_spi_v2.h b/os/hal/include/hal_spi_v2.h index df12b0f38..22834dae3 100644 --- a/os/hal/include/hal_spi_v2.h +++ b/os/hal/include/hal_spi_v2.h @@ -91,7 +91,7 @@ * @note Disabling this option saves both code and data space. */ #if !defined(SPI_SELECT_MODE) || defined(__DOXYGEN__) -#define SPI_SELECT_MODE SPI_SELECT_MODE_LINE +#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD #endif /** @} */ diff --git a/os/hal/ports/STM32/STM32G4xx/hal_lld.h b/os/hal/ports/STM32/STM32G4xx/hal_lld.h index c71468101..8326eaf19 100644 --- a/os/hal/ports/STM32/STM32G4xx/hal_lld.h +++ b/os/hal/ports/STM32/STM32G4xx/hal_lld.h @@ -45,6 +45,11 @@ /* Driver constants. */ /*===========================================================================*/ +/** + * @brief Requires use of SPIv2 driver model. + */ +#define HAL_LLD_SELECT_SPI_V2 TRUE + /** * @name Platform identification * @{ diff --git a/os/hal/ports/STM32/STM32G4xx/platform.mk b/os/hal/ports/STM32/STM32G4xx/platform.mk index f25ef89b4..93b13e2c0 100644 --- a/os/hal/ports/STM32/STM32G4xx/platform.mk +++ b/os/hal/ports/STM32/STM32G4xx/platform.mk @@ -36,7 +36,7 @@ include $(CHIBIOS)/os/hal/ports/STM32/LLD/QUADSPIv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/RCCv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/RTCv3/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/RNGv1/driver.mk -include $(CHIBIOS)/os/hal/ports/STM32/LLD/SPIv2/driver.mk +include $(CHIBIOS)/os/hal/ports/STM32/LLD/SPIv2/driver_v2.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/SYSTICKv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/TIMv1/driver.mk include $(CHIBIOS)/os/hal/ports/STM32/LLD/USARTv3/driver.mk diff --git a/os/hal/src/hal_spi_v2.inc b/os/hal/src/hal_spi_v2.inc index 7277e9480..415a3c976 100644 --- a/os/hal/src/hal_spi_v2.inc +++ b/os/hal/src/hal_spi_v2.inc @@ -606,7 +606,7 @@ msg_t spiExchange(SPIDriver *spip, size_t n, osalSysLock(); msg = spiStartExchangeI(spip, n, txbuf, rxbuf); - if (msg != MSG_OK) { + if (msg == MSG_OK) { msg = spiSynchronizeS(spip, TIME_INFINITE); } diff --git a/testhal/STM32/multi/SPI/cfg/stm32g474re_nucleo64/portab.c b/testhal/STM32/multi/SPI/cfg/stm32g474re_nucleo64/portab.c index a0fe5ba69..c95c2571c 100644 --- a/testhal/STM32/multi/SPI/cfg/stm32g474re_nucleo64/portab.c +++ b/testhal/STM32/multi/SPI/cfg/stm32g474re_nucleo64/portab.c @@ -38,7 +38,7 @@ void spi_circular_cb(SPIDriver *spip); void spi_error_cb(SPIDriver *spip); /* - * Circular SPI configuration (21MHz, CPHA=0, CPOL=0, MSb first). + * Circular SPI configuration (42.5MHz, CPHA=0, CPOL=0, MSb first). */ const SPIConfig c_spicfg = { .circular = true, @@ -54,7 +54,7 @@ const SPIConfig c_spicfg = { }; /* - * Maximum speed SPI configuration (21MHz, CPHA=0, CPOL=0, MSb first). + * Maximum speed SPI configuration (42.5MHz, CPHA=0, CPOL=0, MSb first). */ const SPIConfig hs_spicfg = { .circular = true, @@ -70,7 +70,7 @@ const SPIConfig hs_spicfg = { }; /* - * Low speed SPI configuration (328.125kHz, CPHA=0, CPOL=0, MSb first). + * Low speed SPI configuration (664,062kHz, CPHA=0, CPOL=0, MSb first). */ const SPIConfig ls_spicfg = { .circular = true,