Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_px4fmu_v2.4.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013-2016 the paparazzi team
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
22
29#include "modules/imu/imu.h"
30#include "modules/core/abi.h"
31#include "mcu_periph/spi.h"
32#include "generated/modules.h"
33
34/* SPI defaults set in subsystem makefile, can be configured from airframe file */
38
40
41void imu_px4_init(void) {
42 /* L3GD20 gyro init */
43 /* initialize gyro and set default options */
45
46 /* LSM303d acc init */
48
49 // Set the default scaling
54
55#if !IMU_PX4_DISABLE_MAG
56 /* LSM303d mag init */
58#endif
59
60}
61
62void imu_px4_periodic(void) {
65
66#if !IMU_PX4_DISABLE_MAG
67 /* Read magneto's every 10 times of main freq
68 * at ~50Hz (main loop for rotorcraft: 512Hz)
69 */
71#endif
72}
73
74void imu_px4_event(void) {
75
77
78 /* L3GD20 event task */
81 //the p and q seem to be swapped on the Pixhawk board compared to the acc
82 struct Int32Rates gyro = {
83 imu_px4.l3g.data_rates.rates.q,
84 -imu_px4.l3g.data_rates.rates.p,
85 imu_px4.l3g.data_rates.rates.r
86 };
89 }
90
91 /* LSM303d event task */
94 struct Int32Vect3 accel;
98 }
99#if !IMU_PX4_DISABLE_MAG
102 struct Int32Vect3 mag;
103 VECT3_ASSIGN(mag,
104 imu_px4.lsm_mag.data_mag.vect.x,
105 imu_px4.lsm_mag.data_mag.vect.y,
106 imu_px4.lsm_mag.data_mag.vect.z);
109 }
110#endif
111
112}
Main include for ABI (AirBorneInterface).
#define IMU_PX4_ID
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
angular rates
#define VECT3_ASSIGN(_a, _x, _y, _z)
#define VECT3_COPY(_a, _b)
angular rates
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.
struct ImuPX4 imu_px4
void imu_px4_init(void)
void imu_px4_periodic(void)
void imu_px4_event(void)
Driver for pixhawk IMU's.
struct Lsm303d_Spi lsm_acc
struct L3gd20_Spi l3g
struct Lsm303d_Spi lsm_mag
#define L3GD20_SENS_2000
default gyro sensitivy and neutral from the datasheet L3GD20 has 70e-3 LSB/(deg/s) at 2000deg/s range...
Definition l3gd20.h:40
void l3gd20_spi_event(struct L3gd20_Spi *l3g)
Definition l3gd20_spi.c:135
void l3gd20_spi_init(struct L3gd20_Spi *l3g, struct spi_periph *spi_p, uint8_t slave_idx)
Definition l3gd20_spi.c:30
union L3gd20_Spi::@331 data_rates
static void l3gd20_spi_periodic(struct L3gd20_Spi *l3g)
convenience function: read or start configuration if not already initialized
Definition l3gd20_spi.h:60
volatile bool data_available
data ready flag
Definition l3gd20_spi.h:45
@ LSM303D_TARGET_MAG
Definition lsm303d.h:89
@ LSM303D_TARGET_ACC
Definition lsm303d.h:88
#define LSM303D_ACCEL_SENS_16G
default accel sensitivy from the datasheet LSM303DLHC has 732 LSB/g fixed point sens: 9....
Definition lsm303d.h:61
void lsm303d_spi_event(struct Lsm303d_Spi *lsm)
void lsm303d_spi_init(struct Lsm303d_Spi *lsm, struct spi_periph *spi_p, uint8_t slave_idx, enum Lsm303dTarget target)
Definition lsm303d_spi.c:32
static void lsm303d_spi_periodic(struct Lsm303d_Spi *lsm)
convenience function: read or start configuration if not already initialized
Definition lsm303d_spi.h:68
union Lsm303d_Spi::@335 data_mag
volatile bool data_available_acc
data ready flag accelero
Definition lsm303d_spi.h:45
volatile bool data_available_mag
data ready flag magneto
Definition lsm303d_spi.h:46
union Lsm303d_Spi::@334 data_accel
uint16_t foo
Definition main_demo5.c:58
static const struct FloatVect3 accel_scale_f
Default accel scale/neutral.
Definition navdata.c:97
static const struct FloatRates gyro_scale_f
Default gyro scale.
Definition navdata.c:92
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
Architecture independent SPI (Serial Peripheral Interface) API.
#define FALSE
Definition std.h:5
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.