You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2026/10/25 20:09:25 UTC
(mynewt-core) branch master updated: hw/mcu/stm/stm32_common: Remove HAL_SPI_Init copy for STM32L1
This is an automated email from the ASF dual-hosted git repository.
kasjer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 070e80f3b hw/mcu/stm/stm32_common: Remove HAL_SPI_Init copy for STM32L1
070e80f3b is described below
commit 070e80f3b08d777057df004b44f5d518ca6071a4
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Sun Oct 25 15:49:52 2026 +0100
hw/mcu/stm/stm32_common: Remove HAL_SPI_Init copy for STM32L1
stm32_driver_mod_spi.c had a copy of HAL_SPI_Init() for STM32L152xC.
Comment says it was copied from stm32l1xx_hal_spi_ex.c to override weak
symbol from stm32l1xx_hal_spi.c that did not link correctly. Current
STM32L1 HAL has no stm32l1xx_hal_spi_ex.c and HAL_SPI_Init() is not
weak, so the copy only duplicates the HAL function.
If weak implementation from library was linked instead of the strong
one, pkg.whole_archive: true in pkg.yml is meant for this kind of
situation. With pkg.whole_archive set for stm32_common the copy causes
multiple definition error.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jerzy Kasenberg <je...@apache.org>
---
hw/mcu/stm/stm32_common/src/stm32_driver_mod_spi.c | 69 ----------------------
1 file changed, 69 deletions(-)
diff --git a/hw/mcu/stm/stm32_common/src/stm32_driver_mod_spi.c b/hw/mcu/stm/stm32_common/src/stm32_driver_mod_spi.c
index 156d44f97..20342df4b 100644
--- a/hw/mcu/stm/stm32_common/src/stm32_driver_mod_spi.c
+++ b/hw/mcu/stm/stm32_common/src/stm32_driver_mod_spi.c
@@ -59,75 +59,6 @@ HAL_StatusTypeDef HAL_SPI_QueueTransmit(SPI_HandleTypeDef *hspi, uint8_t *pData,
#define TXDR DR
#endif
-/* XXX: This is copied from stm32l1xx_hal_spi_ex.c because it is a __weak
- * symbol defined in stm32l1xx_hal_spi.c that is overriden but due to our
- * archive process seems to not link correctly. Copying here enables the
- * linker to find the correct non-weak symbol.
- */
-#if defined(STM32L152xC)
-#include "stm32l1xx_hal.h"
-
-HAL_StatusTypeDef HAL_SPI_Init(SPI_HandleTypeDef *hspi)
-{
- /* Check the SPI handle allocation */
- if (hspi == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_SPI_ALL_INSTANCE(hspi->Instance));
- assert_param(IS_SPI_MODE(hspi->Init.Mode));
- assert_param(IS_SPI_DATASIZE(hspi->Init.DataSize));
- assert_param(IS_SPI_CPOL(hspi->Init.CLKPolarity));
- assert_param(IS_SPI_CPHA(hspi->Init.CLKPhase));
- assert_param(IS_SPI_NSS(hspi->Init.NSS));
- assert_param(IS_SPI_BAUDRATE_PRESCALER(hspi->Init.BaudRatePrescaler));
- assert_param(IS_SPI_FIRST_BIT(hspi->Init.FirstBit));
-
- hspi->Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
- hspi->Init.CRCPolynomial = 1;
-
- if (hspi->State == HAL_SPI_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- hspi->Lock = HAL_UNLOCKED;
-
- /* Init the low level hardware : GPIO, CLOCK, NVIC... */
- HAL_SPI_MspInit(hspi);
- }
-
- hspi->State = HAL_SPI_STATE_BUSY;
-
- /* Disble the selected SPI peripheral */
- __HAL_SPI_DISABLE(hspi);
-
- /*----------------------- SPIx CR1 & CR2 Configuration ---------------------*/
- /* Configure : SPI Mode, Communication Mode, Data size, Clock polarity and phase, NSS management,
- Communication speed, First bit and CRC calculation state */
- hspi->Instance->CR1 = (hspi->Init.Mode | hspi->Init.Direction | hspi->Init.DataSize |
- hspi->Init.CLKPolarity | hspi->Init.CLKPhase | (hspi->Init.NSS & SPI_CR1_SSM) |
- hspi->Init.BaudRatePrescaler | hspi->Init.FirstBit | hspi->Init.CRCCalculation);
-
- /* Configure : NSS management */
- hspi->Instance->CR2 = (((hspi->Init.NSS >> 16U) & SPI_CR2_SSOE) | hspi->Init.TIMode);
-
- /*---------------------------- SPIx CRCPOLY Configuration ------------------*/
- /* Configure : CRC Polynomial */
- hspi->Instance->CRCPR = hspi->Init.CRCPolynomial;
-
-#if defined(SPI_I2SCFGR_I2SMOD)
- /* Activate the SPI mode (Make sure that I2SMOD bit in I2SCFGR register is reset) */
- CLEAR_BIT(hspi->Instance->I2SCFGR, SPI_I2SCFGR_I2SMOD);
-#endif
-
- hspi->ErrorCode = HAL_SPI_ERROR_NONE;
- hspi->State = HAL_SPI_STATE_READY;
-
- return HAL_OK;
-}
-#endif
-
#if (!(MYNEWT_VAL(MCU_STM32H7) || defined(STM32U5) || defined(STM32H5)) || !SPI_HAS_FIFO)
static HAL_StatusTypeDef
SPI_WaitFlagStateUntilTimeout(SPI_HandleTypeDef *hspi, uint32_t Flag, uint32_t State, uint32_t Timeout, uint32_t Tickstart)