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);
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
SPI transaction structure.
Driver for the ms2100 magnetic sensor from PNI.
void ms2100_arch_init(void)
void ms2100_reset_cb(struct spi_transaction *t)
Reset callback.
static void Ms2100Set(void)
Here Set indicates the Ms2100 is in reset state, i.e.
static void Ms2100Reset(void)
Here Reset indicates the Ms2100 is in normal state, i.e.
Architecture independent timing functions.
static uint32_t cpu_ticks_of_nsec(uint32_t nsec)
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.