Adding an argument to PAL event callbacks Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
austin_boulderes
Posts: 10
Joined: Wed Nov 05, 2014 9:38 pm
Has thanked: 1 time
Been thanked: 1 time

Adding an argument to PAL event callbacks  Topic is solved

Postby austin_boulderes » Wed Apr 12, 2017 12:20 am

I was excited to see that the PAL driver is getting events -- this seems like it'll be a much better way to handle sharing of interrupt resources between modules than the EXT driver.

As someone who'd like to have his cake and eat it too, however, I'd love to see palcallback_t be modified to have a generic pointer argument. Something like:

Code: Select all

typedef void (*palcallback_t)(void *);


with the event enable function then defined to be:

Code: Select all

#if !defined(pal_lld_enablepadevent) || defined(__DOXYGEN__)
#define palPadEnableEventI(port, pad, mode, callback, arg)
#else
#define palPadEnableEventI(port, pad, mode, callback, arg)                       \
  pal_lld_enablepadevent(port, pad, mode, callback, arg)
#endif


I've found this pattern greatly increases code reusability, and avoids forcing the use of file- or project-global variables. The cost (as far as I understand it) should be fairly low -- just an extra pointer saved alongside the callback itself.

I figured this would be a good time to make the request, since PAL event handling is still in its infancy.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Adding an argument to PAL event callbacks

Postby Giovanni » Wed Apr 12, 2017 7:49 am

Hi,

Moving this in "bug reports" so it will not be lost, probably this will happen during next development cycle, currently I am just bug fixing before next release.

Giovanni

User avatar
alex31
Posts: 379
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 38 times
Been thanked: 62 times
Contact:

Re: Adding an argument to PAL event callbacks

Postby alex31 » Wed Apr 12, 2017 12:42 pm

hello, i remember having asked for a user param in the callback years ago (for the EXTI module at the time: second question of old post), and i can confirm that this would be nice !

Alexandre -- nearly 5 years using ChibiOS, and still happy with it :-)

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Adding an argument to PAL event callbacks

Postby Giovanni » Wed Apr 12, 2017 1:35 pm

I am glad to hear that :)

Anyway, this is matter of next dev cycle, I will make a list of all things that should become part of HAL 6 at some point, there are several.

Giovanni

austin_boulderes
Posts: 10
Joined: Wed Nov 05, 2014 9:38 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Adding an argument to PAL event callbacks

Postby austin_boulderes » Wed Apr 12, 2017 3:30 pm

Great, I'm glad to see it!

josesimoes
Posts: 91
Joined: Sat Feb 18, 2017 11:50 am
Has thanked: 43 times
Been thanked: 23 times

Re: Adding an argument to PAL event callbacks

Postby josesimoes » Thu Aug 17, 2017 6:43 pm

+1 for having a parameter on the callback!
That is most useful for a lot of use cases.

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Adding an argument to PAL event callbacks

Postby Giovanni » Tue Aug 29, 2017 9:53 am

Hi,

Change implemented in repository trunk.

Giovanni

User avatar
FXCoder
Posts: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: Adding an argument to PAL event callbacks

Postby FXCoder » Sat Sep 02, 2017 4:52 am

Hi Giovanni,
Are you planning to make the PAL event system conditionally enabled?
I'm asking because the implementation in trunk so far takes over the EXT IRQ handler definitions unconditionally.
This causes a linker conflict with any user code implemented IRQ handler.

I've defined handlers in stm32_isr.c with __attribute__((weak)) as a temporary workaround only.

Thanks,

Bob

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Adding an argument to PAL event callbacks

Postby Giovanni » Sat Sep 02, 2017 7:35 am

Hi,

The idea is to remove EXT after the work is complete on PAL in HAL 6. EXT has always been an eyesore of a driver.

Giovanni

User avatar
FXCoder
Posts: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Re: Adding an argument to PAL event callbacks

Postby FXCoder » Sat Sep 02, 2017 8:07 am

OK. Understood that EXT will be deprecated (it did the job but was a little quirky).

However, sometimes a custom coded fast interrupt handler for EXTI (i.e. without the IRQ handler PROLOGUE/EPILOGUE) might be needed.
So then a means of implementing an IRQ handler which directly replaces the PAL event IRQ handler would be required.

Does that make sense?

Thanks,

Bob


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 33 guests