GPIOv1/v2 PAL #defines

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
Hildy
Posts: 8
Joined: Wed May 01, 2013 12:55 pm

GPIOv1/v2 PAL #defines

Post by Hildy »

I was getting the FSMC driver from ChibiOS/GFX to work on a Hy-MINI STM32V and while I got the demos going (see http://imgur.com/5VGJBef) I ran into a couple of roadblocks along the way, mainly to do with the PAL differences:

I took SSD1289/gdisp_lld_board_example_fsmc.h and modified it
- what is meant to define STM32F1XX? I ended up defining it in my board.h but I'm not sure of the right place for it to go
- the original code has

palSetBusMode(&busD, PAL_MODE_ALTERNATE(12));
palSetBusMode(&busE, PAL_MODE_ALTERNATE(12));

but for GPIOv1, I needed

palSetBusMode(&busD, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
palSetBusMode(&busE, PAL_MODE_STM32_ALTERNATE_PUSHPULL);

I'm not sure what the accepted way of writing things that are portable across the two GPIO interfaces is.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: GPIOv1/v2 PAL #defines

Post by Giovanni »

Hi,

GPIOv1 and GPIOv2 have very different features so there is no commonality except for a subset of the modes (not alternate modes anyway).

GPIOv1 is limited to STM32F1 devices, all newer families use GPIOv2.

In general would be a good idea to keep GPIO configuration out of high level modules and confine it to board.h or the initial setup performed in the main().

Giovanni
trunet
Posts: 54
Joined: Fri Apr 06, 2012 7:18 pm

Re: GPIOv1/v2 PAL #defines

Post by trunet »

sorry to resurrect the thread.

are you successfully made ugfx works on Hy-MINI STM32V? could you share your code?

Thanks,

Wagner
silart
Posts: 1
Joined: Wed Mar 30, 2016 12:28 pm

Re: GPIOv1/v2 PAL #defines

Post by silart »

Hello!
How to choose v2 version of HAL?
I use stm32F107 and this code is not build:

Code: Select all

   palSetPadMode(GPIOD, 5, PAL_MODE_ALTERNATE(7));
   palSetPadMode(GPIOD, 6, PAL_MODE_ALTERNATE(7));
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: GPIOv1/v2 PAL #defines

Post by Giovanni »

Hi,

STM32F1 is not compatible with all others.

PAL_MODE_ALTERNATE(n) is only available on newer devices. You need to initialize pins using the F1-specific macros (look into ./os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h).

Giovanni
Post Reply