0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內(nèi)不再提示

加速度傳感器QMA6100P的使用

恒泰瑞科技有限公司 ? 2023-09-22 08:34 ? 次閱讀

本文聊聊上海矽睿產(chǎn)的加速度傳感器QMA6100P的使用。

1、特性

高集成,小尺寸封裝:2 x 2 x 0.95 mm LGA
14位數(shù)模轉(zhuǎn)化,低噪聲 ·
具有標準模式和快速模式,支持I2C和SPI接口
內(nèi)置self-test
大范圍操作電壓1.7V-3.6V,與低功耗2~50μA
集成64位FIFO存貯器,符合RoHS標準,無鹵素添加
內(nèi)置運動算法 ,尤其是硬件計步算法
可在-40°C~85°C的溫度中工作

2、引腳說明

c76e13a2-58df-11ee-9788-92fbcf53809c.png
可以看出提供了兩個外部中斷引腳,支持SPI或I2C通信。

3、I2C讀寫地址

c78b2f0a-58df-11ee-9788-92fbcf53809c.png

4、部分寄存器

4.1、設備ID寄存器

c79edd84-58df-11ee-9788-92fbcf53809c.png
可以通過讀這個寄存器判斷設備是否存在,默認是0x90。

4.2、軟復位寄存器c7b4ec00-58df-11ee-9788-92fbcf53809c.png

4.3、數(shù)據(jù)寄存器c7d650ca-58df-11ee-9788-92fbcf53809c.png

通過這6個寄存器可以讀出三軸數(shù)據(jù)。

4.4、量程寄存器

c7ef9864-58df-11ee-9788-92fbcf53809c.png
通過這個寄存器設置測量范圍。

4.5、帶寬寄存器

c800e86c-58df-11ee-9788-92fbcf53809c.png

4.6、電源管理寄存器

c8202b28-58df-11ee-9788-92fbcf53809c.png

5、原理圖設計

c83ef0c6-58df-11ee-9788-92fbcf53809c.png

6、代碼

本文使用軟硬件I2C與QMA6100P通訊,通過宏切換。

void I2cInit(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
I2C_InitTypeDef I2C_InitStructure;


RCC_I2CCLKConfig(RCC_I2C1CLK_SYSCLK);

RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2, ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF , ENABLE);
/* Connect PXx to I2C_SCL*/
GPIO_PinAFConfig(GPIOF, GPIO_PinSource6, GPIO_AF_1);
/* Connect PXx to I2C_SDA*/
GPIO_PinAFConfig(GPIOF, GPIO_PinSource7, GPIO_AF_1);


/* GPIO configuration */
/* Configure sEE_I2C pins: SCL */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOF, &GPIO_InitStructure);

/* Configure sEE_I2C pins: SDA */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_Init(GPIOF, &GPIO_InitStructure);


I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
I2C_InitStructure.I2C_AnalogFilter = I2C_AnalogFilter_Enable;
I2C_InitStructure.I2C_DigitalFilter = 0x00;
I2C_InitStructure.I2C_OwnAddress1 = 0x00;
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I2C_InitStructure.I2C_Timing = 0x40B22536;//0x20D22E37;// 0x02105070; //0x40B22536//100k, 0x10950C27; //400kHz
I2C_Init(I2C2, &I2C_InitStructure);

/* Apply sEE_I2C configuration after enabling it */
I2C_Init(I2C2, &I2C_InitStructure);

/* sEE_I2C Peripheral Enable */
I2C_Cmd(I2C2, ENABLE);
}

void I2cWrite(uint8_t reg,uint8_t var)
{
/* While the bus is busy */
while(I2C_GetFlagStatus(I2C2, I2C_FLAG_BUSY) != RESET){};

/* Send Touch address for write */
I2C_TransferHandling(I2C2, (SLAVE_ADDR<<1), 1, I2C_Reload_Mode, I2C_Generate_Start_Write);

while(I2C_GetFlagStatus(I2C2, I2C_FLAG_TXIS )==RESET){}; // I2C_FLAG_TXE

I2C_SendData(I2C2, reg);

while(I2C_GetFlagStatus(I2C2, I2C_FLAG_TCR) == RESET){};

I2C_TransferHandling(I2C2, (SLAVE_ADDR<<1), 1, I2C_AutoEnd_Mode, I2C_No_StartStop);

/* Test on EV8 and clear it */
while (I2C_GetFlagStatus(I2C2, I2C_FLAG_TXIS) == RESET){}; //I2C_FLAG_TXIS
/* Send the current byte */
I2C_SendData(I2C2, var);

/* Send STOP condition */
while(I2C_GetFlagStatus(I2C2, I2C_FLAG_STOPF) == RESET){};
}


