You will not have to wait for long, it is done and it is ridiculously simple, SVN revision 3309.
There is also the STM32 implementation and a test application but it is not tested yet, I will do that in the evening.
Giovanni
Interrupt support on PAL module
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Interrupt support on PAL module
May be better to place this defines in relevant hal_lld_XXXX.h
Code: Select all
#if defined(STM32F10X_CL) || defined(__DOXYGEN__)
#define EXT_MAX_CHANNELS 20
#elif defined(STM32F2XX)
#define EXT_MAX_CHANNELS 23
#else
#define EXT_MAX_CHANNELS 19
#endif- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Interrupt support on PAL module
I considered it but EXT_MAX_CHANNELS is referred from the common part of the configuration structure, it is EXT-generic not STM32-specific.
Giovanni
Giovanni
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Interrupt support on PAL module
Is there way to enable/disable channels on the fly except of direct modifying EXTICRx registers?
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Interrupt support on PAL module
Not yet, currently it is completely statically defined. I'll add a couple functions to enable/disable channels on the fly.
Giovanni
Giovanni
Re: Interrupt support on PAL module
Honestly, I do not understand the structure of the driver.
The way it is, there can only be one application (thread) use interrupts simultaneously (using extStart). This makes sense for drivers as SPI or Serial, where a device is used by an application for a certain time. Afterwards the driver is "freed" again and available for other applications.
I think for external interrupts, you have to face the same challenges as for the PAL module. There can be several applications which use a group of pads simultaneously. Even in that case the applications could "start" the pal driver when it uses the pins and stop it afterwards.
The problem with interrupts is (for most use cases) that the applications don't know, when an interrupt occurs (this is exactly the meaning of interrupts. Otherwise one could simply poll the channels). Thus, it has to start the driver in the beginning and leave it running. But then, there is no way for other programs to configure their interrupts (on other pins).
Because of that, I think the EXT driver has to look rather similar to the PAL driver. For the same reason there is no need for a stateful ext driver using states as active, stop, etc.
Correct me, if I'm wrong.
Regards,
Florian
The way it is, there can only be one application (thread) use interrupts simultaneously (using extStart). This makes sense for drivers as SPI or Serial, where a device is used by an application for a certain time. Afterwards the driver is "freed" again and available for other applications.
I think for external interrupts, you have to face the same challenges as for the PAL module. There can be several applications which use a group of pads simultaneously. Even in that case the applications could "start" the pal driver when it uses the pins and stop it afterwards.
The problem with interrupts is (for most use cases) that the applications don't know, when an interrupt occurs (this is exactly the meaning of interrupts. Otherwise one could simply poll the channels). Thus, it has to start the driver in the beginning and leave it running. But then, there is no way for other programs to configure their interrupts (on other pins).
Because of that, I think the EXT driver has to look rather similar to the PAL driver. For the same reason there is no need for a stateful ext driver using states as active, stop, etc.
Correct me, if I'm wrong.
Regards,
Florian
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Interrupt support on PAL module
You need a way to associate callbacks to the EXT channels, the PAL driver cannot provide that functionality.
The function extStart() mainly associates a set of callbacks to the EXT driver and perform any MCU-related initialization (in the STM32 it associates the EXT channels to physical pins, unlike the SAM7 the association is dynamic there, not all pins can have interrupts). BTW there are not multiple "applications", once started the driver is active globally regardless the thread that started it.
After starting the EXT driver the application can handle the single pins using the PAL driver or the extChannelEnable() / extChannelDisable() functions (added yesterday).
I think the scenario is not much different for the SAM7.
extStart() associates the configuration (callbacks array) and enables the PIO interrupt globally.
extStop() disables the PIO interrupt generation globally.
extChannelEnable() enables the interrupt for the specified channel (independently from the PAL mode, you can enable the interrupt on input and output pads).
extChannelDisable() disables the interrupt for the specified channel.
If the above scenario is not convincing please go ahead and suggest a different one.
Giovanni
The function extStart() mainly associates a set of callbacks to the EXT driver and perform any MCU-related initialization (in the STM32 it associates the EXT channels to physical pins, unlike the SAM7 the association is dynamic there, not all pins can have interrupts). BTW there are not multiple "applications", once started the driver is active globally regardless the thread that started it.
After starting the EXT driver the application can handle the single pins using the PAL driver or the extChannelEnable() / extChannelDisable() functions (added yesterday).
I think the scenario is not much different for the SAM7.
extStart() associates the configuration (callbacks array) and enables the PIO interrupt globally.
extStop() disables the PIO interrupt generation globally.
extChannelEnable() enables the interrupt for the specified channel (independently from the PAL mode, you can enable the interrupt on input and output pads).
extChannelDisable() disables the interrupt for the specified channel.
If the above scenario is not convincing please go ahead and suggest a different one.
Giovanni
Re: Interrupt support on PAL module
ah ok, I think now I got how the lld-driver is supposed to work. I will have a look at the current version. Thank you!
Re: Interrupt support on PAL module
Hi,
after a few days, I had a bit time to finish the ext_lld driver for the sam7.
I had to change some things from the perspective of the STM32:
The rest is mostly the same as for the STM32.
As I am still integrating our software into the OS I could not test the module yet. Shall I send the two files (ext_lld.c, ext_lld.h) to you via e-mail so you can have a look on them?
Regards,
Florian
after a few days, I had a bit time to finish the ext_lld driver for the sam7.
I had to change some things from the perspective of the STM32:
- Interrupt modes cannot be applied to a channel but only to a whole port (32 channels) on the SAM7, so I introduced a "mode" field in the config struct.
- The high-level driver requires the channels struct to have a mode field, too. Hence, I removed the different edge type defines for channels (using #undef) and introduced EXT_CH_MODE_ENABLED in the LLD driver. So one can chose if a channel is enabled or disabled using that mode field.
- For the two GPIO ports of the sam7, I introduced two drivers EXTDA and EXTDB (the ports names are PIOA and PIOB in the datasheet), that can be used independently.
The rest is mostly the same as for the STM32.
As I am still integrating our software into the OS I could not test the module yet. Shall I send the two files (ext_lld.c, ext_lld.h) to you via e-mail so you can have a look on them?
Regards,
Florian