23 #include "libopencm3/stm32/rcc.h"
24 #include "libopencm3/stm32/gpio.h"
25 #include "libopencm3/stm32/exti.h"
26 #include <libopencm3/cm3/nvic.h>
29 #error "HMC5843 arch currently only implemented for STM32F1"
37 rcc_periph_clock_enable(RCC_GPIOB);
38 rcc_periph_clock_enable(RCC_AFIO);
39 gpio_set_mode(
GPIOB, GPIO_MODE_INPUT,
40 GPIO_CNF_INPUT_FLOAT,
GPIO2);
42 exti_select_source(EXTI2,
GPIOB);
43 exti_set_trigger(EXTI2, EXTI_TRIGGER_FALLING);
44 exti_enable_request(EXTI2);
46 nvic_set_priority(NVIC_EXTI2_IRQ, 0xF);
47 nvic_enable_irq(NVIC_EXTI2_IRQ);
55 exti_reset_request(EXTI2);