Skip to main content
Associate III
Jul 13, 2025 4:34 AM UTC
Solved

Configure a GPIO pin as EXTI

Hello, 

I am trying to build a api in stm32 cube ide with base mcu as nucleo board.i am planning to build a api with input parameters GPIO_PIN,IRQ_HANDLER_FUN.

UserAPI_exticf(GPIO_PIN,IRQ_HANDLER_FUNC)

{}

I don't want ot configure gpio as exti in .ioc file and use it main c

I want everythibg to be done in UserAPI_exticfg.

 

If you have such reference code or libraries please share it.

 

This topic has been closed for replies.
MM..1
MM..1Best answer
Super User
Jul 19, 2025 9:49 AM UTC

Andrew mean use click in some reply and mark as solved = no more reads this topic and try help

= more informative forum...

Then for example if you use in code my LL line mark my reply , we dont require see your code.

10 replies

MM..1
Super User
Jul 13, 2025 5:54 AM UTC
 LL_EXTI_SetEXTISource(LL_EXTI_EXTI_PORTB, LL_EXTI_EXTI_LINE11);
 LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_11);
 LL_EXTI_EnableFallingTrig_0_31(LL_EXTI_LINE_11);
 LL_EXTI_EnableIT_0_31(LL_EXTI_LINE_11);
 HAL_NVIC_SetPriority(EXTI11_IRQn, 5, 0);
 HAL_NVIC_EnableIRQ(EXTI11_IRQn);

some inspiration as you can see your func require port info too.

Andrew Neil
Super User
Jul 14, 2025 11:29 AM UTC

@MM..1 wrote:

 your func require port info too.


@Alex_reynold  Will also need the EXTIxxx_IRQn 

You haven't said what STM32 you're targetting, but there isn't a 1:1 relationship between Pin number and EXTI line

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Associate III
Jul 14, 2025 12:37 PM UTC

Dear @Andrew Neil ,

I am using a sensor which generate a interate upon anew event.

I am building api to fetch data from sensor upon reading interrupt.this avoids unnecessary polling.

You want to suggest like this??

UserAPI_exticf( GPIO_PORT, GPIO_PIN, IRQ_HANDLER_FUNC )
{

}

Edited to apply source code formatting - please see How to insert source code for future reference.