Group ns-MPU6050
Classes
Type | Name |
---|---|
struct | mpu6050_config_t |
struct | mpu6050_fifo_config_t |
struct | mpu6050_int_config_t |
Public Types
Type | Name |
---|---|
enum | mpu6050_accel_fs_t |
enum | mpu6050_clock_src_t |
enum | mpu6050_dlpf_cfg_t |
enum | mpu6050_gyro_fs_t |
enum | mpu6050_status_e |
Public Functions
Type | Name |
---|---|
uint32_t | mpu6050_accel_fsr_value (mpu6050_accel_fs_t range) Acceleration scale in units of G. |
float | mpu6050_accel_resolution (mpu6050_accel_fs_t range) Acceleration scale LSB resolution. |
float | mpu6050_accel_to_gravity (int16_t val, mpu6050_accel_fs_t range) Convert acceleration value to G. |
uint32_t | mpu6050_calibrate (ns_i2c_config_t * cfg, uint32_t devAddr) Calibrate device offsets. Device must be still on a flat surface. |
uint32_t | mpu6050_configure_fifo (ns_i2c_config_t * cfg, uint32_t devAddr, mpu6050_fifo_config_t * fifoConfig) Configure FIFO. |
uint32_t | mpu6050_configure_interrupt (ns_i2c_config_t * cfg, uint32_t devAddr, mpu6050_int_config_t * intConfig) Configure interrupts. |
uint32_t | mpu6050_device_reset (ns_i2c_config_t * cfg, uint32_t devAddr) Hard reset device. |
uint32_t | mpu6050_fifo_pop (ns_i2c_config_t * cfg, uint32_t devAddr, int16_t * value) Pop next value from FIFO. |
uint32_t | mpu6050_get_accel_values (ns_i2c_config_t * cfg, uint32_t devAddr, int16_t * x, int16_t * y, int16_t * z) Get current acceleration values. |
uint32_t | mpu6050_get_fifo_count (ns_i2c_config_t * cfg, uint32_t devAddr, uint16_t * count) Get FIFO count. |
uint32_t | mpu6050_get_gyro_values (ns_i2c_config_t * cfg, uint32_t devAddr, int16_t * x, int16_t * y, int16_t * z) Get current gyro values. |
uint32_t | mpu6050_get_interrupt_status (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t * status) Get interrupt status register. |
uint32_t | mpu6050_get_temperature (ns_i2c_config_t * cfg, uint32_t devAddr, int16_t * t) Get current temperature value. |
uint32_t | mpu6050_gyro_fsr_value (const mpu6050_gyro_fs_t range) Gyroscope scale in units dps. |
float | mpu6050_gyro_resolution (const mpu6050_gyro_fs_t range) Gyroscope scale LSB resolution. |
float | mpu6050_gyro_to_deg_per_sec (int val, mpu6050_gyro_fs_t range) Convert gyroscope value to degrees/second. |
uint32_t | mpu6050_init (ns_i2c_config_t * cfg, mpu6050_config_t * c, uint32_t devAddr) |
uint32_t | mpu6050_mean_sensors (ns_i2c_config_t * cfg, uint32_t devAddr, int * meanAX, int * meanAY, int * meanAZ, int * meanGX, int * meanGY, int * meanGZ) Get average sensor values. |
uint32_t | mpu6050_read_sensors (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t * buffer) Reads MPU sensor values (3-axis accel, 1 temp, 3-axis gyro) |
uint32_t | mpu6050_reset_fifo (ns_i2c_config_t * cfg, uint32_t devAddr) Reset FIFO. |
uint32_t | mpu6050_reset_signal_conds (ns_i2c_config_t * cfg, uint32_t devAddr) Reset signal conditions. |
uint32_t | mpu6050_reset_signal_paths (ns_i2c_config_t * cfg, uint32_t devAddr) Reset signal paths. |
uint32_t | mpu6050_set_accel_full_scale (ns_i2c_config_t * cfg, uint32_t devAddr, mpu6050_accel_fs_t fsr) Set accel full scale range. |
uint32_t | mpu6050_set_accel_offset (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t axis, int offset) Set acceleration offset for axis. |
uint32_t | mpu6050_set_clock_source (ns_i2c_config_t * cfg, uint32_t devAddr, mpu6050_clock_src_t sel) Set clock source. |
uint32_t | mpu6050_set_fifo_enable (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t enable) Enable FIFO. |
uint32_t | mpu6050_set_gyro_full_scale (ns_i2c_config_t * cfg, uint32_t devAddr, mpu6050_gyro_fs_t fsr) Set gyro full scale range. |
uint32_t | mpu6050_set_gyro_offset (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t axis, int offset) Set gyroscope offset for axis. |
uint32_t | mpu6050_set_interrupt_enable (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t overflowEnable, uint8_t dataReadyEnable) Enable/disable interrupts. |
uint32_t | mpu6050_set_lowpass_filter (ns_i2c_config_t * cfg, uint32_t devAddr, mpu6050_dlpf_cfg_t value) Set digital lowpass filter. |
uint32_t | mpu6050_set_lowpower_accel_mode (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t wakeFreq) Put device into low-power acceleration-only mode. |
uint32_t | mpu6050_set_sample_rate (ns_i2c_config_t * cfg, uint32_t devAddr, uint16_t rate) Set target sample rate. |
uint32_t | mpu6050_set_sample_rate_divider (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t divider) Set sample rate divider. |
uint32_t | mpu6050_set_sleep (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t sleep) Enable/disable sleep mode. |
uint32_t | mpu6050_set_temperature_disable (ns_i2c_config_t * cfg, uint32_t devAddr, uint8_t disable) Disable temperature readings. |
float | mpu6050_temperature_to_celsius (int16_t val) Convert temperature value to Celsius. |
uint32_t | mpu6050_test_connection (ns_i2c_config_t * cfg, uint32_t devAddr) Verify device by reading WHO_AM_I register. |
Macros
Type | Name |
---|---|
define | MPU_I2CADDRESS_AD0_HIGH 0x69 |
define | MPU_I2CADDRESS_AD0_LOW 0x68 |
Public Types Documentation
enum mpu6050_accel_fs_t
enum mpu6050_accel_fs_t {
ACCEL_FS_2G = 0,
ACCEL_FS_4G = 1,
ACCEL_FS_8G = 2,
ACCEL_FS_16G = 3
};
Accel full-scale range
enum mpu6050_clock_src_t
enum mpu6050_clock_src_t {
CLOCK_INTERNAL = 0,
CLOCK_GX_PLL = 1,
CLOCK_GY_PLL = 2,
CLOCK_GZ_PLL = 3,
CLOCK_32_REF = 4,
CLOCK_19_REF = 5,
CLOCK_KEEP_RESET = 7
};
Clock selection
enum mpu6050_dlpf_cfg_t
enum mpu6050_dlpf_cfg_t {
DLPF_260HZ = 0,
DLPF_184HZ = 1,
DLPF_094HZ = 2,
DLPF_044HZ = 3,
DLPF_021HZ = 4,
DLPF_010HZ = 5,
DLPF_005HZ = 6
};
enum mpu6050_gyro_fs_t
enum mpu6050_gyro_fs_t {
GYRO_FS_250DPS = 0,
GYRO_FS_500DPS = 1,
GYRO_FS_1000DPS = 2,
GYRO_FS_2000DPS = 3
};
Gyroscope full-scale range
enum mpu6050_status_e
enum mpu6050_status_e {
MPU6050_STATUS_SUCCESS = 0,
MPU6050_STATUS_ERROR = 1
};
Public Functions Documentation
function mpu6050_accel_fsr_value
Acceleration scale in units of G.
uint32_t mpu6050_accel_fsr_value (
mpu6050_accel_fs_t range
)
Parameters:
range
Full scale range selection
Returns:
uint32_t Scale in G
function mpu6050_accel_resolution
Acceleration scale LSB resolution.
float mpu6050_accel_resolution (
mpu6050_accel_fs_t range
)
Parameters:
range
Full scale range selection
Returns:
float Resolution (G)
function mpu6050_accel_to_gravity
Convert acceleration value to G.
float mpu6050_accel_to_gravity (
int16_t val,
mpu6050_accel_fs_t range
)
Parameters:
val
Accel register valuerange
Full-scale range used
Returns:
Acceleration (G)
function mpu6050_calibrate
Calibrate device offsets. Device must be still on a flat surface.
uint32_t mpu6050_calibrate (
ns_i2c_config_t * cfg,
uint32_t devAddr
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C address
Returns:
uint32_t status
Calibrate device offsets. Device must be still on a flat surface.
Parameters:
cfg
I2C configurationdevAddr
Device I2C address
Returns:
uint32_t status
function mpu6050_configure_fifo
Configure FIFO.
uint32_t mpu6050_configure_fifo (
ns_i2c_config_t * cfg,
uint32_t devAddr,
mpu6050_fifo_config_t * fifoConfig
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressfifoConfig
FIFO configuration
Returns:
uint32_t status
function mpu6050_configure_interrupt
Configure interrupts.
uint32_t mpu6050_configure_interrupt (
ns_i2c_config_t * cfg,
uint32_t devAddr,
mpu6050_int_config_t * intConfig
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressintConfig
Interrupt configuration
Returns:
uint32_t status
function mpu6050_device_reset
Hard reset device.
uint32_t mpu6050_device_reset (
ns_i2c_config_t * cfg,
uint32_t devAddr
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C address
Returns:
uint32_t status
function mpu6050_fifo_pop
Pop next value from FIFO.
uint32_t mpu6050_fifo_pop (
ns_i2c_config_t * cfg,
uint32_t devAddr,
int16_t * value
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressvalue
Pointer to FIFO value
Returns:
uint32_t status
function mpu6050_get_accel_values
Get current acceleration values.
uint32_t mpu6050_get_accel_values (
ns_i2c_config_t * cfg,
uint32_t devAddr,
int16_t * x,
int16_t * y,
int16_t * z
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressx
Pointer to store x axisy
Pointer to store y axisz
Pointer to store z axis
Returns:
uint32_t status
function mpu6050_get_fifo_count
Get FIFO count.
uint32_t mpu6050_get_fifo_count (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint16_t * count
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addresscount
Pointer to store count
Returns:
uint32_t status
function mpu6050_get_gyro_values
Get current gyro values.
uint32_t mpu6050_get_gyro_values (
ns_i2c_config_t * cfg,
uint32_t devAddr,
int16_t * x,
int16_t * y,
int16_t * z
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressx
Pointer to store x axisy
Pointer to store y axisz
Pointer to store z axis
Returns:
uint32_t status
function mpu6050_get_interrupt_status
Get interrupt status register.
uint32_t mpu6050_get_interrupt_status (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t * status
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressstatus
Pointer to store status register
Returns:
uint32_t
function mpu6050_get_temperature
Get current temperature value.
uint32_t mpu6050_get_temperature (
ns_i2c_config_t * cfg,
uint32_t devAddr,
int16_t * t
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addresst
Pointer to store Temperature
Returns:
uint32_t status
function mpu6050_gyro_fsr_value
Gyroscope scale in units dps.
uint32_t mpu6050_gyro_fsr_value (
const mpu6050_gyro_fs_t range
)
Parameters:
range
Full scale range selection
Returns:
uint32_t Scale (°/s)
function mpu6050_gyro_resolution
Gyroscope scale LSB resolution.
float mpu6050_gyro_resolution (
const mpu6050_gyro_fs_t range
)
Parameters:
range
Full scale range selection
Returns:
float Resolution (°/s)
function mpu6050_gyro_to_deg_per_sec
Convert gyroscope value to degrees/second.
float mpu6050_gyro_to_deg_per_sec (
int val,
mpu6050_gyro_fs_t range
)
Parameters:
val
Gyroscope register valuerange
Full-scale range used
Returns:
float Gyroscope (°/s)
function mpu6050_init
uint32_t mpu6050_init (
ns_i2c_config_t * cfg,
mpu6050_config_t * c,
uint32_t devAddr
)
function mpu6050_mean_sensors
Get average sensor values.
uint32_t mpu6050_mean_sensors (
ns_i2c_config_t * cfg,
uint32_t devAddr,
int * meanAX,
int * meanAY,
int * meanAZ,
int * meanGX,
int * meanGY,
int * meanGZ
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressmeanAX
Pointer to store mean X accelmeanAY
Pointer to store mean Y accelmeanAZ
Pointer to store mean Z accelmeanGX
Pointer to store mean X gyromeanGY
Pointer to store mean Y gyromeanGZ
Pointer to store mean Z gyro
Returns:
uint32_t status
function mpu6050_read_sensors
Reads MPU sensor values (3-axis accel, 1 temp, 3-axis gyro)
uint32_t mpu6050_read_sensors (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t * buffer
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressbuffer
14-byte buffer to store values
Returns:
uint32_t status
function mpu6050_reset_fifo
Reset FIFO.
uint32_t mpu6050_reset_fifo (
ns_i2c_config_t * cfg,
uint32_t devAddr
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C address
Returns:
uint32_t
function mpu6050_reset_signal_conds
Reset signal conditions.
uint32_t mpu6050_reset_signal_conds (
ns_i2c_config_t * cfg,
uint32_t devAddr
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C address
Returns:
uint32_t status
function mpu6050_reset_signal_paths
Reset signal paths.
uint32_t mpu6050_reset_signal_paths (
ns_i2c_config_t * cfg,
uint32_t devAddr
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C address
Returns:
uint32_t status
function mpu6050_set_accel_full_scale
Set accel full scale range.
uint32_t mpu6050_set_accel_full_scale (
ns_i2c_config_t * cfg,
uint32_t devAddr,
mpu6050_accel_fs_t fsr
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressfsr
Full scale range selection
Returns:
uint32_t
function mpu6050_set_accel_offset
Set acceleration offset for axis.
uint32_t mpu6050_set_accel_offset (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t axis,
int offset
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressaxis
x=0, y=1, z=2offset
Offset value
Returns:
uint32_t status
function mpu6050_set_clock_source
Set clock source.
uint32_t mpu6050_set_clock_source (
ns_i2c_config_t * cfg,
uint32_t devAddr,
mpu6050_clock_src_t sel
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addresssel
Clock selection
Returns:
uint32_t status
function mpu6050_set_fifo_enable
Enable FIFO.
uint32_t mpu6050_set_fifo_enable (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t enable
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressenable
Enable FIFO flag
Returns:
uint32_t status
function mpu6050_set_gyro_full_scale
Set gyro full scale range.
uint32_t mpu6050_set_gyro_full_scale (
ns_i2c_config_t * cfg,
uint32_t devAddr,
mpu6050_gyro_fs_t fsr
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressfsr
Full scale range selection
Returns:
uint32_t status
function mpu6050_set_gyro_offset
Set gyroscope offset for axis.
uint32_t mpu6050_set_gyro_offset (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t axis,
int offset
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressaxis
x=0, y=1, z=2offset
Offset value
Returns:
uint32_t status
function mpu6050_set_interrupt_enable
Enable/disable interrupts.
uint32_t mpu6050_set_interrupt_enable (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t overflowEnable,
uint8_t dataReadyEnable
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressoverflowEnable
Overflow triggers interruptdataReadyEnable
Data ready triggers interrupt
Returns:
uint32_t status
function mpu6050_set_lowpass_filter
Set digital lowpass filter.
uint32_t mpu6050_set_lowpass_filter (
ns_i2c_config_t * cfg,
uint32_t devAddr,
mpu6050_dlpf_cfg_t value
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressvalue
Filter selection
Returns:
uint32_t status
function mpu6050_set_lowpower_accel_mode
Put device into low-power acceleration-only mode.
uint32_t mpu6050_set_lowpower_accel_mode (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t wakeFreq
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addresswakeFreq
Wake-up frequency 0=1.25Hz, 1=5Hz 2=20Hz 3=40Hz
Returns:
uint32_t status
function mpu6050_set_sample_rate
Set target sample rate.
uint32_t mpu6050_set_sample_rate (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint16_t rate
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressrate
Target rate in Hz
Returns:
uint32_t status
function mpu6050_set_sample_rate_divider
Set sample rate divider.
uint32_t mpu6050_set_sample_rate_divider (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t divider
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressdivider
Sample rate divider
Returns:
uint32_t status
function mpu6050_set_sleep
Enable/disable sleep mode.
uint32_t mpu6050_set_sleep (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t sleep
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addresssleep
Sleep flag
Returns:
uint32_t status
function mpu6050_set_temperature_disable
Disable temperature readings.
uint32_t mpu6050_set_temperature_disable (
ns_i2c_config_t * cfg,
uint32_t devAddr,
uint8_t disable
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C addressdisable
Disable temperature flag
Returns:
uint32_t status
function mpu6050_temperature_to_celsius
Convert temperature value to Celsius.
float mpu6050_temperature_to_celsius (
int16_t val
)
Parameters:
val
Temperature register
Returns:
float Temperature (°C)
function mpu6050_test_connection
Verify device by reading WHO_AM_I register.
uint32_t mpu6050_test_connection (
ns_i2c_config_t * cfg,
uint32_t devAddr
)
Parameters:
cfg
I2C configurationdevAddr
Device I2C address
Returns:
uint32_t status
Macro Definition Documentation
define MPU_I2CADDRESS_AD0_HIGH
#define MPU_I2CADDRESS_AD0_HIGH 0x69
define MPU_I2CADDRESS_AD0_LOW
#define MPU_I2CADDRESS_AD0_LOW 0x68