|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
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)
73 #define HMC58XX_DO 0x6 // Data Output Rate (6 -> 75Hz with HMC5883)
76 #define HMC58XX_MS 0x0 // Measurement configuration
79 #define HMC58XX_GN 0x1 // Gain configuration (1 -> +- 1 Gauss)
82 #define HMC58XX_MD 0x0 // Continious measurement mode
85 #define HMC58XX_CRA ((HMC58XX_DO<<2)|(HMC58XX_MS))
86 #define HMC58XX_CRB (HMC58XX_GN<<5)
89 #ifndef ASPIRIN_2_MAG_STARTUP_DELAY
90 #define ASPIRIN_2_MAG_STARTUP_DELAY 1.5
112 #if !ASPIRIN_2_DISABLE_MAG
152 #define Int16FromBuf(_buf,_idx) ((int16_t)((_buf[_idx]<<8) | _buf[_idx+1]))
160 #if !ASPIRIN_2_DISABLE_MAG
170 #ifdef LISA_S_UPSIDE_DOWN
179 #if !ASPIRIN_2_DISABLE_MAG
185 #if !ASPIRIN_2_DISABLE_MAG
194 #ifdef LISA_M_OR_MX_21
203 #if !ASPIRIN_2_DISABLE_MAG
209 #ifdef LISA_M_LONGITUDINAL_X
218 #if !ASPIRIN_2_DISABLE_MAG
224 #if !ASPIRIN_2_DISABLE_MAG
237 #if !ASPIRIN_2_DISABLE_MAG
247 mpu_set(mpu, _reg, _val);
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
uint8_t nb_bytes
number of bytes to read starting with MPU60X0_REG_INT_STATUS
struct spi_transaction spi_trans
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
uint8_t smplrt_div
Sample rate divider.
enum SPIClockPolarity cpol
clock polarity control
#define MPU60X0_REG_I2C_SLV0_CTRL
#define ASPIRIN_2_GYRO_RANGE
enum Mpu60x0GyroRanges gyro_range
deg/s Range
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
void mpu_wait_slave4_ready(void)
#define MPU60X0_REG_I2C_SLV0_REG
uint16_t output_length
number of data words to write
void imu_aspirin2_event(void)
#define MPU60X0_I2C_SLV4_DONE
static float get_sys_time_float(void)
Get the time in seconds since startup.
SPI transaction structure.
void imu_aspirin2_init(void)
uint8_t data_ext[MPU60X0_BUFFER_EXT_LEN]
enum Mpu60x0MstClk i2c_mst_clk
MPU I2C master clock speed.
bool imu_aspirin2_configure_mag_slave(Mpu60x0ConfigSet mpu_set, void *mpu)
function to configure hmc5883 mag
enum Mpu60x0AccelRanges accel_range
g Range
enum Mpu60x0DLPF dlpf_cfg
Digital Low Pass Filter.
void mpu_wait_slave4_ready_cb(struct spi_transaction *t)
@ SPISelectUnselect
slave is selected before transaction and unselected after
#define ASPIRIN_2_SPI_DEV
#define ASPIRIN_2_SPI_SLAVE_IDX
enum SPIBitOrder bitorder
MSB/LSB order.
void(* Mpu60x0ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
enum SPISlaveSelect select
slave selection behavior
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
#define RATES_ASSIGN(_ra, _p, _q, _r)
#define MPU60X0_REG_I2C_SLV4_REG
Mpu60x0I2cSlaveConfigure configure
struct spi_periph * spi_p
enum SPIClockPhase cpha
clock phase control
void imu_aspirin2_periodic(void)
SPICallback after_cb
NULL or function called after the transaction.
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
#define MPU60X0_REG_I2C_SLV0_ADDR
Architecture independent timing functions.
#define HMC58XX_REG_DATXM
@ SPICpolIdleHigh
CPOL = 1.
void imu_scale_gyro(struct Imu *_imu)
#define MPU60X0_REG_I2C_SLV4_ADDR
struct Imu imu
global IMU state
uint8_t nb_slaves
number of used I2C slaves
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
static void mpu_set_and_wait(Mpu60x0ConfigSet mpu_set, void *mpu, uint8_t _reg, uint8_t _val)
struct ImuAspirin2Spi imu_aspirin2
static void mpu60x0_spi_periodic(struct Mpu60x0_Spi *mpu)
convenience function: read or start configuration if not already initialized
uint16_t input_length
number of data words to read
enum SPIDataSizeSelect dss
data transfer word size
#define Int16FromBuf(_buf, _idx)
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
#define MPU60X0_REG_I2C_SLV4_DO
union Mpu60x0_Spi::@333 data_accel
void imu_scale_mag(struct Imu *_imu)
uint8_t i2c_mst_delay
MPU I2C slaves delayed sample rate.
struct Mpu60x0I2cSlave slaves[MPU60X0_I2C_NB_SLAVES]
I2C slaves.
volatile uint8_t * input_buf
pointer to receive buffer for DMA
volatile bool data_available
data ready flag
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
#define ASPIRIN_2_ACCEL_RANGE
volatile bool slave4_ready
SPICallback before_cb
NULL or function called before the transaction.
#define MPU60X0_REG_I2C_SLV4_CTRL
#define VECT3_ASSIGN(_a, _x, _y, _z)
#define RATES_COPY(_a, _b)
union Mpu60x0_Spi::@334 data_rates
struct Mpu60x0Config config
#define MPU60X0_REG_I2C_MST_STATUS
struct spi_transaction wait_slave4_trans
void mpu60x0_spi_init(struct Mpu60x0_Spi *mpu, struct spi_periph *spi_p, uint8_t slave_idx)
enum SPITransactionStatus status
void mpu60x0_spi_event(struct Mpu60x0_Spi *mpu)
void imu_scale_accel(struct Imu *_imu)
#define ASPIRIN_2_MAG_STARTUP_DELAY
delay in seconds before starting to configure HMC58xx mag slave
#define VECT3_COPY(_a, _b)
volatile uint8_t wait_slave4_tx_buf[1]
volatile uint8_t wait_slave4_rx_buf[2]
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC