영어 | 简体中文 | 繁體中文 | 日本語 | 도이치치 | 한국어
MPU9250은 단일 QFN 패키지에 통합 된 2 개의 다이로 구성된 멀티 치프 모듈 (MCM)입니다. 하나의 다이에는 3 축 자이로 스코프와 3 축 가속도계가 있습니다. 다른 다이에는 Asahi Kasei Microdevices Corporation의 AK8963 3 축 자력계가 있습니다. 따라서 MPU9250은 3 축 자이로 스코프, 3 축 자력계 및 디지털 모션 프로세서 ™ (DMP)을 결합하여 MPU6515에서 직접 완료된 I2C 센서 버스에서 PIN 대용량 업그레이드를 제공하는 작은 3x3x1mm 패키지를 결합한 9 축 모션 트래킹 장치입니다. MotionFusion ™ 출력. MPU9250 모션 트래킹 장치는 9 축 통합, 온 칩 모션 퓨전 ™ 및 런타임 캘리브레이션 펌웨어를 사용하여 제조업체가 비용이 많이 들고 복잡한 선택, 자격 및 시스템 수준의 이산 장치의 시스템 수준 통합을 제거 할 수 있으며 소비자에 대한 최적의 모션 성능을 보장 할 수 있습니다. PORT.MPU9250은 자이로 스코프 출력을 디지털화하기위한 3 개의 16 비트 아날로그-디지털 변환기 (ADC), 가속도계 출력을 디지털화하기위한 3 개의 16 비트 ADC 및 자기 계산기를 디지털화하기위한 3 개의 16 비트 ADC를 갖추고 있습니다. 빠르고 느린 동작의 정밀 추적을 위해,이 부품은 ± 250, ± 500, ± 1000, ± 2000 °/sec (DPS)의 사용자 프로그래밍 가능한 자이로 스코프 전체 범위의 ± 2G, ± 4G, ± 8G 및 ± 40의 ± 40의 ± 16G 범위를 특징으로합니다.
Libdriver MPU9250은 Libdriver가 시작한 MPU9250의 전체 기능 드라이버입니다. 가속도 읽기, 각속도 읽기, 자력계 읽기, 태도 각도 읽기, DMP 읽기, 탭 감지 및 기타 기능을 제공합니다. Libdriver는 Misra를 준수합니다.
/src에는 libdriver mpu9250 소스 파일이 포함됩니다.
/인터페이스에는 libdriver mpu9250 IIC, SPI 플랫폼 독립 템플릿이 포함됩니다.
/테스트에는 Libdriver MPU9250 드라이버 테스트 코드가 포함 되며이 코드는 필요한 기능을 간단히 테스트 할 수 있습니다.
/예제에는 libdriver mpu9250 샘플 코드가 포함됩니다.
/doc에는 libdriver mpu9250 오프라인 문서가 포함되어 있습니다.
/데이터 시트에는 MPU9250 데이터 시트가 포함되어 있습니다.
/프로젝트에는 공통 Linux 및 MCU 개발 보드 샘플 코드가 포함됩니다. 모든 프로젝트는 쉘 스크립트를 사용하여 드라이버를 디버깅하고 각 프로젝트의 readme.md에서 세부 명령을 찾을 수 있습니다.
/misra에는 libdriver misra 코드 스캔 결과가 포함되어 있습니다.
참조 /인터페이스 IIC, SPI 플랫폼 독립 템플릿 및 플랫폼 IIC, SPI 드라이버를 완료합니다.
/SRC 디렉토리, 플랫폼의 인터페이스 드라이버 및 자신의 드라이버를 프로젝트에 추가하십시오. 기본 예제 드라이버를 사용하려면 /예제 디렉토리를 프로젝트에 추가하십시오.
/예제 디렉토리의 예제를 참조하여 자신의 드라이버를 완료 할 수 있습니다. 기본 프로그래밍 예제를 사용하려면 사용 방법은 다음과 같습니다.
#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 ;온라인 문서 : https://www.libdriver.com/docs/mpu9250/index.html.
오프라인 문서 : /doc/html/index.html.
Contributing.md를 참조하십시오.
Copyright (C) 2015- 현재 Libdriver 판권 소유
MIT 라이센스 (MIT)
이에 따라 사본을 얻는 사람에게 무료로 허가가 부여됩니다.
이 소프트웨어 및 관련 문서 파일 ( "소프트웨어")의
권리를 포함하여 제한이없는 소프트웨어에서
사용, 복사, 수정, 병합, 출판, 배포, 하선 및/또는 판매
소프트웨어 사본 및 소프트웨어가있는 사람을 허용하기 위해
다음 조건에 따라이를 위해 제공됩니다.
위의 저작권 통지 및이 권한 통지는 모두에 포함되어야합니다.
소프트웨어의 사본 또는 상당 부분.
소프트웨어는 어떤 종류의 보증없이 "있는 그대로"제공됩니다.
상업성의 보증을 포함하되 이에 국한되지 않는 암시,
특정 목적과 비방을위한 적합성. 어떠한 경우에도
저자 또는 저작권 보유자는 청구, 손해 또는 기타에 대해 책임을집니다.
계약, 불법 행위 또는 다른 방법으로,
소프트웨어 또는 사용 또는 기타 거래와 관련하여
소프트웨어.
[email protected]으로 이메일을 보내주십시오.