dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pios_mpu.h
Go to the documentation of this file.
1 
14 /*
15  * This program is free software; you can redistribute it and/or modify
16  * it under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 3 of the License, or
18  * (at your option) any later version.
19  *
20  * This program is distributed in the hope that it will be useful, but
21  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  * for more details.
24  *
25  * You should have received a copy of the GNU General Public License along
26  * with this program; if not, see <http://www.gnu.org/licenses/>
27  */
28 
29 #ifndef PIOS_MPU_H
30 #define PIOS_MPU_H
31 
32 #include "pios.h"
33 
47 };
48 
61 };
62 
64  PIOS_MPU60X0_GYRO_LOWPASS_256_HZ = 0x00, // 8KHz sample mode
71 };
72 
74  PIOS_MPU6500_GYRO_LOWPASS_250_HZ = 0x00, // 8KHz sample mode
81 };
82 
84  PIOS_ICM206XX_GYRO_LOWPASS_250_HZ = 0x00, // 8KHz sample mode
91  PIOS_ICM206XX_GYRO_LOWPASS_3281_HZ = 0x07 // 8KHz sample mode
92 };
93 
102 };
103 
105  PIOS_ICM206XX_ACCEL_LOWPASS_218_HZ = 0x00, // 0x00 and 0x01 are identical.
112 };
113 
119 };
120 
126 };
127 
128 enum pios_mpu_orientation { // clockwise rotation from board forward
137 };
138 
139 struct pios_mpu_cfg {
140  const struct pios_exti_cfg *exti_cfg; /* Pointer to the EXTI configuration */
141 
145 #ifdef PIOS_INCLUDE_MPU_MAG
146  bool use_internal_mag; /* Flag to indicate whether or not to use the internal mag on MPU9x50 devices */
147 #endif // PIOS_INCLUDE_MPU_MAG
148 };
149 
150 typedef struct pios_mpu_dev * pios_mpu_dev_t;
151 
158 int32_t PIOS_MPU_I2C_Init(pios_mpu_dev_t *dev, pios_i2c_t i2c_id, const struct pios_mpu_cfg *cfg);
163 int32_t PIOS_MPU_SPI_Init(pios_mpu_dev_t *dev, pios_spi_t spi_id, uint32_t slave_num, const struct pios_mpu_cfg *cfg);
164 int32_t PIOS_MPU_Test();
165 int32_t PIOS_MPU_SetGyroRange(enum pios_mpu_gyro_range range);
166 int32_t PIOS_MPU_SetAccelRange(enum pios_mpu_accel_range range);
167 
172 int32_t PIOS_MPU_SetSampleRate(uint16_t samplerate_hz);
173 
180 void PIOS_MPU_SetGyroBandwidth(uint16_t bandwidth);
181 
188 void PIOS_MPU_SetAccelBandwidth(uint16_t bandwidth);
189 
194 bool PIOS_MPU_IRQHandler(void);
195 
200 
201 #endif /* PIOS_MPU_H */
202 
int32_t PIOS_MPU_I2C_Init(pios_mpu_dev_t *dev, pios_i2c_t i2c_id, const struct pios_mpu_cfg *cfg)
Initialize the MPU-xxxx 6/9-axis sensor on I2C.
pios_mpu60x0_gyro_filter
Definition: pios_mpu.h:63
pios_icm206xx_accel_filter
Definition: pios_mpu.h:104
int32_t PIOS_MPU_SetSampleRate(uint16_t samplerate_hz)
Main PiOS header to include all the compiled in PiOS options.
enum pios_mpu_type PIOS_MPU_GetType(void)
Which type of MPU was detected?
enum pios_mpu_orientation orientation
Definition: pios_mpu.h:143
pios_mpu6500_accel_filter
Definition: pios_mpu.h:94
uint16_t default_samplerate
Definition: pios_mpu.h:142
struct pios_mpu_dev * pios_mpu_dev_t
Definition: pios_mpu.h:150
static struct flyingpicmd_cfg_fa cfg
Definition: main.c:49
int32_t PIOS_MPU_SPI_Init(pios_mpu_dev_t *dev, pios_spi_t spi_id, uint32_t slave_num, const struct pios_mpu_cfg *cfg)
Initialize the MPU-xxxx 6/9-axis sensor on SPI.
pios_icm206xx_gyro_filter
Definition: pios_mpu.h:83
const struct pios_exti_cfg * exti_cfg
Definition: pios_mpu.h:140
int32_t PIOS_MPU_SetAccelRange(enum pios_mpu_accel_range range)
pios_mpu_orientation
Definition: pios_mpu.h:128
struct pios_i2c_adapter * pios_i2c_t
Definition: pios_i2c.h:48
pios_mpu_type
Definition: pios_mpu.h:52
bool skip_startup_irq_check
Definition: pios_mpu.h:144
void PIOS_MPU_SetGyroBandwidth(uint16_t bandwidth)
Sets the bandwidth desired from the gyro. The driver will automatically select the lowest bandwidth l...
void PIOS_MPU_SetAccelBandwidth(uint16_t bandwidth)
Sets the bandwidth desired from the accelerometer. The driver will automatically select the lowest ba...
pios_mpu_accel_range
Definition: pios_mpu.h:121
int32_t PIOS_MPU_Test()
pios_mpu6500_gyro_filter
Definition: pios_mpu.h:73
bool PIOS_MPU_IRQHandler(void)
The IMU interrupt handler. Fetches new data from the IMU.
pios_mpu_gyro_range
Definition: pios_mpu.h:114
pios_mpu_error
Definition: pios_mpu.h:37
int32_t PIOS_MPU_SetGyroRange(enum pios_mpu_gyro_range range)