Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
imu_px4fmu.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Felix Ruess <felix.ruess@gmail.com>
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
28#include "modules/imu/imu.h"
29#include "modules/core/abi.h"
30#include "mcu_periph/spi.h"
32#include "generated/modules.h"
33
34
35/* MPU60x0 gyro/accel internal lowpass frequency */
36#if !defined PX4FMU_LOWPASS_FILTER && !defined PX4FMU_SMPLRT_DIV
37#if (PERIODIC_FREQUENCY == 60) || (PERIODIC_FREQUENCY == 120)
38/* Accelerometer: Bandwidth 44Hz, Delay 4.9ms
39 * Gyroscope: Bandwidth 42Hz, Delay 4.8ms sampling 1kHz
40 */
41#define PX4FMU_LOWPASS_FILTER MPU60X0_DLPF_42HZ
42#define PX4FMU_SMPLRT_DIV 9
43PRINT_CONFIG_MSG("Gyro/Accel output rate is 100Hz at 1kHz internal sampling")
44#elif PERIODIC_FREQUENCY == 512
45/* Accelerometer: Bandwidth 260Hz, Delay 0ms
46 * Gyroscope: Bandwidth 256Hz, Delay 0.98ms sampling 8kHz
47 */
48#define PX4FMU_LOWPASS_FILTER MPU60X0_DLPF_256HZ
49#define PX4FMU_SMPLRT_DIV 3
50PRINT_CONFIG_MSG("Gyro/Accel output rate is 2kHz at 8kHz internal sampling")
51#else
52#error Non-default PERIODIC_FREQUENCY: please define PX4FMU_LOWPASS_FILTER and PX4FMU_SMPLRT_DIV.
53#endif
54#endif
57
60
62
80
81
83{
85
86 // Read HMC58XX at 50Hz (main loop for rotorcraft: 512Hz)
88}
89
91{
93
96 struct Int32Rates gyro = {
100 };
101 struct Int32Vect3 accel = {
105 };
109 }
110
111 /* HMC58XX event task */
114 struct Int32Vect3 mag = {
115 imu_px4fmu.hmc.data.vect.y,
116 imu_px4fmu.hmc.data.vect.x,
117 -imu_px4fmu.hmc.data.vect.z
118 };
121 }
122}
123
Main include for ABI (AirBorneInterface).
#define IMU_BOARD_ID
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
angular rates
process_rx_dma_interrupt & spi1
receive transferred over DMA
Definition spi_arch.c:967
#define SPI_SLAVE2
Definition spi.h:194
void hmc58xx_init(struct Hmc58xx *hmc, struct i2c_periph *i2c_p, uint8_t addr)
Initialize Hmc58xx struct and set default config options.
Definition hmc58xx.c:83
void hmc58xx_event(struct Hmc58xx *hmc)
Definition hmc58xx.c:160
static void hmc58xx_periodic(struct Hmc58xx *hmc)
convenience function: read or start configuration if not already initialized
Definition hmc58xx.h:87
union Hmc58xx::@323 data
volatile bool data_available
data ready flag
Definition hmc58xx.h:67
Register defs for Honeywell HMC5843, HMC5883 and HMC5983 magnetometers.
#define HMC58XX_ADDR
void imu_set_defaults_accel(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct Int32Vect3 *scale)
Set the defaults for a accel sensor WARNING: Should be called before sensor is publishing messages to...
Definition imu.c:610
void imu_set_defaults_gyro(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Rates *neutral, const struct Int32Rates *scale)
Set the defaults for a gyro sensor WARNING: Should be called before sensor is publishing messages to ...
Definition imu.c:580
Inertial Measurement Unit interface.
void imu_px4fmu_periodic(void)
Definition imu_px4fmu.c:82
void imu_px4fmu_init(void)
Definition imu_px4fmu.c:63
struct ImuPx4fmu imu_px4fmu
Definition imu_px4fmu.c:61
void imu_px4fmu_event(void)
Definition imu_px4fmu.c:90
Driver for the PX4FMU SPI1 for the MPU6000 and I2C2 for the HMC5883.
#define PX4FMU_GYRO_RANGE
Definition imu_px4fmu.h:38
struct Hmc58xx hmc
Definition imu_px4fmu.h:47
#define PX4FMU_ACCEL_RANGE
Definition imu_px4fmu.h:42
struct Mpu60x0_Spi mpu
Definition imu_px4fmu.h:46
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
uint16_t foo
Definition main_demo5.c:58
const struct Int32Rates MPU60X0_GYRO_SENS_FRAC[4][2]
Definition mpu60x0.c:38
const struct Int32Vect3 MPU60X0_ACCEL_SENS_FRAC[4][2]
Definition mpu60x0.c:56
uint8_t smplrt_div
Sample rate divider.
Definition mpu60x0.h:140
enum Mpu60x0DLPF dlpf_cfg
Digital Low Pass Filter.
Definition mpu60x0.h:141
enum Mpu60x0AccelRanges accel_range
g Range
Definition mpu60x0.h:144
enum Mpu60x0GyroRanges gyro_range
deg/s Range
Definition mpu60x0.h:143
void mpu60x0_spi_event(struct Mpu60x0_Spi *mpu)
void mpu60x0_spi_init(struct Mpu60x0_Spi *mpu, struct spi_periph *spi_p, uint8_t slave_idx)
Definition mpu60x0_spi.c:31
volatile bool data_available
data ready flag
Definition mpu60x0_spi.h:56
struct Mpu60x0Config config
Definition mpu60x0_spi.h:67
float temp
temperature in degrees Celcius
Definition mpu60x0_spi.h:65
union Mpu60x0_Spi::@344 data_rates
static void mpu60x0_spi_periodic(struct Mpu60x0_Spi *mpu)
convenience function: read or start configuration if not already initialized
Definition mpu60x0_spi.h:78
union Mpu60x0_Spi::@343 data_accel
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
Architecture independent SPI (Serial Peripheral Interface) API.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.