34 #ifndef ASPIRIN_2_SPI_SLAVE_IDX
35 #define ASPIRIN_2_SPI_SLAVE_IDX SPI_SLAVE2
39 #ifndef ASPIRIN_2_SPI_DEV
40 #define ASPIRIN_2_SPI_DEV spi2
45 #if !defined ASPIRIN_2_LOWPASS_FILTER && !defined ASPIRIN_2_SMPLRT_DIV
46 #if (PERIODIC_FREQUENCY == 60) || (PERIODIC_FREQUENCY == 120)
50 #define ASPIRIN_2_LOWPASS_FILTER MPU60X0_DLPF_42HZ
51 #define ASPIRIN_2_SMPLRT_DIV 9
52 PRINT_CONFIG_MSG(
"Gyro/Accel output rate is 100Hz at 1kHz internal sampling")
53 #elif PERIODIC_FREQUENCY == 512
57 #define ASPIRIN_2_LOWPASS_FILTER MPU60X0_DLPF_256HZ
58 #define ASPIRIN_2_SMPLRT_DIV 3
61 #error Non-default PERIODIC_FREQUENCY: please define ASPIRIN_2_LOWPASS_FILTER and ASPIRIN_2_SMPLRT_DIV.
64 PRINT_CONFIG_VAR(ASPIRIN_2_LOWPASS_FILTER)
65 PRINT_CONFIG_VAR(ASPIRIN_2_SMPLRT_DIV)
67 #ifndef ASPIRIN_2_GYRO_RANGE
68 #define ASPIRIN_2_GYRO_RANGE MPU60X0_GYRO_RANGE_2000
72 #ifndef ASPIRIN_2_ACCEL_RANGE
73 #define ASPIRIN_2_ACCEL_RANGE MPU60X0_ACCEL_RANGE_16G
80 #define HMC58XX_DO 0x6 // Data Output Rate (6 -> 75Hz with HMC5883)
83 #define HMC58XX_MS 0x0 // Measurement configuration
86 #define HMC58XX_GN 0x1 // Gain configuration (1 -> +- 1 Gauss)
89 #define HMC58XX_MD 0x0 // Continious measurement mode
92 #define HMC58XX_CRA ((HMC58XX_DO<<2)|(HMC58XX_MS))
93 #define HMC58XX_CRB (HMC58XX_GN<<5)
96 #ifndef ASPIRIN_2_MAG_STARTUP_DELAY
97 #define ASPIRIN_2_MAG_STARTUP_DELAY 1.5
119 #if !ASPIRIN_2_DISABLE_MAG
159 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))
167 #if !ASPIRIN_2_DISABLE_MAG
177 #ifdef LISA_S_UPSIDE_DOWN
186 #if !ASPIRIN_2_DISABLE_MAG
192 #if !ASPIRIN_2_DISABLE_MAG
201 #ifdef LISA_M_OR_MX_21
210 #if !ASPIRIN_2_DISABLE_MAG
216 #ifdef LISA_M_LONGITUDINAL_X
225 #if !ASPIRIN_2_DISABLE_MAG
231 #if !ASPIRIN_2_DISABLE_MAG
244 #if !ASPIRIN_2_DISABLE_MAG
254 mpu_set(mpu, _reg, _val);
enum SPIClockPolarity cpol
clock polarity control
void imu_aspirin2_periodic(void)
void mpu60x0_spi_init(struct Mpu60x0_Spi *mpu, struct spi_periph *spi_p, uint8_t slave_idx)
#define MPU60X0_REG_I2C_SLV0_REG
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
struct ImuAspirin2Spi imu_aspirin2
uint8_t data_ext[MPU60X0_BUFFER_EXT_LEN]
#define MPU60X0_I2C_SLV4_DONE
uint16_t output_length
number of data words to write
void imu_scale_gyro(struct Imu *_imu)
#define MPU60X0_REG_I2C_SLV0_CTRL
void imu_scale_accel(struct Imu *_imu)
void mpu_wait_slave4_ready(void)
struct Mpu60x0Config config
volatile bool slave4_ready
void mpu60x0_spi_event(struct Mpu60x0_Spi *mpu)
#define VECT3_COPY(_a, _b)
volatile uint8_t wait_slave4_tx_buf[1]
#define VECT3_ASSIGN(_a, _x, _y, _z)
#define RATES_ASSIGN(_ra, _p, _q, _r)
void imu_aspirin2_init(void)
Main include for ABI (AirBorneInterface).
union Mpu60x0_Spi::@314 data_accel
uint8_t smplrt_div
Sample rate divider.
SPI transaction structure.
#define ASPIRIN_2_ACCEL_RANGE
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
enum SPIBitOrder bitorder
MSB/LSB order.
struct Imu imu
global IMU state
enum Mpu60x0GyroRanges gyro_range
deg/s Range
#define ASPIRIN_2_GYRO_RANGE
#define ASPIRIN_2_SPI_DEV
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
static float get_sys_time_float(void)
Get the time in seconds since startup.
enum Mpu60x0AccelRanges accel_range
g Range
enum SPISlaveSelect select
slave selection behavior
enum Mpu60x0DLPF dlpf_cfg
Digital Low Pass Filter.
Mpu60x0I2cSlaveConfigure configure
Architecture independent SPI (Serial Peripheral Interface) API.
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
enum SPIClockPhase cpha
clock phase control
enum Mpu60x0MstClk i2c_mst_clk
MPU I2C master clock speed.
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
static void mpu60x0_spi_periodic(struct Mpu60x0_Spi *mpu)
convenience function: read or start configuration if not already initialized
Architecture independent timing functions.
struct spi_transaction spi_trans
SPICallback after_cb
NULL or function called after the transaction.
void imu_aspirin2_event(void)
uint8_t nb_slaves
number of used I2C slaves
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
#define MPU60X0_REG_I2C_SLV4_REG
struct spi_periph * spi_p
#define HMC58XX_REG_DATXM
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
Inertial Measurement Unit interface.
uint16_t input_length
number of data words to read
volatile bool data_available
data ready flag
static void mpu_set_and_wait(Mpu60x0ConfigSet mpu_set, void *mpu, uint8_t _reg, uint8_t _val)
volatile uint8_t wait_slave4_rx_buf[2]
#define MPU60X0_REG_I2C_SLV4_ADDR
Register defs for Honeywell HMC5843 and HMC5883 magnetometers.
#define MPU60X0_REG_I2C_SLV0_ADDR
#define Int16FromBuf(_buf, _idx)
struct spi_transaction wait_slave4_trans
#define MPU60X0_REG_I2C_SLV4_CTRL
void imu_scale_mag(struct Imu *_imu)
#define ASPIRIN_2_SPI_SLAVE_IDX
union Mpu60x0_Spi::@315 data_rates
slave is selected before transaction and unselected after
#define MPU60X0_REG_I2C_MST_STATUS
enum SPIDataSizeSelect dss
data transfer word size
uint8_t i2c_mst_delay
MPU I2C slaves delayed sample rate.
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
volatile uint8_t * input_buf
pointer to receive buffer for DMA
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
SPICallback before_cb
NULL or function called before the transaction.
#define RATES_COPY(_a, _b)
#define MPU60X0_REG_I2C_SLV4_DO
void mpu_wait_slave4_ready_cb(struct spi_transaction *t)
uint8_t nb_bytes
number of bytes to read starting with MPU60X0_REG_INT_STATUS
bool imu_aspirin2_configure_mag_slave(Mpu60x0ConfigSet mpu_set, void *mpu)
function to configure hmc5883 mag
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
#define ASPIRIN_2_MAG_STARTUP_DELAY
delay in seconds before starting to configure HMC58xx mag slave
struct Mpu60x0I2cSlave slaves[MPU60X0_I2C_NB_SLAVES]
I2C slaves.
void(* Mpu60x0ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
enum SPITransactionStatus status
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC