Page 1 of 1
How to use the EXTI driver
Posted: Sat May 03, 2025 9:39 am
by blackberryer
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?
Re: How to use the EXTI driver
Posted: Sat May 03, 2025 10:55 am
by blackberryer
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?
Re: How to use the EXTI driver
Posted: Sat May 03, 2025 3:11 pm
by blackberryer
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
Re: How to use the EXTI driver
Posted: Sat May 03, 2025 3:15 pm
by Giovanni
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
Re: How to use the EXTI driver
Posted: Sun May 04, 2025 12:04 pm
by blackberryer
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
Re: How to use the EXTI driver
Posted: Sun May 04, 2025 5:40 pm
by Giovanni
PAL events are based on EXTI so they have the same limitations.
Giovanni