I've found a macro expansion bug in the SPI driver while porting my application to ChibiOS 18.2.x. While using spiSelectI I got the following compiler error:
Code: Select all
/disk/greb/src/ChibiOS/os/hal/include/hal_spi.h:160:20: error: invalid type argument of '->' (have 'SPIDriver {aka struct SPIDriver}')
palClearLine(spip->config->ssline); \
^
/disk/greb/src/ChibiOS/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h:381:74: note: in definition of macro 'pal_lld_clearport'
#define pal_lld_clearport(port, bits) ((port)->BSRR.H.clear = (uint16_t)(bits))
^
/disk/grep/src/ChibiOS/os/hal/include/hal_pal.h:626:32: note: in expansion of macro 'palClearPort'
#define palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad))
^
/disk/grep/src/ChibiOS/os/hal/include/hal_pal.h:626:51: note: in expansion of macro 'PAL_PORT_BIT'
#define palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad))
^
/disk/grep/src/ChibiOS/os/hal/include/hal_pal.h:741:28: note: in expansion of macro 'palClearPad'
#define palClearLine(line) palClearPad(PAL_PORT(line), PAL_PAD(line))
^
/disk/grep/src/ChibiOS/os/hal/include/hal_pal.h:741:56: note: in expansion of macro 'PAL_PAD'
#define palClearLine(line) palClearPad(PAL_PORT(line), PAL_PAD(line))
^
/disk/greb/src/ChibiOS/os/hal/include/hal_spi.h:160:3: note: in expansion of macro 'palClearLine'
palClearLine(spip->config->ssline); \
^
cl.c:115:5: note: in expansion of macro 'spiSelectI'
spiSelectI(&SPID1);
I recommend putting the macro parameter spip in parantheses to avoid expansion problems.
Best regards,
greb