本帖最后由 DavidZH 于 2019-8-10 23:09 编辑
今天解析LSM6DSO, 接口I模拟IIC, 驱动还是按照原来的, 验证读ID:
uint8_t LSM6DSO_Read_Date(uint8_t SlaveAddress, uint8_t RegAddress)
{
uint8_t recvDate;
uint8_t succ, stime=0;
I2C_Start();
succ = I2C_Send_Byte(SlaveAddress & 0xfe);
while((succ !=1)&&(stime<3))
{
I2C_Stop();
I2C_Start();
succ = I2C_Send_Byte(SlaveAddress & 0xfe); //写
stime++;
}
I2C_Send_Byte(RegAddress);
I2C_Start();
I2C_Send_Byte(SlaveAddress | 0x01); //读
recvDate = I2C_Read_Byte(1); //NACK
I2C_Stop();
return recvDate;
}
printf("PID_LSM = %X\r\n",LPS22HH_Read_Date(LSM6DSO_ADD, 0x0F));
寄存器文件:
LSM6DSO-master.zip
(49.84 KB, 下载次数: 10)
此内容由EEWORLD论坛网友DavidZH原创,如需转载或用于商业用途需征得作者同意并注明出处