uint8_t I2cRead(uint8_t reg)
{
uint8_t ret=0;

/* While the bus is busy */
while(I2C_GetFlagStatus(I2C2, I2C_FLAG_BUSY) != RESET){};

/* Generate start & wait event detection */
I2C_TransferHandling(I2C2, (SLAVE_ADDR<<1), 1, I2C_SoftEnd_Mode, I2C_Generate_Start_Write);

while(I2C_GetFlagStatus(I2C2, I2C_FLAG_TXIS ) == RESET){}; //I2C_FLAG_TXIS

I2C_SendData(I2C2, reg);

while (I2C_GetFlagStatus(I2C2, I2C_FLAG_TC) == RESET){};

/* Send STRAT condition a second time */
I2C_TransferHandling(I2C2, (SLAVE_ADDR<<1), 1, I2C_AutoEnd_Mode, I2C_Generate_Start_Read);

while(I2C_GetFlagStatus(I2C2, I2C_FLAG_RXNE) == RESET){};

/* Read a byte from the EEPROM */
ret = I2C_ReceiveData(I2C2);

/* Enable Acknowledgement to be ready for another reception */
while(I2C_GetFlagStatus(I2C2, I2C_FLAG_STOPF) == RESET){};

return ret;
}

#define _SCL_PORT GPIOF
#define _SCL_PIN GPIO_Pin_6

#define _SDA_PORT GPIOF
#define _SDA_PIN GPIO_Pin_7

void _I2cInit(void)
{
/* sEE_I2C_SCL_GPIO_CLK and sEE_I2C_SDA_GPIO_CLK Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF , ENABLE);
/* sEE_I2C Periph clock enable */

GPIO_InitTypeDef GPIO_InitStructure;

/* GPIO configuration */
/* Configure sEE_I2C pins: SCL */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOF, &GPIO_InitStructure);

/* Configure sEE_I2C pins: SDA */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_Init(GPIOF, &GPIO_InitStructure);
}


void _SDA_IN(void)
{
GPIO_InitTypeDef GPIO_InitStructure;

/* GPIO configuration */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOF, &GPIO_InitStructure);
}


void _SDA_OUT(void)
{
GPIO_InitTypeDef GPIO_InitStructure;

/* GPIO configuration */
/* Configure sEE_I2C pins: SCL */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOF, &GPIO_InitStructure);
}

void _I2C_Start(void)
{
_SDA_OUT();
GPIO_SetBits(_SDA_PORT,_SDA_PIN); //SDA=1
DelayUs(10);
GPIO_SetBits(_SCL_PORT,_SCL_PIN); //SCL=1
DelayUs(10);
GPIO_ResetBits(_SDA_PORT,_SDA_PIN);//SDA=0
DelayUs(10);
GPIO_ResetBits(_SCL_PORT,_SCL_PIN);//SCL=0
DelayUs(10);
}

void _I2C_Stop(void)
{
_SDA_OUT();

GPIO_ResetBits(_SDA_PORT,_SDA_PIN);//SDA=0
DelayUs(10);
GPIO_SetBits(_SCL_PORT,_SCL_PIN); //SCL=1
DelayUs(10);
GPIO_SetBits(_SDA_PORT,_SDA_PIN); //SDA=1
DelayUs(10);
}


void _I2C_Ack(void)
{
_SDA_OUT();
GPIO_ResetBits(_SDA_PORT,_SDA_PIN);//SDA=0
DelayUs(5);
GPIO_SetBits(_SCL_PORT,_SCL_PIN); //SCL=1
DelayUs(5);
GPIO_ResetBits(_SCL_PORT,_SCL_PIN); //SCL=0
}


