Ddereferencing type-punned pointer, unused parameter, pin undeclared

Hi,

I am still at the low end of the learning curve :frowning:

I am trying to use the TM_SPI modules, but Yotta is upset

I just copied this source file .c & .h into my source directory.
Should I install the full library set with Yotta install or pip ?

3 different types of issues:

“dereferencing type-punned pointer will break strict-aliasing rules”
C:/workspace/Blinky3/source/tm_stm32_spi.c: In function ‘TM_SPI_WriteMulti’:
C:/workspace/Blinky3/source/tm_stm32_spi.c:269:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
(void)*(__IO uint16_t *)&SPIx->DR;

“unused parameter”
C:/workspace/Blinky3/source/tm_stm32_spi.c: In function ‘TM_SPI_InitCustomPinsCallback’:
C:/workspace/Blinky3/source/tm_stm32_spi.c:352:56: warning: unused parameter ‘SPIx’ [-Wunused-parameter]
__weak void TM_SPI_InitCustomPinsCallback(SPI_TypeDef* SPIx, uint16_t AlternateFunction) {

" ‘GPIO_AFx_SPI1’ undeclared "
C:/workspace/Blinky3/source/tm_stm32_spi.c: In function ‘TM_SPI1_INT_InitPins’:
C:/workspace/Blinky3/source/tm_stm32_spi.c:486:129: error: ‘GPIO_AFx_SPI1’ undeclared (first use in this function)
TM_GPIO_InitAlternate(GPIOA, GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7, TM_GPIO_OType_PP, TM_GPIO_PuPd_NOPULL, TM_GPIO_Speed_High, GPIO_AFx_SPI1);

How can I address these issues without modifying the original TX_SPI files ?

Hi,

I fixed the errors, but not the warnings

now I have 2 defines …

define SDRAM_USE_STM32F429_DISCOVERY
define STM32F4xx

But the warnings still appear.

“dereferencing type-punned pointer”
(workspace) C:\workspace\Blinky3>yotta build
info: generate for target: stm32f429i-disco-gcc 0.0.20 at C:\workspace\Blinky3\yotta_targets\stm32f429i-disco-gcc
warning: subdirectory “test” of blinky3 0.0.0 at C:\workspace\Blinky3 was ignored because it doesn’t appear to contain any source files
GCC version is: 4.9.3
suppressing warnings from mbed-hal-st-stm32cubef4
– Configuring done
– Generating done
– Build files have been written to: C:/workspace/Blinky3/build/stm32f429i-disco-gcc
[7/8] Building C object source/CMakeFiles/blinky3.dir/C_/workspace/Blinky3/source/tm_stm32_spi.c.o
C:/workspace/Blinky3/source/tm_stm32_spi.c: In function ‘TM_SPI_WriteMulti’:
C:/workspace/Blinky3/source/tm_stm32_spi.c:269:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
(void)*(__IO uint16_t *)&SPIx->DR;

" unused parameter"
C:/workspace/Blinky3/source/tm_stm32_spi.c: In function ‘TM_SPI_InitCustomPinsCallback’:
C:/workspace/Blinky3/source/tm_stm32_spi.c:352:56: warning: unused parameter ‘SPIx’ [-Wunused-parameter]
__weak void TM_SPI_InitCustomPinsCallback(SPI_TypeDef* SPIx, uint16_t AlternateFunction) {
^

I would like to understand these issues and the fix…