OS : ChibiOS-21.11.3
MCU : STM32F405VGT6
I noticed that this article(viewtopic.php?f=36&t=3355) has a discussion about EXTI, see you mentioned the palLineEnableEvent function, but I didn't find this function in the ChibiOS-21.11.3 version,
I found the extiEnableGroup1 & extiEnableLine in EXTIv1.c:
1.Among them I did not find the settings for the SYSCFG_EXTICRx registers
2.It doesn't have a callback, how can I call a callback?
I don't see such a routine in the demo either.
In addition, I will use PA3, PC0~5, PE1, so that there will be the same lines, PA3 and PC3, PC1 and PE1 trigger the interrupt vector is the same, can the program distinguish it?
How to use the EXTI driver
-
blackberryer
- Posts: 24
- Joined: Sat Apr 05, 2025 6:52 pm
- Been thanked: 4 times
-
blackberryer
- Posts: 24
- Joined: Sat Apr 05, 2025 6:52 pm
- Been thanked: 4 times
Re: How to use the EXTI driver
oh,i see,i found palEnableLineEvent & palSetLineCallback.
palSetLineCallbackSet the parameters of the callback,
What can this parameter contain? I guess this parameter can be used to distinguish between PC1 and PE1?
palSetLineCallbackSet the parameters of the callback,
What can this parameter contain? I guess this parameter can be used to distinguish between PC1 and PE1?
-
blackberryer
- Posts: 24
- Joined: Sat Apr 05, 2025 6:52 pm
- Been thanked: 4 times
Re: How to use the EXTI driver
Code: Select all
/* init */
palEnableLineEvent(PAL_LINE(GPIOC, GPIOC_PUSH), PAL_EVENT_MODE_BOTH_EDGES);
palSetLineCallback(PAL_LINE(GPIOC, GPIOC_PUSH), handle_button_ext, NULL);
palEnableLineEvent(PAL_LINE(GPIOA, GPIOA_CTP_IRQ), PAL_EVENT_MODE_FALLING_EDGE);
palSetLineCallback(PAL_LINE(GPIOA, GPIOA_CTP_IRQ), handle_button_ext, NULL);
palEnableLineEvent(PAL_LINE(GPIOA, GPIOA_SD_DET), PAL_EVENT_MODE_BOTH_EDGES);
palSetLineCallback(PAL_LINE(GPIOA, GPIOA_SD_DET), handle_button_ext, NULL);Code: Select all
static void handle_button_ext(void *arg) {
(void)arg;
if (palReadLine(PAL_LINE(GPIOC, GPIOC_PUSH)) == 0) {
palTogglePad(GPIOC, GPIOC_LED1);
}
if (palReadLine(PAL_LINE(GPIOA, GPIOA_CTP_IRQ)) == 0) {
palTogglePad(GPIOC, GPIOC_LED2);
}
if (palReadLine(PAL_LINE(GPIOA, GPIOA_SD_DET)) == 0) {
palTogglePad(GPIOC, GPIOC_LED3);
}
}Is the above code correct? I wrote it with reference to the program in the multi folder, but when I actually ran it, I found that the interrupt triggered all the GPIOA_SD_DET
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: How to use the EXTI driver
On STM32 there are constraints on EXTI mapping on GPIOs, each bit in a port can only be mapped to a single GPIO. For example, you cannot use GPIOA[4] and GPIOB[4] together.
Please read the STM32 RM if you plan to use EXTI, it is a tricky limitation.
Giovanni
Please read the STM32 RM if you plan to use EXTI, it is a tricky limitation.
Giovanni
-
blackberryer
- Posts: 24
- Joined: Sat Apr 05, 2025 6:52 pm
- Been thanked: 4 times
Re: How to use the EXTI driver
Giovanni wrote:On STM32 there are constraints on EXTI mapping on GPIOs, each bit in a port can only be mapped to a single GPIO. For example, you cannot use GPIOA[4] and GPIOB[4] together.
Please read the STM32 RM if you plan to use EXTI, it is a tricky limitation.
Giovanni
So can I use PAL events instead? As I asked, I see that PAL has an interrupt-like feature
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: How to use the EXTI driver
PAL events are based on EXTI so they have the same limitations.
Giovanni
Giovanni