Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_aspirin_arch.c
Go to the documentation of this file.
1 #include "subsystems/imu.h"
2 
3 #include <libopencm3/stm32/f1/gpio.h>
4 #include <libopencm3/stm32/f1/rcc.h>
5 #include <libopencm3/stm32/exti.h>
6 #include <libopencm3/stm32/spi.h>
7 #include <libopencm3/stm32/f1/dma.h>
8 #include <libopencm3/stm32/f1/nvic.h>
9 
10 #include "mcu_periph/i2c.h"
11 
13 
14 #ifdef ASPIRIN_USE_GYRO_INT
15  nvic_set_priority(NVIC_EXTI15_10_IRQ, 0x0F);
16  nvic_enable_irq(NVIC_EXTI15_10_IRQ);
17 #endif
18 
19  nvic_set_priority(NVIC_EXTI2_IRQ, 0x0F);
20  nvic_enable_irq(NVIC_EXTI2_IRQ);
21 
22  // should not be needed anymore, handled by the spi driver
23 #if 0
24  /* Enable DMA1 channel4 IRQ Channel ( SPI RX) */
25  nvic_set_priority(NVIC_DMA1_CHANNEL4_IRQ, 0);
26  nvic_enable_irq(NVIC_DMA1_CHANNEL4_IRQ);
27 #endif
28 }
29 
31 
32 #ifdef ASPIRIN_USE_GYRO_INT
33  nvic_disable_irq(NVIC_EXTI15_10_IRQ);
34 #endif
35 
36  nvic_disable_irq(NVIC_EXTI2_IRQ);
37 
38  // should not be needed anymore, handled by the spi driver
39 #if 0
40  /* Enable DMA1 channel4 IRQ Channel ( SPI RX) */
41  nvic_disable_irq(NVIC_DMA1_CHANNEL4_IRQ);
42 #endif
43 }
44 
46 
47  // This was needed for Lisa/L????
48 #if 0
49  /* Set "mag ss" and "mag reset" as floating inputs ------------------------*/
50  /* "mag ss" (PC12) is shorted to I2C2 SDA */
51  /* "mag reset" (PC13) is shorted to I2C2 SCL */
52  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
53  gpio_set_mode(GPIOC, GPIO_MODE_INPUT,
54  GPIO_CNF_INPUT_FLOAT, GPIO12 | GPIO13);
55 #endif
56 
57  /* Gyro --------------------------------------------------------------------*/
58  /* configure external interrupt exti15_10 on PC14( gyro int ) */
59  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN |
60  RCC_APB2ENR_AFIOEN);
61  gpio_set_mode(GPIOC, GPIO_MODE_INPUT,
62  GPIO_CNF_INPUT_FLOAT, GPIO14);
63 
64 #ifdef ASPIRIN_USE_GYRO_INT
65  exti_select_source(EXTI14, GPIOC);
66  exti_set_trigger(EXTI14, EXTI_TRIGGER_FALLING);
67  exti_enable_request(EXTI14);
68 #endif
69 
70  /* configure external interrupt exti2 on PB2( accel int ) */
71  rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN | RCC_APB2ENR_AFIOEN);
72  gpio_set_mode(GPIOB, GPIO_MODE_INPUT,
73  GPIO_CNF_INPUT_FLOAT, GPIO2);
74  exti_select_source(EXTI2, GPIOB);
75  exti_set_trigger(EXTI2, EXTI_TRIGGER_FALLING);
76  exti_enable_request(EXTI2);
77 
78 }
79 
80 
81 /****** the interrupts should be handled in the peripheral drivers *******/
82 
83 /*
84  * Gyro data ready
85  */
86 void exti15_10_isr(void) {
87 
88  /* clear EXTI */
89  exti_reset_request(EXTI14);
90 
91 #ifdef ASPIRIN_USE_GYRO_INT
92  imu_aspirin.gyro_eoc = TRUE;
93  imu_aspirin.status = AspirinStatusReadingGyro;
94 #endif
95 
96 }
97 
98 /*
99  * Accel data ready
100  */
101 void exti2_isr(void) {
102 
103  /* clear EXTI */
104  exti_reset_request(EXTI2);
105 
106  //adxl345_start_reading_data();
107 }
108 
struct ImuAspirin imu_aspirin
Definition: imu_aspirin.c:66
void imu_aspirin_arch_init(void)
void exti2_isr(void)
void imu_aspirin_arch_int_disable(void)
Inertial Measurement Unit interface.
#define TRUE
Definition: imu_chimu.h:144
void exti15_10_isr(void)
void imu_aspirin_arch_int_enable(void)
Architecture independent I2C (Inter-Integrated Circuit Bus) API.