Ahh makes sense, thanks for the clear answer and right to the point.
After I found the problem, I read in many places of people having the same problem and it was fixed with the extern C. I didn't try a C code yet, but I tried many different codes. I am actually writing to the registers directly now, so I don't think the problem can be elsewhere. But I will check again, with some example code.
That is what I am doing exactly, the code is just for testing so it is not in its best shape :
//MCU : STM32L151
//The user will pass pin and port enumeration that I created. On my turn I will enable the corresponding Interrupt.
// The user will also pass an Edge for the interrupt.
RCC->APB2ENR |= (1ul << 0); // Enable SYSCFG clock
SYSCFG->EXTICR[registerIndex] &= ~(15ul << 4* (pinIndex %4)); //pinIndex is an enumaration on Pins I created
SYSCFG->EXTICR[registerIndex] |= (portIndex << 4* (pinIndex %4));
EXTI->IMR |= (1ul << pinIndex);
switch(edgeLevel)
{
case FALLING_EDGE:
EXTI->RTSR |= (1ul << pinIndex);
break;
case RISING_EDGE:
EXTI->FTSR |= (1ul << pinIndex);
break;
case BOTH_EDGES:
EXTI->RTSR |= (1ul << pinIndex);
EXTI->FTSR |= (1ul << pinIndex);
break;
}
if(pinIndex == 0)
{
NVIC_SetPriority(EXTI0_IRQn,priority);
NVIC_EnableIRQ(EXTI0_IRQn);
}
else if (pinIndex ==1)
{
NVIC_SetPriority(EXTI1_IRQn,priority);
NVIC_EnableIRQ(EXTI1_IRQn);
}
else if(pinIndex ==2)
{
NVIC_SetPriority(EXTI2_IRQn,priority);
NVIC_EnableIRQ(EXTI2_IRQn);
}
else if(pinIndex ==3)
{
NVIC_SetPriority(EXTI3_IRQn,priority);
NVIC_EnableIRQ(EXTI3_IRQn);
}
else if(pinIndex ==4)
{
NVIC_SetPriority(EXTI4_IRQn,priority);
NVIC_EnableIRQ(EXTI4_IRQn);
}
else if(pinIndex >4 && pinIndex <=9 )
{
NVIC_SetPriority(EXTI9_5_IRQn,priority);
NVIC_EnableIRQ(EXTI9_5_IRQn);
}
else if(pinIndex >9 && pinIndex <=15 )
{
NVIC_SetPriority(EXTI15_10_IRQn,priority);
NVIC_EnableIRQ(EXTI15_10_IRQn);
}
Here are the enumerations, nothing special:
typedef enum PINn
{
PIN0,
PIN1,
PIN2,
PIN3,
PIN4,
PIN5,
PIN6,
PIN7,
PIN8,
PIN9,
PIN10,
PIN11,
PIN12,
PIN13,
PIN14,
PIN15,
}PINn_Type;
typedef enum PORTn
{
PORTA,
PORTB,
PORTC,
PORTD,
PORTE
}PORTn_Type;