LibDriver MPU9250
Loading...
Searching...
No Matches
mpu9250 magnetometer driver function

mpu9250 magnetometer driver modules More...

Collaboration diagram for mpu9250 magnetometer driver function:

Enumerations

enum  mpu9250_magnetometer_status1_t { MPU9250_MAGNETOMETER_STATUS1_DRDY = (1 << 0) , MPU9250_MAGNETOMETER_STATUS1_DOR = (1 << 1) }
 mpu9250 magnetometer status1 enumeration definition More...
enum  mpu9250_magnetometer_status2_t { MPU9250_MAGNETOMETER_STATUS2_HOFL = (1 << 3) , MPU9250_MAGNETOMETER_STATUS2_BITM = (1 << 4) }
 mpu9250 magnetometer status2 enumeration definition More...
enum  mpu9250_magnetometer_mode_t {
  MPU9250_MAGNETOMETER_MODE_POWER_DOWN = 0x00 , MPU9250_MAGNETOMETER_MODE_SINGLE = 0x01 , MPU9250_MAGNETOMETER_MODE_CONTINUOUS1 = 0x02 , MPU9250_MAGNETOMETER_MODE_CONTINUOUS2 = 0x06 ,
  MPU9250_MAGNETOMETER_MODE_EXT_TRIGGER = 0x04 , MPU9250_MAGNETOMETER_MODE_SELF_TEST = 0x08 , MPU9250_MAGNETOMETER_MODE_FUSE_ROM = 0x0F
}
 mpu9250 magnetometer mode enumeration definition More...
enum  mpu9250_magnetometer_bits_t { MPU9250_MAGNETOMETER_BITS_14 = 0x00 , MPU9250_MAGNETOMETER_BITS_16 = 0x01 }
 mpu9250 magnetometer bits enumeration definition More...

Functions

uint8_t mpu9250_mag_init (mpu9250_handle_t *handle)
 initialize the magnetometer of mpu9250
uint8_t mpu9250_mag_deinit (mpu9250_handle_t *handle)
 magnetometer deinit
uint8_t mpu9250_mag_read (mpu9250_handle_t *handle, int16_t mag_raw[3], float mag_ut[3])
 mag read the data
uint8_t mpu9250_mag_get_info (mpu9250_handle_t *handle, uint8_t *info)
 magnetometer get the information
uint8_t mpu9250_mag_get_status1 (mpu9250_handle_t *handle, uint8_t *status)
 magnetometer get the status1
uint8_t mpu9250_mag_get_status2 (mpu9250_handle_t *handle, uint8_t *status)
 magnetometer get the status2
uint8_t mpu9250_mag_set_mode (mpu9250_handle_t *handle, mpu9250_magnetometer_mode_t mode)
 magnetometer set the mode
uint8_t mpu9250_mag_get_mode (mpu9250_handle_t *handle, mpu9250_magnetometer_mode_t *mode)
 magnetometer get the mode
uint8_t mpu9250_mag_set_bits (mpu9250_handle_t *handle, mpu9250_magnetometer_bits_t bits)
 magnetometer set the bits
uint8_t mpu9250_mag_get_bits (mpu9250_handle_t *handle, mpu9250_magnetometer_bits_t *bits)
 magnetometer get the bits
uint8_t mpu9250_mag_set_reset (mpu9250_handle_t *handle, mpu9250_bool_t enable)
 magnetometer enable or disable reset
uint8_t mpu9250_mag_get_reset (mpu9250_handle_t *handle, mpu9250_bool_t *enable)
 magnetometer get the reset status
uint8_t mpu9250_mag_set_self_test (mpu9250_handle_t *handle, mpu9250_bool_t enable)
 magnetometer enable or disable self test
uint8_t mpu9250_mag_get_self_test (mpu9250_handle_t *handle, mpu9250_bool_t *enable)
 magnetometer get the self test status
uint8_t mpu9250_mag_iic_disable (mpu9250_handle_t *handle)
 magnetometer disable the iic
uint8_t mpu9250_mag_get_asa (mpu9250_handle_t *handle, uint8_t asa[3])
 magnetometer get the asa data
uint8_t mpu9250_mag_set_fifo_mode (mpu9250_handle_t *handle)
 magnetometer set into fifo mode

Detailed Description

mpu9250 magnetometer driver modules

Enumeration Type Documentation

◆ mpu9250_magnetometer_bits_t

mpu9250 magnetometer bits enumeration definition

Enumerator
MPU9250_MAGNETOMETER_BITS_14 

14 bits output

MPU9250_MAGNETOMETER_BITS_16 

16 bits output

Definition at line 425 of file driver_mpu9250.h.

◆ mpu9250_magnetometer_mode_t

mpu9250 magnetometer mode enumeration definition

Enumerator
MPU9250_MAGNETOMETER_MODE_POWER_DOWN 

power down mode

MPU9250_MAGNETOMETER_MODE_SINGLE 

single measurement mode

MPU9250_MAGNETOMETER_MODE_CONTINUOUS1 

continuous measurement mode 1

MPU9250_MAGNETOMETER_MODE_CONTINUOUS2 

continuous measurement mode 2

MPU9250_MAGNETOMETER_MODE_EXT_TRIGGER 

external trigger measurement mode

MPU9250_MAGNETOMETER_MODE_SELF_TEST 

self test mode

MPU9250_MAGNETOMETER_MODE_FUSE_ROM 

fuse rom access mode

Definition at line 411 of file driver_mpu9250.h.

◆ mpu9250_magnetometer_status1_t

mpu9250 magnetometer status1 enumeration definition

Enumerator
MPU9250_MAGNETOMETER_STATUS1_DRDY 

data is ready

MPU9250_MAGNETOMETER_STATUS1_DOR 

data overrun

Definition at line 393 of file driver_mpu9250.h.

◆ mpu9250_magnetometer_status2_t

mpu9250 magnetometer status2 enumeration definition

Enumerator
MPU9250_MAGNETOMETER_STATUS2_HOFL 

magnetic sensor overflow occurred

MPU9250_MAGNETOMETER_STATUS2_BITM 

0: 14bits / 1: 16bits

Definition at line 402 of file driver_mpu9250.h.

Function Documentation

◆ mpu9250_mag_deinit()

uint8_t mpu9250_mag_deinit ( mpu9250_handle_t * handle)

magnetometer deinit

Parameters
[in]*handlepointer to an mpu9250 handle structure
Returns
status code
  • 0 success
  • 1 mag deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 4893 of file driver_mpu9250.c.

◆ mpu9250_mag_get_asa()

uint8_t mpu9250_mag_get_asa ( mpu9250_handle_t * handle,
uint8_t asa[3] )

magnetometer get the asa data

Parameters
[in]*handlepointer to an mpu9250 handle structure
[out]*asapointer to an asa buffer
Returns
status code
  • 0 success
  • 1 mag get asa failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5612 of file driver_mpu9250.c.

◆ mpu9250_mag_get_bits()

uint8_t mpu9250_mag_get_bits ( mpu9250_handle_t * handle,
mpu9250_magnetometer_bits_t * bits )

magnetometer get the bits

Parameters
[in]*handlepointer to an mpu9250 handle structure
[out]*bitspointer to a magnetometer bits buffer
Returns
status code
  • 0 success
  • 1 mag get bits failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5333 of file driver_mpu9250.c.

◆ mpu9250_mag_get_info()

uint8_t mpu9250_mag_get_info ( mpu9250_handle_t * handle,
uint8_t * info )

magnetometer get the information

Parameters
[in]*handlepointer to an mpu9250 handle structure
[out]*infopointer to an info buffer
Returns
status code
  • 0 success
  • 1 mag get info failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5059 of file driver_mpu9250.c.

◆ mpu9250_mag_get_mode()

uint8_t mpu9250_mag_get_mode ( mpu9250_handle_t * handle,
mpu9250_magnetometer_mode_t * mode )

magnetometer get the mode

Parameters
[in]*handlepointer to an mpu9250 handle structure
[out]*modepointer to a magnetometer mode buffer
Returns
status code
  • 0 success
  • 1 mag get mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5237 of file driver_mpu9250.c.

◆ mpu9250_mag_get_reset()

uint8_t mpu9250_mag_get_reset ( mpu9250_handle_t * handle,
mpu9250_bool_t * enable )

magnetometer get the reset status

Parameters
[in]*handlepointer to an mpu9250 handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 mag get reset failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5429 of file driver_mpu9250.c.

◆ mpu9250_mag_get_self_test()

