I'm a 16 yr old self learned hobbyist. I've been banging my head for the last 5 days unable to get the exti part working. Now, I'm gonna come clear, I've twiddled with registers and am using the low level functions and not the wirish library, and for some reason, my code doesn't work...
Board: Maple mini
Here's the code:
#include <libmaple/gpio.h>
#include <libmaple/exti.h>
#include <libmaple/rcc.h>
#include <libmaple/libmaple.h>
//GVars---------------------------------------
volatile int s = 0;
//Functions-----------------------------------
void intHandler();
int main(void){
RCC_BASE->APB2ENR |= (1 << 3);
//Enabling the clock for PORTB
GPIOB->regs->CRL |= ((1 << 4)|(1 << 5));
GPIOB->regs->CRL &= ~((1 << 7)|(1 << 6));
//Setting PB1 (the LED pin) to be an output
gpio_set_mode(GPIOB, 8, GPIO_INPUT_PD);
//Setting PB1 (the LED pin) to be an input
afio_init();
//Enable the AFIO clock
//afio_exti_select(AFIO_EXTI_8,AFIO_EXTI_PB);
exti_attach_interrupt((exti_num)AFIO_EXTI_8, gpio_exti_port(GPIOB), intHandler, EXTI_RISING);
//attach the interrupt handler to the EXTI9_5 irq
//Setting PB1 as an OUTPUT
//blinky
while(1){
/* if((GPIOB->regs->IDR & (1 << 8)) == (1 << 8))
s = 1;*/
if(s == 0)
continue;
GPIOB->regs->BSRR = (1 << 1);
//Turn the LED On
delay_us(1000000);
GPIOB->regs->BRR = (1 << 1);
//Turn the LED Off
delay_us(1000000);
}
}
void intHandler()
{
GPIOB->regs->BSRR = (1 << 1);
s = 1;
}