void _I2C_NAck(void)
{
GPIO_SetBits(_SDA_PORT,_SDA_PIN); //SDA=1
DelayUs(10);
GPIO_SetBits(_SCL_PORT,_SCL_PIN); //SCL=1
DelayUs(10);
GPIO_ResetBits(_SCL_PORT,_SCL_PIN); //SCL=0
DelayUs(10);
}


uint8_t _I2C_Wait_Ack(void)
{
uint8_t ucErrTime=0;

#if 0
SDA_IN();
GPIO_SetBits(_SDA_PORT,_SDA_PIN); //釋放總線
#else
GPIO_SetBits(_SDA_PORT,_SDA_PIN); //釋放總線
_SDA_IN();
#endif

DelayUs(5);
GPIO_SetBits(_SCL_PORT,_SCL_PIN); //SCL=1
DelayUs(5);
while(GPIO_ReadInputDataBit(_SDA_PORT,_SDA_PIN))
{
ucErrTime++;
if(ucErrTime>250)
{
_I2C_Stop();
return 1;
}
}
GPIO_ResetBits(_SCL_PORT,_SCL_PIN); //SCL=0
DelayUs(5);
return 0;
}


uint8_t _I2C_Read_Byte(uint8_t ack)
{
uint8_t i,rxdata=0;

#if 0
_SDA_IN();
GPIO_SetBits(_SDA_PORT,_SDA_PIN); //釋放總線
#else
GPIO_SetBits(_SDA_PORT,_SDA_PIN); //釋放總線
_SDA_IN();
#endif

for(i=0;i<8;i++ )
{
GPIO_ResetBits(_SCL_PORT,_SCL_PIN); //SCL=0
DelayUs(5);
GPIO_SetBits(_SCL_PORT,_SCL_PIN); //SCL=1
DelayUs(5);
rxdata<<=1;
if(GPIO_ReadInputDataBit(_SDA_PORT,_SDA_PIN))
{
rxdata|=0x01;
}
DelayUs(5);
}
if (!ack)
_I2C_NAck();//nACK
else
_I2C_Ack(); //ACK

return rxdata;
}

void _I2C_Send_Byte(uint8_t txd)
{
uint8_t i;

_SDA_OUT();
GPIO_ResetBits(_SCL_PORT,_SCL_PIN); //SCL=0

for(i=0;i<8;i++)
{
if((txd&0x80)==0x80)
GPIO_SetBits(_SDA_PORT,_SDA_PIN);
else
GPIO_ResetBits(_SDA_PORT,_SDA_PIN);

txd<<=1;
DelayUs(5);
GPIO_SetBits(_SCL_PORT,_SCL_PIN); //SCL=1
DelayUs(5);
GPIO_ResetBits(_SCL_PORT,_SCL_PIN); //SCL=0
DelayUs(5);
}
}


void _WriteByteReg(uint8_t addr,uint8_t reg,uint8_t data)
{
_I2C_Start();
_I2C_Send_Byte(addr); //write addr
_I2C_Wait_Ack();
_I2C_Send_Byte(reg);
_I2C_Wait_Ack();
_I2C_Send_Byte(data);
_I2C_Wait_Ack();
_I2C_Stop();
}


uint8_t _ReadByteReg(uint8_t addr,uint8_t reg)
{
uint8_t data;

_I2C_Start();
_I2C_Send_Byte(addr); //write addr
_I2C_Wait_Ack();
_I2C_Send_Byte(reg);
_I2C_Wait_Ack();

_I2C_Start();
_I2C_Send_Byte(addr+1); //read addr
_I2C_Wait_Ack();
data=_I2C_Read_Byte(0); //no ack
_I2C_Stop();

return data;
}

void _WriteRegU8(uint8_t reg,uint8_t data)
{
_I2C_Start();
_I2C_Send_Byte(SLAVE_ADDR<<1|0x00); //write addr
_I2C_Wait_Ack();
_I2C_Send_Byte(reg);
_I2C_Wait_Ack();
_I2C_Send_Byte(data);
_I2C_Wait_Ack();
_I2C_Stop();
}