uint8_t mpu9250_mag_get_self_test ( mpu9250_handle_t * handle,
mpu9250_bool_t * enable )

magnetometer get the self test status

Parameters
[in]*handlepointer to an mpu9250 handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 mag get self test failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5525 of file driver_mpu9250.c.

◆ mpu9250_mag_get_status1()

uint8_t mpu9250_mag_get_status1 ( mpu9250_handle_t * handle,
uint8_t * status )

magnetometer get the status1

Parameters
[in]*handlepointer to an mpu9250 handle structure
[out]*statuspointer to a status1 buffer
Returns
status code
  • 0 success
  • 1 mag get status1 failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5101 of file driver_mpu9250.c.

◆ mpu9250_mag_get_status2()

uint8_t mpu9250_mag_get_status2 ( mpu9250_handle_t * handle,
uint8_t * status )

magnetometer get the status2

Parameters
[in]*handlepointer to an mpu9250 handle structure
[out]*statuspointer to a status2 buffer
Returns
status code
  • 0 success
  • 1 mag get status2 failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5143 of file driver_mpu9250.c.

◆ mpu9250_mag_iic_disable()

uint8_t mpu9250_mag_iic_disable ( mpu9250_handle_t * handle)

magnetometer disable the iic

Parameters
[in]*handlepointer to an mpu9250 handle structure
Returns
status code
  • 0 success
  • 1 mag iic disable failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5568 of file driver_mpu9250.c.

◆ mpu9250_mag_init()

uint8_t mpu9250_mag_init ( mpu9250_handle_t * handle)

initialize the magnetometer of mpu9250

Parameters
[in]*handlepointer to an mpu9250 handle structure
Returns
status code
  • 0 success
  • 1 mag init failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 reset failed
  • 5 mag id is invalid
  • 6 spi don't support
Note
none

Definition at line 4741 of file driver_mpu9250.c.

◆ mpu9250_mag_read()

uint8_t mpu9250_mag_read ( mpu9250_handle_t * handle,
int16_t mag_raw[3],
float mag_ut[3] )

mag read the data

Parameters
[in]*handlepointer to an mpu9250 handle structure
[out]*mag_rawpointer to a mag raw data buffer
[out]*mag_utpointer to a converted mag data buffer
Returns
status code
  • 0 success
  • 1 mag read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 4994 of file driver_mpu9250.c.

◆ mpu9250_mag_set_bits()

uint8_t mpu9250_mag_set_bits ( mpu9250_handle_t * handle,
mpu9250_magnetometer_bits_t bits )

magnetometer set the bits

Parameters
[in]*handlepointer to an mpu9250 handle structure
[in]bitsmagnetometer bits
Returns
status code
  • 0 success
  • 1 mag set bits failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5281 of file driver_mpu9250.c.

◆ mpu9250_mag_set_fifo_mode()

uint8_t mpu9250_mag_set_fifo_mode ( mpu9250_handle_t * handle)

magnetometer set into fifo mode

Parameters
[in]*handlepointer to an mpu9250 handle structure
Returns
status code
  • 0 success
  • 1 mag set fifo mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
fifo mode will use slave 0

Definition at line 5653 of file driver_mpu9250.c.

◆ mpu9250_mag_set_mode()

uint8_t mpu9250_mag_set_mode ( mpu9250_handle_t * handle,
mpu9250_magnetometer_mode_t mode )

magnetometer set the mode

Parameters
[in]*handlepointer to an mpu9250 handle structure
[in]modemagnetometer mode
Returns
status code
  • 0 success
  • 1 mag set mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5185 of file driver_mpu9250.c.

◆ mpu9250_mag_set_reset()

uint8_t mpu9250_mag_set_reset ( mpu9250_handle_t * handle,
mpu9250_bool_t enable )

magnetometer enable or disable reset

Parameters
[in]*handlepointer to an mpu9250 handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 mag set reset failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5377 of file driver_mpu9250.c.

◆ mpu9250_mag_set_self_test()

uint8_t mpu9250_mag_set_self_test ( mpu9250_handle_t * handle,
mpu9250_bool_t enable )

magnetometer enable or disable self test

Parameters
[in]*handlepointer to an mpu9250 handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 mag set self test failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 mag is not inited
Note
none

Definition at line 5473 of file driver_mpu9250.c.