Changes to the EXT 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.
User avatar
Badger
Posts: 346
Joined: Mon Apr 18, 2011 6:07 pm

Re: Changes to the EXT driver

Post by Badger »

Hi Giovanni,

fair points, I'm just trying to present functionality that would be useful to me, and maybe others.

This is not portable, those parameters apply to the STM32 only

I think that is about as portable as the PAL parameters, with the exception of mode, but mode could be abstracted to chibios types such as RISING, FALLING, BOTH, NONE. The structure wouldn't even need to be defined in the driver, there could just be a new function which takes a non const EXTConfig pointer and modifies the structure (ignoring any possible pin conflicts as you've mentioned, that will have to be something the user checks) and enables the channel.

The background for this request is that I am putting together a driver for the RFM22B/Si4432 chip which is an RF module including an interrupt pin which is proving quite difficult to package 'nicely' as a self contained driver. So I want the driver to have input params that define the port/pin that the interrupt should use. The alternative is to directly include the function in the EXTConfig for the application, but I think there will be problems with doing this in flash as the callback will be static and defined in an external file?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Changes to the EXT driver

Post by Giovanni »

PAL is limited at handling GPIO, this is not the case with EXT which also have to handle dedicated pins or internal event sources.

About your driver, you could put a reference to the EXT driver into your driver configuration then program the pin from inside your driver (to make it general make also the ext channel/GPIO configurable).

If you make the EXTConfig structure non const then the callback and the mode can be changed using the new API, the EXTConfig structure does not need to be initialized at all (zero filled).

Giovanni
User avatar
levrik
Posts: 26
Joined: Wed Dec 21, 2011 7:35 am

Re: Changes to the EXT driver

Post by levrik »

There seems to be a bug in the formula to calculate the port-map for SYSCFG->EXTICR:
ext_lld.c, line 582:
Working code:

Code: Select all

    uint32_t port = ((extp->config->channels[channel].mode &
                      EXT_MODE_GPIO_MASK) >>
                     EXT_MODE_GPIO_OFF) << ((channel & 3) * 4);

Current trunk-code.

Code: Select all

    uint32_t port = ((extp->config->channels[channel].mode &
                      EXT_MODE_GPIO_MASK) >>
                     EXT_MODE_GPIO_OFF) << (channel & 3);

Please notice the * 4.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Changes to the EXT driver

Post by Giovanni »

Fixed, thanks for finding.

Giovanni
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Changes to the EXT driver

Post by barthess »

Probalble bug on line 581 in ext_lld.c

Code: Select all

uint32_t mask = ~(0xF << (channel & 3));

must be

Code: Select all

uint32_t mask = ~(0xF << ((channel & 3) * 4));
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Changes to the EXT driver

Post by Giovanni »

You are right, thanks, apparently the previous fix was not sufficient, there was another instance of wrong shift.

Giovanni
Post Reply