uint8_t _ReadRegU8(uint8_t reg)
{
uint8_t data;

_I2C_Start();
_I2C_Send_Byte(SLAVE_ADDR<<1|0x00); //write addr
_I2C_Wait_Ack();
_I2C_Send_Byte(reg);
_I2C_Wait_Ack();

_I2C_Start();
_I2C_Send_Byte(SLAVE_ADDR<<1|0x01); //read addr
_I2C_Wait_Ack();
data=_I2C_Read_Byte(0); //no ack
_I2C_Stop();

return data;
}

#if 1
#define GsensorRead I2cRead
#define GsensorWrite I2cWrite
#define GsensorIoInit I2cInit
#else
#define GsensorRead _ReadRegU8
#define GsensorWrite _WriteRegU8
#define GsensorIoInit _I2cInit
#endif

void QMA6100PCheck(void)
{
uint8_t chip_id=0;

chip_id=GsensorRead(QMA6100P_REG_CHIP_ID);

log_debug ("chip id=%d\r\n",chip_id);

if(chip_id==0x90)
{
log_debug("device exist\r\n");
}
else
{
log_debug("device not exist\r\n");
}
}

void QMA6100PInit(void)
{
GsensorIoInit();

QMA6100PCheck();

GsensorWrite(QMA6100P_REG_RESET, 0xb6);
DelayMs(5);
GsensorWrite(QMA6100P_REG_RESET, 0x00);
DelayMs(10);

GsensorWrite(0x11, 0x80);
GsensorWrite(0x11, 0x84);
GsensorWrite(0x4a, 0x20);
GsensorWrite(0x56, 0x01);
GsensorWrite(0x5f, 0x80);
DelayMs(2);
GsensorWrite(0x5f, 0x00);
DelayMs(10);

GsensorWrite(QMA6100P_REG_RANGE,QMA6100P_RANGE_8G);
GsensorWrite(QMA6100P_REG_BW_ODR,QMA6100P_BW_100);
GsensorWrite(QMA6100P_REG_POWER_MANAGE,QMA6100P_MCLK_51_2K|0x80);

qma6100p_hand_raise_down(3, QMA6100P_MAP_INT1, 1);

GsensorWrite(0x21, 0x03);// default 0x1c, step latch mode
}


void QMA6100PReadRawData(QMA6100PRawData_t *rawdata)
{
int16_t temp=0;

temp=GsensorRead(QMA6100P_REG_XOUTL)+(GsensorRead(QMA6100P_REG_XOUTH)<<8);
rawdata->acc_x=temp>>2;

temp=GsensorRead(QMA6100P_REG_YOUTL)+(GsensorRead(QMA6100P_REG_YOUTH)<<8);
rawdata->acc_y=temp>>2;

temp=GsensorRead(QMA6100P_REG_ZOUTL)+(GsensorRead(QMA6100P_REG_ZOUTH)<<8);
rawdata->acc_z=temp>>2;
}

void QMA6100PPolling(void)
{
static uint32_t curtick=0;

float angle_x,angle_y,angle_z;

if(SystemGetTick()-curtick>=200)
{
QMA6100PRawData_t rawdata;
float x ,y,z,g;

QMA6100PReadRawData(&rawdata);

x=rawdata.acc_x*QMA6100P_SENSITITY_8G/1000.0;
y=rawdata.acc_y*QMA6100P_SENSITITY_8G/1000.0;
z=rawdata.acc_z*QMA6100P_SENSITITY_8G/1000.0;

g=sqrt(x*x+y*y+z*z);

log_debug("%f, %f, %f, %f\r\n",x,y,z,g);

curtick=SystemGetTick();
}
}

#define SLAVE_ADDR QMA6100P_ADDRESS

#define QMA6100P_ADDRESS 0x12

#define QMA6100P_DEVICE_ID0x90

#define QMA6100P_REG_CHIP_ID 0x00

#define QMA6100P_REG_XOUTL0x01
#define QMA6100P_REG_XOUTH0x02
#define QMA6100P_REG_YOUTL0x03
#define QMA6100P_REG_YOUTH0x04
#define QMA6100P_REG_ZOUTL0x05
#define QMA6100P_REG_ZOUTH0x06

#define QMA6100P_REG_STEP_CNT_L0x07
#define QMA6100P_REG_STEP_CNT_M0x08
#define QMA6100P_REG_STEP_CNT_H0x0d

