Inglés | 简体中文 | 繁體中文 | 日本語 | Deutsch | 한국어
MPU9250 es un módulo múltiple (MCM) que consta de dos troqueles integrados en un solo paquete QFN. Un die alberga el giroscopio de 3 ejes y el acelerómetro de 3 ejes. El otro Die alberga el magnetómetro AK8963 de 3 ejes de Asahi Kasei Microdevices Corporation. Hence, the MPU9250 is a 9-axis MotionTracking device that combines a 3-axis gyroscope, 3-axis accelerometer, 3-axis magnetometer and a Digital Motion Processor™ (DMP) all in a small 3x3x1mm package available as a pin-compatible upgrade from the MPU6515.With its dedicated I2C sensor bus, the MPU9250 directly provides complete Salida de 9 ejes MotionFusion ™. El dispositivo MPU9250 MotionTracking, con su firmware de calibración de calibración de tiempo de ejecución de 9 ejes, en Chip MotionFusion ™ y de tiempo de ejecución, permite a los fabricantes eliminar la selección costosa y compleja, la calificación y la integración de nivel de sistema de los sensores discretos, como los sensores de presión óptimo para los consumidores. El puerto I2C.MPU9250 presenta tres convertidores analógicos de 16 bits (ADC) para digitalizar las salidas de giroscopio, tres ADC de 16 bits para digitalizar las salidas del acelerómetro y tres ADC de 16 bits para digitalizar las salidas del magnetómetro. Para el seguimiento de precisión de los movimientos rápidos y lentos, las piezas cuentan con un rango a gran escala de giroscopio programable para el usuario de ± 250, ± 500, ± 1000 y ± 2000 °/SEC (DPS), un rango de escala completa de acelerómetro de acelerómetro programable por el usuario de ± 2G, ± 4G, ± 8G y ± 16g, y un rango de escala completa de magnetómetro de ± 48800.
Libdriver MPU9250 es el controlador de función completa de MPU9250 lanzado por Libdriver. Proporciona lectura de aceleración, lectura de velocidad angular, lectura del magnetómetro, lectura de ángulo de actitud, lectura de DMP, detección de toque y otras funciones. Libdriver cumple con Misra.
/SRC incluye archivos de origen Libdriver MPU9250.
/La interfaz incluye Libdriver MPU9250 IIC, plantilla independiente de la plataforma SPI.
/Prueba incluye el código de prueba del controlador Libdriver MPU9250 y este código puede probar la función necesaria del chip simplemente.
/Ejemplo incluye el código de muestra Libdriver MPU9250.
/Doc incluye el documento fuera de línea Libdriver MPU9250.
/La hoja de datos incluye la hoja de datos MPU9250.
/El proyecto incluye el código de muestra Common Linux y MCU Development Board. Todos los proyectos usan el script de shell para depurar el controlador y la instrucción detallada se puede encontrar en el readMe.md de cada proyecto.
/Misra incluye los resultados de escaneo del código Libdriver Misra.
Referencia /interfaz IIC, plantilla independiente de plataforma SPI y finalizar su plataforma IIC, controlador SPI.
Agregue el directorio /SRC, el controlador de interfaz para su plataforma y sus propios controladores a su proyecto, si desea usar los controladores de ejemplo predeterminados, agregue el directorio /Ejemplo a su proyecto.
Puede consultar los ejemplos en el directorio /ejemplo para completar su propio controlador. Si desea utilizar los ejemplos de programación predeterminados, esto es cómo usarlos.
#include "driver_mpu9250_basic.h"
uint8_t res ;
uint32_t i ;
uint32_t times ;
float g [ 3 ];
float dps [ 3 ];
float ut [ 3 ];
float degrees ;
mpu9250_address_t addr ;
/* init */
addr = MPU9250_ADDRESS_AD0_LOW ;
res = mpu9250_basic_init ( MPU9250_INTERFACE_IIC , addr );
if ( res != 0 )
{
return 1 ;
}
...
/* read all */
times = 3 ;
for ( i = 0 ; i < times ; i ++ )
{
/* read */
if ( mpu9250_basic_read ( g , dps , ut ) != 0 )
{
( void ) mpu9250_basic_deinit ();
return 1 ;
}
...
if ( mpu9250_basic_read_temperature ( & degrees ) != 0 )
{
( void ) mpu9250_basic_deinit ();
return 1 ;
}
...
/* output */
mpu9250_interface_debug_print ( "mpu9250: %d/%d.n" , i + 1 , times );
mpu9250_interface_debug_print ( "mpu9250: acc x is %0.2fg.n" , g [ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: acc y is %0.2fg.n" , g [ 1 ]);
mpu9250_interface_debug_print ( "mpu9250: acc z is %0.2fg.n" , g [ 2 ]);
mpu9250_interface_debug_print ( "mpu9250: gyro x is %0.2fdps.n" , dps [ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: gyro y is %0.2fdps.n" , dps [ 1 ]);
mpu9250_interface_debug_print ( "mpu9250: gyro z is %0.2fdps.n" , dps [ 2 ]);
mpu9250_interface_debug_print ( "mpu9250: mag x is %0.2fuT.n" , ut [ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: mag y is %0.2fuT.n" , ut [ 1 ]);
mpu9250_interface_debug_print ( "mpu9250: mag z is %0.2fuT.n" , ut [ 2 ]);
mpu9250_interface_debug_print ( "mpu9250: temperature %0.2fC.n" , degrees );
...
/* delay 1000 ms */
mpu9250_interface_delay_ms ( 1000 );
...
}
...
/* deinit */
( void ) mpu9250_basic_deinit ();
return 0 ; #include "driver_mpu9250_fifo.h"
uint32_t i ;
uint32_t times ;
uint16_t len ;
uint8_t ( * g_gpio_irq )( void ) = NULL ;
static int16_t gs_accel_raw [ 128 ][ 3 ];
static float gs_accel_g [ 128 ][ 3 ];
static int16_t gs_gyro_raw [ 128 ][ 3 ];
static float gs_gyro_dps [ 128 ][ 3 ];
atic int16_t gs_mag_raw [ 128 ][ 3 ];
static float gs_mag_ut [ 128 ][ 3 ];
mpu9250_address_t addr ;
/* gpio init */
if ( gpio_interrupt_init () != 0 )
{
return 1 ;
}
g_gpio_irq = mpu9250_fifo_irq_handler ;
/* init */
addr = MPU9250_ADDRESS_AD0_LOW ;
if ( mpu9250_fifo_init ( MPU9250_INTERFACE_IIC , addr ) != 0 )
{
g_gpio_irq = NULL ;
( void ) gpio_interrupt_deinit ();
return 1 ;
}
/* delay 100 ms */
mpu9250_interface_delay_ms ( 100 );
...
times = 3 ;
for ( i = 0 ; i < times ; i ++ )
{
len = 128 ;
/* read */
if ( mpu9250_fifo_read ( gs_accel_raw , gs_accel_g ,
gs_gyro_raw , gs_gyro_dps , gs_mag_raw , gs_mag_ut , & len ) != 0 )
{
( void ) mpu9250_fifo_deinit ();
g_gpio_irq = NULL ;
( void ) gpio_interrupt_deinit ();
return 1 ;
}
...
/* output */
mpu9250_interface_debug_print ( "mpu9250: %d/%d.n" , i + 1 , times );
mpu9250_interface_debug_print ( "mpu9250: fifo %d.n" , len );
mpu9250_interface_debug_print ( "mpu9250: acc x[0] is %0.2fg.n" , gs_accel_g [ 0 ][ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: acc y[0] is %0.2fg.n" , gs_accel_g [ 0 ][ 1 ]);
mpu9250_interface_debug_print ( "mpu9250: acc z[0] is %0.2fg.n" , gs_accel_g [ 0 ][ 2 ]);
mpu9250_interface_debug_print ( "mpu9250: gyro x[0] is %0.2fdps.n" , gs_gyro_dps [ 0 ][ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: gyro y[0] is %0.2fdps.n" , gs_gyro_dps [ 0 ][ 1 ]);
mpu9250_interface_debug_print ( "mpu9250: gyro z[0] is %0.2fdps.n" , gs_gyro_dps [ 0 ][ 2 ]);
mpu9250_interface_debug_print ( "mpu9250: mag x[0] is %0.2fuT.n" , gs_mag_ut [ 0 ][ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: mag y[0] is %0.2fuT.n" , gs_mag_ut [ 0 ][ 1 ]);
mpu9250_interface_debug_print ( "mpu9250: mag z[0] is %0.2fuT.n" , gs_mag_ut [ 0 ][ 2 ]);
...
/* delay 100 ms */
mpu9250_interface_delay_ms ( 100 );
...
}
...
/* deinit */
( void ) mpu9250_fifo_deinit ();
g_gpio_irq = NULL ;
( void ) gpio_interrupt_deinit ();
return 0 ; #include "driver_mpu9250_dmp.h"
uint32_t i ;
uint32_t times ;
uint32_t cnt ;
uint16_t len ;
uint8_t ( * g_gpio_irq )( void ) = NULL ;
static int16_t gs_accel_raw [ 128 ][ 3 ];
static float gs_accel_g [ 128 ][ 3 ];
static int16_t gs_gyro_raw [ 128 ][ 3 ];
static float gs_gyro_dps [ 128 ][ 3 ];
static int32_t gs_quat [ 128 ][ 4 ];
static float gs_pitch [ 128 ];
static float gs_roll [ 128 ];
static float gs_yaw [ 128 ];
mpu9250_address_t addr ;
static void a_receive_callback ( uint8_t type )
{
switch ( type )
{
case MPU9250_INTERRUPT_MOTION :
{
mpu9250_interface_debug_print ( "mpu9250: irq motion.n" );
break ;
}
case MPU9250_INTERRUPT_FIFO_OVERFLOW :
{
mpu9250_interface_debug_print ( "mpu9250: irq fifo overflow.n" );
break ;
}
case MPU9250_INTERRUPT_FSYNC_INT :
{
mpu9250_interface_debug_print ( "mpu9250: irq fsync int.n" );
break ;
}
case MPU9250_INTERRUPT_DMP :
{
mpu9250_interface_debug_print ( "mpu9250: irq dmpn" );
break ;
}
case MPU9250_INTERRUPT_DATA_READY :
{
mpu9250_interface_debug_print ( "mpu9250: irq data readyn" );
break ;
}
default :
{
mpu9250_interface_debug_print ( "mpu9250: irq unknown code.n" );
break ;
}
}
}
static void a_dmp_tap_callback ( uint8_t count , uint8_t direction )
{
switch ( direction )
{
case MPU9250_DMP_TAP_X_UP :
{
mpu9250_interface_debug_print ( "mpu9250: tap irq x up with %d.n" , count );
break ;
}
case MPU9250_DMP_TAP_X_DOWN :
{
mpu9250_interface_debug_print ( "mpu9250: tap irq x down with %d.n" , count );
break ;
}
case MPU9250_DMP_TAP_Y_UP :
{
mpu9250_interface_debug_print ( "mpu9250: tap irq y up with %d.n" , count );
break ;
}
case MPU9250_DMP_TAP_Y_DOWN :
{
mpu9250_interface_debug_print ( "mpu9250: tap irq y down with %d.n" , count );
break ;
}
case MPU9250_DMP_TAP_Z_UP :
{
mpu9250_interface_debug_print ( "mpu9250: tap irq z up with %d.n" , count );
break ;
}
case MPU9250_DMP_TAP_Z_DOWN :
{
mpu9250_interface_debug_print ( "mpu9250: tap irq z down with %d.n" , count );
break ;
}
default :
{
mpu9250_interface_debug_print ( "mpu9250: tap irq unknown code.n" );
break ;
}
}
}
static void a_dmp_orient_callback ( uint8_t orientation )
{
switch ( orientation )
{
case MPU9250_DMP_ORIENT_PORTRAIT :
{
mpu9250_interface_debug_print ( "mpu9250: orient irq portrait.n" );
break ;
}
case MPU9250_DMP_ORIENT_LANDSCAPE :
{
mpu9250_interface_debug_print ( "mpu9250: orient irq landscape.n" );
break ;
}
case MPU9250_DMP_ORIENT_REVERSE_PORTRAIT :
{
mpu9250_interface_debug_print ( "mpu9250: orient irq reverse portrait.n" );
break ;
}
case MPU9250_DMP_ORIENT_REVERSE_LANDSCAPE :
{
mpu9250_interface_debug_print ( "mpu9250: orient irq reverse landscape.n" );
break ;
}
default :
{
mpu9250_interface_debug_print ( "mpu9250: orient irq unknown code.n" );
break ;
}
}
}
/* init */
if ( gpio_interrupt_init () != 0 )
{
return 1 ;
}
g_gpio_irq = mpu9250_dmp_irq_handler ;
/* init */
addr = MPU9250_ADDRESS_AD0_LOW ;
if ( mpu9250_dmp_init ( MPU9250_INTERFACE_IIC , addr , a_receive_callback ,
a_dmp_tap_callback , a_dmp_orient_callback ) != 0 )
{
g_gpio_irq = NULL ;
( void ) gpio_interrupt_deinit ();
return 1 ;
}
/* delay 500 ms */
mpu9250_interface_delay_ms ( 500 );
...
times = 3 ;
for ( i = 0 ; i < times ; i ++ )
{
len = 128 ;
/* read */
if ( mpu9250_dmp_read_all ( gs_accel_raw , gs_accel_g ,
gs_gyro_raw , gs_gyro_dps ,
gs_quat ,
gs_pitch , gs_roll , gs_yaw ,
& len ) != 0 )
{
( void ) mpu9250_dmp_deinit ();
g_gpio_irq = NULL ;
( void ) gpio_interrupt_deinit ();
return 1 ;
}
/* output */
mpu9250_interface_debug_print ( "mpu9250: %d/%d.n" , i + 1 , times );
mpu9250_interface_debug_print ( "mpu9250: fifo %d.n" , len );
mpu9250_interface_debug_print ( "mpu9250: pitch[0] is %0.2fdeg.n" , gs_pitch [ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: roll[0] is %0.2fdeg.n" , gs_roll [ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: yaw[0] is %0.2fdeg.n" , gs_yaw [ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: acc x[0] is %0.2fg.n" , gs_accel_g [ 0 ][ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: acc y[0] is %0.2fg.n" , gs_accel_g [ 0 ][ 1 ]);
mpu9250_interface_debug_print ( "mpu9250: acc z[0] is %0.2fg.n" , gs_accel_g [ 0 ][ 2 ]);
mpu9250_interface_debug_print ( "mpu9250: gyro x[0] is %0.2fdps.n" , gs_gyro_dps [ 0 ][ 0 ]);
mpu9250_interface_debug_print ( "mpu9250: gyro y[0] is %0.2fdps.n" , gs_gyro_dps [ 0 ][ 1 ]);
mpu9250_interface_debug_print ( "mpu9250: gyro z[0] is %0.2fdps.n" , gs_gyro_dps [ 0 ][ 2 ]);
/* delay 500 ms */
mpu9250_interface_delay_ms ( 500 );
....
/* get the pedometer step count */
res = mpu9250_dmp_get_pedometer_counter ( & cnt );
if ( res != 0 )
{
( void ) mpu9250_dmp_deinit ();
g_gpio_irq = NULL ;
( void ) gpio_interrupt_deinit ();
return 1 ;
}
...
}
...
/* deinit */
( void ) mpu9250_dmp_deinit ();
g_gpio_irq = NULL ;
( void ) gpio_interrupt_deinit ();
return 0 ;Documentos en línea: https://www.libdriver.com/docs/mpu9250/index.html.
Documentos fuera de línea: /doc/html/index.html.
Consulte la contribución. MD.
Copyright (c) 2015 - Presente Libdriver Todos los derechos reservados
La licencia del MIT (MIT)
Por la presente, se otorga el permiso, de forma gratuita, a cualquier persona que obtenga una copia
de este software y archivos de documentación asociados (el "software"), para tratar
en el software sin restricción, incluidos los derechos de los derechos
para usar, copiar, modificar, fusionar, publicar, distribuir, sublicense y/o vender
copias del software y para permitir a las personas a quienes es el software
proporcionado para hacerlo, sujeto a las siguientes condiciones:
El aviso de derechos de autor anterior y este aviso de permiso se incluirán en todos
copias o porciones sustanciales del software.
El software se proporciona "tal cual", sin garantía de ningún tipo, expreso o
Implícito, incluidos, entre otros, las garantías de comerciabilidad,
Fitness para un propósito particular y no infracción. En ningún caso el
Los autores o los titulares de derechos de autor seré responsable de cualquier reclamo, daños u otros
Responsabilidad, ya sea en una acción de contrato, agravio o de otra manera, derivada de,
Fuera o en relación con el software o el uso u otros tratos en el
SOFTWARE.
Envíe un correo electrónico a [email protected].