33 #include "generated/modules.h"
36 #ifndef ASPIRIN_2_SPI_SLAVE_IDX
37 #define ASPIRIN_2_SPI_SLAVE_IDX SPI_SLAVE2
41 #ifndef ASPIRIN_2_SPI_DEV
42 #define ASPIRIN_2_SPI_DEV spi2
47 #if !defined ASPIRIN_2_LOWPASS_FILTER && !defined ASPIRIN_2_SMPLRT_DIV
48 #if (PERIODIC_FREQUENCY == 60) || (PERIODIC_FREQUENCY == 120)
52 #define ASPIRIN_2_LOWPASS_FILTER MPU60X0_DLPF_42HZ
53 #define ASPIRIN_2_SMPLRT_DIV 9
54 PRINT_CONFIG_MSG(
"Gyro/Accel output rate is 100Hz at 1kHz internal sampling")
55 #elif PERIODIC_FREQUENCY == 512
59 #define ASPIRIN_2_LOWPASS_FILTER MPU60X0_DLPF_256HZ
60 #define ASPIRIN_2_SMPLRT_DIV 3
63 #error Non-default PERIODIC_FREQUENCY: please define ASPIRIN_2_LOWPASS_FILTER and ASPIRIN_2_SMPLRT_DIV.
75 #define HMC58XX_DO 0x6
78 #define HMC58XX_MS 0x0
81 #define HMC58XX_GN 0x1
84 #define HMC58XX_MD 0x0
87 #define HMC58XX_CRA ((HMC58XX_DO<<2)|(HMC58XX_MS))
88 #define HMC58XX_CRB (HMC58XX_GN<<5)
91 #ifndef ASPIRIN_2_MAG_STARTUP_DELAY
92 #define ASPIRIN_2_MAG_STARTUP_DELAY 1.5
118 #if !ASPIRIN_2_DISABLE_MAG
158 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))
166 #if !ASPIRIN_2_DISABLE_MAG
178 #ifdef LISA_S_UPSIDE_DOWN
187 #if !ASPIRIN_2_DISABLE_MAG
193 #if !ASPIRIN_2_DISABLE_MAG
202 #ifdef LISA_M_OR_MX_21
211 #if !ASPIRIN_2_DISABLE_MAG
217 #ifdef LISA_M_LONGITUDINAL_X
226 #if !ASPIRIN_2_DISABLE_MAG
232 #if !ASPIRIN_2_DISABLE_MAG
243 #if !ASPIRIN_2_DISABLE_MAG
252 mpu_set(mpu, _reg, _val);
Main include for ABI (AirBorneInterface).
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
#define RATES_COPY(_a, _b)
#define RATES_ASSIGN(_ra, _p, _q, _r)
#define VECT3_ASSIGN(_a, _x, _y, _z)
#define VECT3_COPY(_a, _b)
enum SPIClockPolarity cpol
clock polarity control
enum SPIClockPhase cpha
clock phase control
enum SPISlaveSelect select
slave selection behavior
SPICallback before_cb
NULL or function called before the transaction.
SPICallback after_cb
NULL or function called after the transaction.
enum SPIDataSizeSelect dss
data transfer word size
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
uint16_t input_length
number of data words to read
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
volatile uint8_t * input_buf
pointer to receive buffer for DMA
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
enum SPIBitOrder bitorder
MSB/LSB order.
uint16_t output_length
number of data words to write
enum SPITransactionStatus status
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
@ SPICpolIdleHigh
CPOL = 1.
@ SPISelectUnselect
slave is selected before transaction and unselected after
SPI transaction structure.
Register defs for Honeywell HMC5843 and HMC5883 magnetometers.
#define HMC58XX_REG_DATXM
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...
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 ...
Inertial Measurement Unit interface.
#define ASPIRIN_2_SPI_DEV
void imu_aspirin2_event(void)
#define ASPIRIN_2_MAG_STARTUP_DELAY
delay in seconds before starting to configure HMC58xx mag slave
struct ImuAspirin2Spi imu_aspirin2
void mpu_wait_slave4_ready_cb(struct spi_transaction *t)
#define ASPIRIN_2_SPI_SLAVE_IDX
void imu_aspirin2_periodic(void)
void mpu_wait_slave4_ready(void)
void imu_aspirin2_init(void)
bool imu_aspirin2_configure_mag_slave(Mpu60x0ConfigSet mpu_set, void *mpu)
function to configure hmc5883 mag
#define Int16FromBuf(_buf, _idx)
static void mpu_set_and_wait(Mpu60x0ConfigSet mpu_set, void *mpu, uint8_t _reg, uint8_t _val)
Driver for the Aspirin v2.x IMU using SPI for the MPU6000.
volatile bool slave4_ready
#define ASPIRIN_2_GYRO_RANGE
volatile uint8_t wait_slave4_rx_buf[2]
#define ASPIRIN_2_ACCEL_RANGE
volatile uint8_t wait_slave4_tx_buf[1]
struct spi_transaction wait_slave4_trans
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
const struct Int32Rates MPU60X0_GYRO_SENS_FRAC[4][2]
const struct Int32Vect3 MPU60X0_ACCEL_SENS_FRAC[4][2]
Mpu60x0I2cSlaveConfigure configure
uint8_t i2c_mst_delay
MPU I2C slaves delayed sample rate.
enum Mpu60x0MstClk i2c_mst_clk
MPU I2C master clock speed.
uint8_t nb_bytes
number of bytes to read starting with MPU60X0_REG_INT_STATUS
uint8_t smplrt_div
Sample rate divider.
uint8_t nb_slaves
number of used I2C slaves
struct Mpu60x0I2cSlave slaves[MPU60X0_I2C_NB_SLAVES]
I2C slaves.
enum Mpu60x0DLPF dlpf_cfg
Digital Low Pass Filter.
enum Mpu60x0AccelRanges accel_range
g Range
void(* Mpu60x0ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
enum Mpu60x0GyroRanges gyro_range
deg/s Range
#define MPU60X0_I2C_SLV4_DONE
#define MPU60X0_REG_I2C_SLV0_ADDR
#define MPU60X0_REG_I2C_SLV4_REG
#define MPU60X0_REG_I2C_SLV4_CTRL
#define MPU60X0_REG_I2C_MST_STATUS
#define MPU60X0_REG_I2C_SLV0_REG
#define MPU60X0_REG_I2C_SLV0_CTRL
#define MPU60X0_REG_I2C_SLV4_ADDR
#define MPU60X0_REG_I2C_SLV4_DO
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)
volatile bool data_available
data ready flag
uint8_t data_ext[MPU60X0_BUFFER_EXT_LEN]
struct Mpu60x0Config config
struct spi_transaction spi_trans
float temp
temperature in degrees Celcius
union Mpu60x0_Spi::@342 data_rates
struct spi_periph * spi_p
static void mpu60x0_spi_periodic(struct Mpu60x0_Spi *mpu)
convenience function: read or start configuration if not already initialized
union Mpu60x0_Spi::@341 data_accel
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
Architecture independent SPI (Serial Peripheral Interface) API.
Architecture independent timing functions.
static float get_sys_time_float(void)
Get the time in seconds since startup.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.