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/* MPU60x0 gyro/accel internal lowpass frequency */
35#if !defined PX4FMU_LOWPASS_FILTER && !defined PX4FMU_SMPLRT_DIV
36#if (PERIODIC_FREQUENCY == 60) || (PERIODIC_FREQUENCY == 120)
37/* Accelerometer: Bandwidth 44Hz, Delay 4.9ms
38 * Gyroscope: Bandwidth 42Hz, Delay 4.8ms sampling 1kHz
39 */
40#define PX4FMU_LOWPASS_FILTER MPU60X0_DLPF_42HZ
41#define PX4FMU_SMPLRT_DIV 9
42PRINT_CONFIG_MSG("Gyro/Accel output rate is 100Hz at 1kHz internal sampling")
43#elif (PERIODIC_FREQUENCY == 500) || (PERIODIC_FREQUENCY == 512)
44/* Accelerometer: Bandwidth 260Hz, Delay 0ms
45 * Gyroscope: Bandwidth 256Hz, Delay 0.98ms sampling 8kHz
46 */
47#define PX4FMU_LOWPASS_FILTER MPU60X0_DLPF_256HZ
48#define PX4FMU_SMPLRT_DIV 3
49PRINT_CONFIG_MSG("Gyro/Accel output rate is 2kHz at 8kHz internal sampling")
50#else
51#error Non-default PERIODIC_FREQUENCY: please define PX4FMU_LOWPASS_FILTER and PX4FMU_SMPLRT_DIV.
52#endif
53#endif
56
59
61
79
81{
83
84 // Read HMC58XX at 50Hz (main loop for rotorcraft: 512Hz)
86}
87
89{
91
94 struct Int32Rates gyro = {
98 };
99 struct Int32Vect3 accel = {
103 };
107 }
108
109 /* HMC58XX event task */
112 struct Int32Vect3 mag = {
113 imu_px4fmu.hmc.data.vect.y,
114 imu_px4fmu.hmc.data.vect.x,
115 -imu_px4fmu.hmc.data.vect.z
116 };
119 }
120}
121
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:191
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_gyro(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Rates *neutral, const struct FloatRates *scale_f)
Set the defaults for a gyro sensor WARNING: Should be called before sensor is publishing messages to ...
Definition imu.c:616
void imu_set_defaults_accel(uint8_t abi_id, const struct Int32RMat *imu_to_sensor, const struct Int32Vect3 *neutral, const struct FloatVect3 *scale_f)
Set the defaults for a accel sensor WARNING: Should be called before sensor is publishing messages to...
Definition imu.c:645
Inertial Measurement Unit interface.
void imu_px4fmu_periodic(void)
Definition imu_px4fmu.c:80
void imu_px4fmu_init(void)
Definition imu_px4fmu.c:62
struct ImuPx4fmu imu_px4fmu
Definition imu_px4fmu.c:60
void imu_px4fmu_event(void)
Definition imu_px4fmu.c:88
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 FloatVect3 MPU60X0_ACCEL_SENS_F[4]
Definition mpu60x0.c:54
const struct FloatRates MPU60X0_GYRO_SENS_F[4]
Definition mpu60x0.c:38
uint8_t smplrt_div
Sample rate divider.
Definition mpu60x0.h:123
enum Mpu60x0DLPF dlpf_cfg
Digital Low Pass Filter.
Definition mpu60x0.h:124
enum Mpu60x0AccelRanges accel_range
g Range
Definition mpu60x0.h:127
enum Mpu60x0GyroRanges gyro_range
deg/s Range
Definition mpu60x0.h:126
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.