英語| 簡體中文| 繁體中文| 日本語|德意志| 한국어
MPU9250是一個多芯片模塊(MCM),該模塊由兩個模具組成,該模塊集成到單個QFN軟件包中。一個模具容納3軸陀螺儀和3軸加速度計。另一個模具容納了Asahi Kasei Microdevices Corporation的AK8963 3軸磁力計。因此,MPU9250是一種9軸運動跟踪設備,結合了3軸陀螺儀,3軸加速度計,3軸磁力計和數字運動處理器(DMP),所有這些都可以在小型3x3x1mm套件中以PIN型的固定式升級為單位。 9軸MotionFusion™輸出。 MPU9250運動跟踪設備,其9軸集成,芯片運動融合™和運行時校準固件,使製造商能夠消除離散設備的昂貴且複雜的選擇,資格和系統水平集成,並為消費者提供最佳運動性能,以供多個ITS互動的INS互動,以供多個固定的Interial Interformer.mpu9250,以下port.MPU9250具有三個16位類似物對數字轉換器(ADC),用於數字化陀螺儀輸出,三個16位ADC用於數字化加速度計輸出和三個16位ADC,用於數字化磁力計輸出。為了精確跟踪快速和緩慢的運動,該部分具有用戶可編程的全尺度範圍±250,±500,±1000和±2000°/sec(dps),用戶可編程的加速度計的全尺度範圍為±2G,±4G,±4G,±8G和±8G和±8G和±8G和±8G和±8G和±8G和±8G和一個範圍。
Libdriver MPU9250是Libdriver推出的MPU9250的完整功能驅動程序。它提供加速度讀數,角速度讀數,磁力計讀數,態度角度讀數,DMP讀數,TAP檢測和其他功能。 Libdriver符合Misra的規定。
/src包括libdriver mpu9250源文件。
/接口包括Libdriver MPU9250 IIC,SPI平台獨立模板。
/測試包括Libdriver MPU9250驅動程序測試代碼,此代碼可以簡單地測試芯片必要的功能。
/示例包括Libdriver MPU9250示例代碼。
/DOC包括Libdriver MPU9250離線文檔。
/數據表包括MPU9250數據表。
/項目包括通用Linux和MCU開發委員會樣本代碼。所有項目都使用Shell腳本來調試驅動程序,並且可以在每個項目的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。
請參考貢獻。
版權(c)2015年 - 目前的libdriver保留所有權利
麻省理工學院許可證(MIT)
特此免費授予任何獲得副本的人的許可
該軟件和相關文檔文件(“軟件”)
在軟件中無限制的軟件中,包括無限制的權利
使用,複製,修改,合併,發布,分發,轉銷和/或出售
軟件的副本,並允許軟件的人
符合以下條件的規定,可以這樣做:
上述版權通知和此許可通知應包含
該軟件的副本或大量部分。
該軟件是“原樣”提供的,沒有任何形式的保證,明確或
暗示,包括但不限於適銷性保證,
適合特定目的和非侵擾的適合度。在任何情況下都不會
作者或版權持有人應對任何索賠,損害賠償或其他責任負責
責任,無論是在合同,侵權的訴訟中還是其他責任,是由
與軟件或使用或與使用或其他交易有關
軟體.
請發送電子郵件至[email protected]。