Hardware Abstraction Layer for FreeRTOS
Collaboration diagram for MPU9250 driver:

Data Structures

struct  mpu9250_accel
 
struct  mpu9250_gyro
 
struct  mpu9250
 
struct  mpu9250_vector
 

Macros

#define MPU_GRAVITY   16384
 
#define MPU9250_ADDDEV(id)
 
#define MPU9250_ID(id)   HAL_GET_ID(hal, mpu9250, mpu9250_##id)
 

Functions

struct mpu9250mpu9250_init (uint32_t index, struct spi *spi, uint8_t cs, uint16_t gpio, TickType_t waittime)
 
int32_t mpu9250_deinit (struct mpu9250 *mpu)
 
int32_t mpu9250_reset (struct mpu9250 *mpu, TickType_t waittime)
 
int32_t mpu9250_getAccel (struct mpu9250 *mpu, struct mpu9250_vector *vec, TickType_t waittime)
 
int32_t mpu9250_getGyro (struct mpu9250 *mpu, struct mpu9250_vector *vec, TickType_t waittime)
 

Detailed Description

#include <mpu9250.h>

This is the MPU9250 Driver.

Macro Definition Documentation

◆ MPU9250_ADDDEV

#define MPU9250_ADDDEV (   id)
Value:
struct mpu9250 mpu9250_##id; \
struct mpu9250_accel mpu9250_accel_##id = { \
ACCEL_INIT_DEV(mpu9250) \
HAL_NAME("MPU9250 " #id " Accelerator") \
.mpu = &mpu9250_##id, \
.accelBasis = {0, 0, 0}, \
};\
struct mpu9250_gyro mpu9250_gyro_##id = { \
GYRO_INIT_DEV(mpu9250) \
HAL_NAME("MPU9250 " #id " Gyro") \
.mpu = &mpu9250_##id, \
.gyroBasis = {0, 0, 0}, \
};\
struct mpu9250 mpu9250_##id = { \
HAL_NAME("MPU9250 " #id) \
.gen.init = false, \
.slave = NULL, \
.accel = &mpu9250_accel_##id, \
.gyro = &mpu9250_gyro_##id, \
.bank = 0, \
}; \
ACCEL_ADDDEV(mpu9250, mpu9250_accel_##id); \
GYRO_ADDDEV(mpu9250, mpu9250_gyro_##id); \
HAL_ADD(mpu9250, mpu9250_##id)

The Number of MPU9250 is Board spezific, the User Code must Call this Macro to define a new MPU9250 dev

Warning
do not use the created Variable directly! Use the init function!
Parameters
idUnique identifier

◆ MPU9250_ID

#define MPU9250_ID (   id)    HAL_GET_ID(hal, mpu9250, mpu9250_##id)

Get MPU9250 based on id

◆ MPU_GRAVITY

#define MPU_GRAVITY   16384

MPU9250 Gravity Constant

Function Documentation

◆ mpu9250_deinit()

int32_t mpu9250_deinit ( struct mpu9250 mpu)

Deinit MPU9250 Instance

Parameters
mpuMPU9250 Instance
Returns
-1 on error 0 on ok

◆ mpu9250_getAccel()

int32_t mpu9250_getAccel ( struct mpu9250 mpu,
struct mpu9250_vector vec,
TickType_t  waittime 
)

Get actual Accelerator Value

Parameters
mpuMPU9250 Instance
vecValue
waittimemax waittime in mutex or isr lock see xSemaphoreTake()
Returns
-1 on error 0 on ok

◆ mpu9250_getGyro()

int32_t mpu9250_getGyro ( struct mpu9250 mpu,
struct mpu9250_vector vec,
TickType_t  waittime 
)

Get actual Gyroscope Value

Parameters
mpuMPU9250 Instance
vecValue
waittimemax waittime in mutex or isr lock see xSemaphoreTake()
Returns
-1 on error 0 on ok

◆ mpu9250_init()

struct mpu9250* mpu9250_init ( uint32_t  index,
struct spi *  spi,
uint8_t  cs,
uint16_t  gpio,
TickType_t  waittime 
)

MPU9250 init

Parameters
indexDriver Index
waittimemax waittime in mutex or isr lock see xSemaphoreTake()
spiSPI Device
csCS Number or SPI_OPT_CS_DIS
gpioGPIO Pin Number or SPI_OPT_GPIO_DIS
Returns
MPU9250 Instance or NULL on error

◆ mpu9250_reset()

int32_t mpu9250_reset ( struct mpu9250 mpu,
TickType_t  waittime 
)

Reset MPU9250

Parameters
mpuMPU9250 Instance
waittimemax waittime in mutex or isr lock see xSemaphoreTake()
Returns
-1 on error 0 on ok
mpu9250_gyro::mpu
struct mpu9250 * mpu
Definition: mpu9250.h:396
mpu9250::gen
struct hal gen
Definition: mpu9250.h:407
mpu9250_gyro
Definition: mpu9250.h:388
mpu9250_accel
Definition: mpu9250.h:371
mpu9250
Definition: mpu9250.h:406
mpu9250.h
hal::init
bool init
Definition: hal.h:52
mpu9250_accel::mpu
struct mpu9250 * mpu
Definition: mpu9250.h:379