Page 1 of 1

Error when porting due to the difference in pal_lld_setport between GPIOv1 and GPIOv2

Posted: Thu Apr 20, 2017 4:02 am
by s03311251
I'm new in ChibiOS but I have to work on a project that has to port a program for STM32F103 to STM32F072:
https://github.com/gaudat/chinkboard-ads1256

The version of ChibiOS I'm using is pulled from https://github.com/ChibiOS/ChibiOS a week ago.

It gives error like this:

Code: Select all

In file included from ../ChibiOS/os/hal/include/hal_pal.h:129:0,
                 from ../ChibiOS/os/hal/include/hal.h:124,
                 from ./modules/load_cell/scale.c:10:
./modules/load_cell/scale.c: In function 'updateLed':
../ChibiOS/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h:484:50: error: request for member 'H' in something not a structure or union
 #define pal_lld_setport(port, bits) ((port)->BSRR.H.set = (uint16_t)(bits))
                                                  ^
../ChibiOS/os/hal/include/hal_pal.h:286:32: note: in expansion of macro 'pal_lld_setport'
 #define palSetPort(port, bits) pal_lld_setport(port, bits)
                                ^
../ChibiOS/os/hal/include/hal_pal.h:454:30: note: in expansion of macro 'palSetPort'
 #define palSetPad(port, pad) palSetPort(port, PAL_PORT_BIT(pad))
                              ^
./modules/load_cell/scale.c:160:9: note: in expansion of macro 'palSetPad'
         palSetPad(LED_PORT,LED_R);
         ^
../ChibiOS/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h:496:52: error: request for member 'H' in something not a structure or union
 #define pal_lld_clearport(port, bits) ((port)->BSRR.H.clear = (uint16_t)(bits))
                                                    ^
../ChibiOS/os/hal/include/hal_pal.h:306:34: note: in expansion of macro 'pal_lld_clearport'
 #define palClearPort(port, bits) pal_lld_clearport(port, bits)
                                  ^
../ChibiOS/os/hal/include/hal_pal.h:473:32: note: in expansion of macro 'palClearPort'
 #define palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad))
                                ^
./modules/load_cell/scale.c:162:9: note: in expansion of macro 'palClearPad'
         palClearPad(LED_PORT,LED_R);
         ^
../ChibiOS/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h:484:50: error: request for member 'H' in something not a structure or union
 #define pal_lld_setport(port, bits) ((port)->BSRR.H.set = (uint16_t)(bits))
                                                  ^
../ChibiOS/os/hal/include/hal_pal.h:286:32: note: in expansion of macro 'pal_lld_setport'
 #define palSetPort(port, bits) pal_lld_setport(port, bits)
                                ^
../ChibiOS/os/hal/include/hal_pal.h:454:30: note: in expansion of macro 'palSetPort'
 #define palSetPad(port, pad) palSetPort(port, PAL_PORT_BIT(pad))
                              ^
./modules/load_cell/scale.c:165:9: note: in expansion of macro 'palSetPad'
         palSetPad(LED_PORT,LED_G);
         ^
../ChibiOS/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h:496:52: error: request for member 'H' in something not a structure or union
 #define pal_lld_clearport(port, bits) ((port)->BSRR.H.clear = (uint16_t)(bits))
                                                    ^
../ChibiOS/os/hal/include/hal_pal.h:306:34: note: in expansion of macro 'pal_lld_clearport'
 #define palClearPort(port, bits) pal_lld_clearport(port, bits)
                                  ^
../ChibiOS/os/hal/include/hal_pal.h:473:32: note: in expansion of macro 'palClearPort'
 #define palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad))
                                ^
./modules/load_cell/scale.c:167:9: note: in expansion of macro 'palClearPad'
         palClearPad(LED_PORT,LED_G);
         ^
../ChibiOS/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h:484:50: error: request for member 'H' in something not a structure or union
 #define pal_lld_setport(port, bits) ((port)->BSRR.H.set = (uint16_t)(bits))
                                                  ^
../ChibiOS/os/hal/include/hal_pal.h:286:32: note: in expansion of macro 'pal_lld_setport'
 #define palSetPort(port, bits) pal_lld_setport(port, bits)
                                ^
../ChibiOS/os/hal/include/hal_pal.h:454:30: note: in expansion of macro 'palSetPort'
 #define palSetPad(port, pad) palSetPort(port, PAL_PORT_BIT(pad))
                              ^
./modules/load_cell/scale.c:170:9: note: in expansion of macro 'palSetPad'
         palSetPad(LED_PORT,LED_B);
         ^
../ChibiOS/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h:496:52: error: request for member 'H' in something not a structure or union
 #define pal_lld_clearport(port, bits) ((port)->BSRR.H.clear = (uint16_t)(bits))
                                                    ^
../ChibiOS/os/hal/include/hal_pal.h:306:34: note: in expansion of macro 'pal_lld_clearport'
 #define palClearPort(port, bits) pal_lld_clearport(port, bits)
                                  ^
../ChibiOS/os/hal/include/hal_pal.h:473:32: note: in expansion of macro 'palClearPort'
 #define palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad))
                                ^
./modules/load_cell/scale.c:172:9: note: in expansion of macro 'palClearPad'
         palClearPad(LED_PORT,LED_B);
         ^


As pal_lld_setport is for internal use, I don't know whether it is appropriate to change the code.

I know STM32F1xx uses GPIOv1 and STM32F0xx uses GPIOv2, but I don't know what is the difference that caused the problem. :? Also, are there any articles that talk about the difference between GPIOv1 and GPIOv2?

Thank you.

Re: Error when porting due to the difference in pal_lld_setport between GPIOv1 and GPIOv2

Posted: Thu Apr 20, 2017 7:29 am
by Giovanni
Hi,

Board files are different between v1 and v2, differences are caused by differences in hardware so the explanation is in the STM32 Reference Manuals, see GPIO chapters.

You need to use "v2" board files.

Giovanni

Re: Error when porting due to the difference in pal_lld_setport between GPIOv1 and GPIOv2

Posted: Thu Apr 20, 2017 5:42 pm
by s03311251
Thank you for your help.

The problem has been figured out. Somewhere in the code,

Code: Select all

...
static GPIO_TypeDef* BUTTON_PORT = GPIOB;
...
palReadPad(BUTTON_PORT,ZERO_BUTTON)
...


It works fine after changing it to:

Code: Select all

...
#define BUTTON_PORT GPIOB
...
palReadPad(BUTTON_PORT,ZERO_BUTTON)
...