[En-Nut-Discussion] Problem with STM32 pin configuration

Ole Reinhardt ole.reinhardt at embedded-it.de
Tue Oct 6 00:53:27 CEST 2015


Hi Uwe,

there is a problem with your new pin configuration scheme, which you
committed a few days ago, which breaks several drivers.

The problem is, that the GCC preprocessor does not know anything about
types. But in several places, a preprocessor comparison like

#if (SPI_CS0 != PIN_NONE)

is used, where PIN_NONE is of the enum type nutgpio_t.

The above comparison is always true, as the preprocessor takes SPI_CS0
and PIN_NONE as identifiers, not as macros. These are then both replaced
by 0. So finally the comparison is always true.

This kind of preprocessor comparisons are at least used in

arch/cm3/dev/stm/stm32_spi.c
arch/cm3/dev/stm/stm32_emac.c

but perhaps ins several more.

See also https://gcc.gnu.org/onlinedocs/gcc-3.0.2/cpp_4.html#SEC38 for a
detailed explanation.


Could you please have a look at it? Unfortunately I do not have an idea
for an elegant solution.

Best regards,

Ole


-- 
kernel concepts GmbH            Tel: +49-271-771091-14
Sieghuetter Hauptweg 48         Mob: +49-177-7420433
D-57072 Siegen
http://www.embedded-it.de
http://www.kernelconcepts.de


More information about the En-Nut-Discussion mailing list