[INFO] Enhancements to the PAL driver

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
Post Reply
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

[INFO] Enhancements to the PAL driver

Post by Giovanni »

It is the oldest driver and also the one that received least changes over the years.

I just introduced the new concept of "line", A line is a combo of port and pin, this simplifies the API a lot, for example instead of writing:

palSetPad(GPIOA, GPIOA_LED_GREEN);

Now it is possible to write:

palSetLine(LINE_LED_GREEN);

The advantages are:
- Easier to use API.
- Identifiers not bound to specific ports, this makes code a lot more portable.

The new functions are: palWriteLine(), palReadLine(), palSetLine(), palClearLine(), palToggleLine(), palSetLineMode(). Those are all macros so there is no code size increase, the old API is still available.
I modified the GPIOv1 and GPIOv2 drivers. Platforms with not updated drivers will give an error when trying one of the new macros but will work unmodified otherwise.

The boards generator now generates macros for both "Pad" and "Line" functions, it now generates both GPIOA_LED_GREEN and LINE_LED_GREEN.

I only updated the F7 boards/demos, others will be done gradually.

Giovanni
Jacon
Posts: 143
Joined: Wed Dec 08, 2010 7:52 am
Has thanked: 50 times
Been thanked: 5 times

Re: [INFO] Enhancements to the PAL driver

Post by Jacon »

Great, and very much welcomed idea, Giovanni :D
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: [INFO] Enhancements to the PAL driver

Post by Tectu »

I like where this is going. Nice work!


~ Tectu
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: [INFO] Enhancements to the PAL driver

Post by Giovanni »

Change to the boards generator, now it is possible to make aliases of pins (giving them multiple names) by simply separating identifiers with a space in the .chcfg.

It will be included in next ChibiStudio and also be available as installable plugin on the update site.

Giovanni
a.giacomolli
Posts: 3
Joined: Wed Aug 29, 2012 7:21 pm

Re: [INFO] Enhancements to the PAL driver

Post by a.giacomolli »

Hi

In the function palWriteLine, pin needs to be line.

Anderson
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: [INFO] Enhancements to the PAL driver

Post by Giovanni »

Hi,

Thanks, fixed.

Giovanni
Post Reply