#define QMA6100P_REG_INT_STATUS_00x09
#define QMA6100P_REG_INT_STATUS_10x0a
#define QMA6100P_REG_INT_STATUS_20x0b
#define QMA6100P_REG_INT_STATUS_30x0c

#define QMA6100P_REG_FIFO_STATE0x0e

#define QMA6100P_REG_RANGE0x0f

#define QMA6100P_REG_BW_ODR0x10

#define QMA6100P_REG_POWER_MANAGE0x11

#define QMA6100P_REG_STEP_SAMPLE_CNT0x12
#define QMA6100P_REG_STEP_PRECISION0x13
#define QMA6100P_REG_STEP_TIME_LOW0x14
#define QMA6100P_REG_STEP_TIME_UP0x15

#define QMA6100P_REG_INT_EN_00x16
#define QMA6100P_REG_INT_EN_10x17
#define QMA6100P_REG_INT_EN_20x18

#define QMA6100P_REG_INT1_MAP_00x19
#define QMA6100P_REG_INT1_MAP_10x1a
#define QMA6100P_REG_INT2_MAP_00x1b
#define QMA6100P_REG_INT2_MAP_10x1c

#define QMA6100P_REG_INTPIN_CFG0x20

#define QMA6100P_REG_INT_CFG0x21

#define QMA6100P_REG_OS_CUST_X 0x27
#define QMA6100P_REG_OS_CUST_Y0x28
#define QMA6100P_REG_OS_CUST_Z0x29

#define QMA6100P_REG_NVM0x33
#define QMA6100P_REG_RESET0x36


#define QMA6100P_REG_DRDY_BIT0x10// enable 1

#define QMA6100P_REG_AMD_X_BIT0x01
#define QMA6100P_REG_AMD_Y_BIT0x02
#define QMA6100P_REG_AMD_Z_BIT0x04

typedef enum
{
QMA6100P_MAP_INT1,
QMA6100P_MAP_INT2,
QMA6100P_MAP_INT_NONE
}qma6100p_int_map;

typedef enum
{
QMA6100P_BW_100 = 0,
QMA6100P_BW_200 = 1,
QMA6100P_BW_400 = 2,
QMA6100P_BW_800 = 3,
QMA6100P_BW_1600 = 4,
QMA6100P_BW_50 = 5,
QMA6100P_BW_25 = 6,
QMA6100P_BW_12_5 = 7,
QMA6100P_BW_OTHER = 8
}qma6100p_bw;

typedef enum
{
QMA6100P_RANGE_2G = 0x01,
QMA6100P_RANGE_4G = 0x02,
QMA6100P_RANGE_8G = 0x04,
QMA6100P_RANGE_16G = 0x08,
QMA6100P_RANGE_32G = 0x0f
}qma6100p_range;

typedef enum
{
QMA6100P_LPF_OFF = (0x00<<5),
QMA6100P_LPF_1 = (0x04<<5),
QMA6100P_LPF_2 = (0x01<<5),
QMA6100P_LPF_4 = (0x02<<5),
QMA6100P_LPF_8 = (0x03<<5),
QMA6100P_LPF_RESERVED = 0xff
}qma6100p_nlpf;

typedef enum
{
QMA6100P_HPF_DIV_OFF = (0x00<<5),
QMA6100P_HPF_DIV_10 = (0x01<<5),
QMA6100P_HPF_DIV_25 = (0x02<<5),
QMA6100P_HPF_DIV_50 = (0x03<<5),
QMA6100P_HPF_DIV_100 = (0x04<<5),
QMA6100P_HPF_DIV_200 = (0x05<<5),
QMA6100P_HPF_DIV_400 = (0x06<<5),
QMA6100P_HPF_DIV_800 = (0x07<<5),
QMA6100P_HPF_RESERVED = 0xff
}qma6100p_nhpf;

typedef enum
{
QMA6100P_MODE_STANDBY = 0,
QMA6100P_MODE_ACTIVE = 1,
QMA6100P_MODE_MAX
}qma6100p_mode;

typedef enum
{
QMA6100P_MCLK_102_4K = 0x03,
QMA6100P_MCLK_51_2K = 0x04,
QMA6100P_MCLK_25_6K = 0x05,
QMA6100P_MCLK_12_8K = 0x06,
QMA6100P_MCLK_6_4K = 0x07,
QMA6100P_MCLK_RESERVED = 0xff
}qma6100p_mclk;

