31 #include <libopencm3/stm32/rcc.h>
32 #include <libopencm3/stm32/gpio.h>
33 #include <libopencm3/stm32/exti.h>
34 #include <libopencm3/cm3/nvic.h>
37 #error "MS2100 arch currently only implemented for STM32F1"
44 rcc_periph_clock_enable(RCC_GPIOC);
45 rcc_periph_clock_enable(RCC_AFIO);
47 gpio_set_mode(
GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL,
GPIO13);
51 rcc_periph_clock_enable(RCC_GPIOB);
52 gpio_set_mode(
GPIOB, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT,
GPIO5);
55 exti_select_source(EXTI5,
GPIOB);
56 exti_set_trigger(EXTI5, EXTI_TRIGGER_RISING);
57 exti_enable_request(EXTI5);
59 nvic_set_priority(NVIC_EXTI9_5_IRQ, 0x0f);
60 nvic_enable_irq(NVIC_EXTI9_5_IRQ);
71 int32_t end_cpu_ticks = systick_get_value() - dt_ticks;
72 if (end_cpu_ticks < 0) {
73 end_cpu_ticks += systick_get_reload();
75 while (systick_get_value() > (
uint32_t)end_cpu_ticks)
84 exti_reset_request(EXTI5);