0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

加速度传感器QMA6100P的使用

恒泰瑞科技有限公司 2023-09-22 08:34 次阅读

本文聊聊上海矽睿产的加速度传感器QMA6100P的使用。

1、特性

高集成,小尺寸封装:2 x 2 x 0.95 mm LGA
14位数模转化,低噪声 ·
具有标准模式和快速模式,支持I2C和SPI接口
内置self-test
大范围操作电压1.7V-3.6V,与低功耗2~50μA
集成64位FIFO存贮器,符合RoHS标准,无卤素添加
内置运动算法 ,尤其是硬件计步算法
可在-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、数据寄存器c7d650ca-58df-11ee-9788-92fbcf53809c.png

通过这6个寄存器可以读出三轴数据。

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、读取数据

c853ecec-58df-11ee-9788-92fbcf53809c.png
本测试中读取了x,y,z三轴的值,并计算出了g的值。

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 传感器
    +关注

    关注

    2550

    文章

    51035

    浏览量

    753083
  • 寄存器
    +关注

    关注

    31

    文章

    5336

    浏览量

    120232
  • 加速度传感器

    关注

    12

    文章

    471

    浏览量

    55140
收藏 人收藏

    评论

    相关推荐

    ZC1202速度传感器温度传感器视觉传感器加速度传感器的作用

    速度传感器、温度传感器、视觉传感器加速度传感器在各自的应用领域中发挥着不可替代的作用,为现代工
    的头像 发表于 10-11 15:11 291次阅读

    加速度传感器的应用

    加速度传感器是一种能够测量加速度传感器。通常由质量块、阻尼、弹性元件、敏感元件和适调电路等部分组成。
    的头像 发表于 09-30 08:08 682次阅读
    <b class='flag-5'>加速度</b><b class='flag-5'>传感器</b>的应用

    物联网系统中加速度测试方案的实现_加速度传感器分析

    01 物联网系统中为什么要使用加速度传感器 在物联网系统中,使用加速度传感器的原因主要基于加速度传感器
    的头像 发表于 09-26 14:19 472次阅读
    物联网系统中<b class='flag-5'>加速度</b>测试方案的实现_<b class='flag-5'>加速度</b><b class='flag-5'>传感器</b>分析

    国产士兰微MEMS三轴加速度传感器的多元应用场景

    国产士兰微SC7A20H三轴加速度传感器
    的头像 发表于 08-08 14:39 1119次阅读

    PT32L007F8P7K&amp; QMA6100P IIC 通讯源代码分享

       qma6100p   ******************************************************************************   * @attention
    的头像 发表于 06-07 09:53 846次阅读
    PT32L007F8<b class='flag-5'>P</b>7K&amp; <b class='flag-5'>QMA6100P</b> IIC 通讯源代码分享

    LIS2DE12加速度传感器能否保存数据一次获取?当读取xyz轴加速度时获得的是当前实时加速度吗?

    LIS2DE12加速度传感器能否保存数据一次获取,当读取xyz轴加速度时获得的是当前实时加速度吗?
    发表于 04-02 06:53

    加速度传感器的基本力学模型是什么

    加速度传感器的基本力学模型是一个受力物体的运动学和动力学模型的组合。本文将从以下几个方面介绍加速度传感器的基本力学模型。 一、运动学模型 加速度
    的头像 发表于 01-17 11:08 1364次阅读

    加速度传感器常用的有哪两种

    加速度传感器常用的有两种,一种是基于压电效应的压电式加速度传感器,另一种是基于微机电系统(MEMS)技术的微型加速度
    的头像 发表于 01-15 15:27 1024次阅读

    加速度传感器属于什么类型传感器

    加速度传感器属于惯性传感器类型的传感器。惯性传感器主要通过测量物体运动状态中的加速度
    的头像 发表于 01-12 11:12 936次阅读

    加速度传感器原理及其应用

    常见的加速度传感器工作原理有三种:压电原理、电容原理和微机电系统(MEMS)原理。 1.压电原理:压电加速度传感器通过压电材料的压电效应来测量加速度
    的头像 发表于 01-05 08:39 1743次阅读
    <b class='flag-5'>加速度</b><b class='flag-5'>传感器</b>原理及其应用

    压阻式加速度传感器的主要作用

    压阻式加速度传感器的主要作用  压阻式加速度传感器是一种广泛应用于工业、汽车、医疗和消费电子等领域的传感器。它能够实时测量物体的
    的头像 发表于 01-03 15:59 930次阅读

    加速度传感器的噪声密度的单位是ug/sqrt Hz,赫兹前面为什么带根号?

    1.加速度传感器的噪声密度的单位是ug/sqrt Hz,赫兹前面为什么带根号?这个值有什么意义?(仅仅是定义了分辨率么?) 2.以ADXL203为例,它的噪声密度典型值是110ug/sqrt Hz
    发表于 01-01 08:08

    ADXL103 CE加速度传感器能否测竖直方向的振动?

    ADXL 103 CE 加速度传感器能否测竖直方向的振动?该款传感器标着测试方向是水平面内的X或Y轴,我发现竖直放置使用时,零g偏移电平在3.5V,这样能可以正常使用吗?影响测量精度吗?是否有z方向的单轴
    发表于 01-01 06:56

    请问加速度传感器的带宽与数据刷新率有什么关系吗?

    请问加速度传感器的带宽与数据刷新率有什么关系没? 譬如说ADXL316资料说明Z轴带宽为500Hz,那Z轴的数据刷新率为多少?
    发表于 12-28 07:54

    请问ADXL354加速度传感器的最小加速度测量值或是说分辨率是多少?

    请问ADXL354加速度传感器的最小加速度测量值或是说分辨率是多少,在说明书中没有看见,感谢。
    发表于 12-27 06:48