typedef enum
{
QMA6100P_STEP_LPF_0 = (0x00<<6),
QMA6100P_STEP_LPF_2 = (0x01<<6),
QMA6100P_STEP_LPF_4 = (0x02<<6),
QMA6100P_STEP_LPF_8 = (0x03<<6),
QMA6100P_STEP_LPF_RESERVED = 0xff
}qma6100p_step_lpf;

typedef enum
{
QMA6100P_STEP_AXIS_ALL = 0x00,
QMA6100P_STEP_AXIS_YZ = 0x01,
QMA6100P_STEP_AXIS_XZ = 0x02,
QMA6100P_STEP_AXIS_XY = 0x03,
QMA6100P_STEP_AXIS_RESERVED = 0xff
}qma6100p_step_axis;

typedef enum
{
QMA6100P_STEP_START_0 = 0x00,
QMA6100P_STEP_START_4 = 0x20,
QMA6100P_STEP_START_8 = 0x40,
QMA6100P_STEP_START_12 = 0x60,
QMA6100P_STEP_START_16 = 0x80,
QMA6100P_STEP_START_24 = 0xa0,
QMA6100P_STEP_START_32 = 0xc0,
QMA6100P_STEP_START_40 = 0xe0,
QMA6100P_STEP_START_RESERVED = 0xff
}qma6100p_step_start_cnt;

typedef enum
{
QMA6100P_FIFO_MODE_NONE,
QMA6100P_FIFO_MODE_FIFO,
QMA6100P_FIFO_MODE_STREAM,
QMA6100P_FIFO_MODE_BYPASS,
QMA6100P_FIFO_MODE_MAX
}qma6100p_fifo_mode;

typedef enum
{
QMA6100P_TAP_SINGLE = 0x80,
QMA6100P_TAP_DOUBLE = 0x20,
QMA6100P_TAP_TRIPLE = 0x10,
QMA6100P_TAP_QUARTER = 0x01,
QMA6100P_TAP_MAX = 0xff
}qma6100p_tap;

typedef enum
{
QMA6100P_SENSITITY_2G = 244,
QMA6100P_SENSITITY_4G = 488,
QMA6100P_SENSITITY_8G = 977,
QMA6100P_SENSITITY_16G = 1950,
QMA6100P_SENSITITY_32G = 3910
}qma6100p_sensitity;

typedef struct {
int16_t temp;

int16_t acc_x;
int16_t acc_y;
int16_t acc_z;
}QMA6100PRawData_t;

7、讀取數(shù)據(jù)

c853ecec-58df-11ee-9788-92fbcf53809c.png
本測試中讀取了x,y,z三軸的值,并計算出了g的值。

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 傳感器
    +關(guān)注

    關(guān)注

    2541

    文章

    49957

    瀏覽量

    747466
  • 寄存器
    +關(guān)注

    關(guān)注

    31

    文章

    5250

    瀏覽量

    119199
  • 加速度傳感器
    +關(guān)注

    關(guān)注

    12

    文章

    465

    瀏覽量

    55050
收藏 人收藏

    評論

    相關(guān)推薦

    國產(chǎn)士蘭微MEMS三軸加速度傳感器的多元應用場景

    國產(chǎn)士蘭微SC7A20H三軸加速度傳感器
    的頭像 發(fā)表于 08-08 14:39 ?485次閱讀

    PT32L007F8P7K&amp; QMA6100P IIC 通訊源代碼分享

    ? ?qma6100p ? ****************************************************************************** ? * @attention
    的頭像 發(fā)表于 06-07 09:53 ?462次閱讀
    PT32L007F8<b class='flag-5'>P</b>7K&amp; <b class='flag-5'>QMA6100P</b> IIC 通訊源代碼分享

    LIS2DE12加速度傳感器能否保存數(shù)據(jù)一次獲???當讀取xyz軸加速度時獲得的是當前實時加速度嗎?

    LIS2DE12加速度傳感器能否保存數(shù)據(jù)一次獲取,當讀取xyz軸加速度時獲得的是當前實時加速度嗎?
    發(fā)表于 04-02 06:53

    加速度傳感器的基本力學模型是什么

    加速度傳感器的基本力學模型是一個受力物體的運動學和動力學模型的組合。本文將從以下幾個方面介紹加速度傳感器的基本力學模型。 一、運動學模型 加速度
    的頭像 發(fā)表于 01-17 11:08 ?946次閱讀

    加速度傳感器常用的有哪兩種

    加速度傳感器常用的有兩種,一種是基于壓電效應的壓電式加速度傳感器,另一種是基于微機電系統(tǒng)(MEMS)技術(shù)的微型加速度
    的頭像 發(fā)表于 01-15 15:27 ?739次閱讀

    加速度傳感器屬于什么類型傳感器

    加速度傳感器屬于慣性傳感器類型的傳感器。慣性傳感器主要通過測量物體運動狀態(tài)中的加速度、
    的頭像 發(fā)表于 01-12 11:12 ?710次閱讀

    加速度傳感器原理及其應用

    常見的加速度傳感器工作原理有三種:壓電原理、電容原理和微機電系統(tǒng)(MEMS)原理。 1.壓電原理:壓電加速度傳感器通過壓電材料的壓電效應來測量加速度
    的頭像 發(fā)表于 01-05 08:39 ?1365次閱讀
    <b class='flag-5'>加速度</b><b class='flag-5'>傳感器</b>原理及其應用

    壓阻式加速度傳感器的主要作用

    壓阻式加速度傳感器的主要作用? 壓阻式加速度傳感器是一種廣泛應用于工業(yè)、汽車、醫(yī)療和消費電子等領域的傳感器。它能夠?qū)崟r測量物體的
    的頭像 發(fā)表于 01-03 15:59 ?680次閱讀

    ADXL103 CE加速度傳感器能否測豎直方向的振動?

    ADXL 103 CE 加速度傳感器能否測豎直方向的振動?該款傳感器標著測試方向是水平面內(nèi)的X或Y軸,我發(fā)現(xiàn)豎直放置使用時,零g偏移電平在3.5V,這樣能可以正常使用嗎?影響測量精度嗎?是否有z方向的單軸
    發(fā)表于 01-01 06:56

    請問ADXL354加速度傳感器的最小加速度測量值或是說分辨率是多少?

    請問ADXL354加速度傳感器的最小加速度測量值或是說分辨率是多少,在說明書中沒有看見,感謝。
    發(fā)表于 12-27 06:48

    三軸加速度傳感器在跌倒檢測中應用說明

    電子發(fā)燒友網(wǎng)站提供《三軸加速度傳感器在跌倒檢測中應用說明.pdf》資料免費下載
    發(fā)表于 11-22 14:27 ?6次下載
    三軸<b class='flag-5'>加速度</b><b class='flag-5'>傳感器</b>在跌倒檢測中應用說明

    可以通過角速度傳感器來獲得角加速度嗎?

    我想讓單片機實現(xiàn)接受角加速度傳感器的信息,并且將獲得的信息進?行函數(shù)運算,我想知道有角加速度傳感器嗎?我查了一下有角速度傳?感
    發(fā)表于 11-09 08:21

    陀螺儀傳感器加速度傳感器的區(qū)別

    加速度傳感器則是測量物體加速度傳感器,其工作原理基于牛頓第二定律,即物體的加速度與所受力成正比。加速度
    的頭像 發(fā)表于 10-22 10:58 ?1396次閱讀

    陀螺儀傳感器加速度傳感器的區(qū)別

    隨著現(xiàn)代科技的飛速發(fā)展,傳感器技術(shù)在各個領域中得到了廣泛的應用。在移動設備、航空航天、汽車、工業(yè)自動化等領域,陀螺儀傳感器加速度傳感器作為兩種常見的慣性
    的頭像 發(fā)表于 10-05 10:49 ?3239次閱讀

    QMA8658A 6軸加速度傳感器概述和主要特點

    QMA8658A 是一款功能強大的6軸加速度傳感器,其內(nèi)置了3軸加速度計和3軸陀螺儀,能夠同時測量三個方向的加速度和角
    發(fā)表于 09-24 14:36 ?635次閱讀
    <b class='flag-5'>QMA</b>8658A 6軸<b class='flag-5'>加速度</b><b class='flag-5'>傳感器</b>概述和主要特點