完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
最近使用了stm的lsm9ds1这个九轴触感器,各个数据都读出,现在给大家分享下磁力计这部分代码,顺便问一下,磁力计这样配置对不对,file:///C:UsersdellAppDataRoamingTencentUsers1531886062QQWinTempRichOle6_JBF]PVFTOIK~0I4ADD9I5.pngCTRL_REG1_M (20h),这个此存器该怎么配置?void config_mag_default(){
unsigned char buffer[2]; int wait; //CTRL_REG1_M buffer[0] = 0x20; //10hz buffer[1] = 0x30; // 0b00110000 datasheet i2cWrite(SAD_M_0, buffer, sizeof(buffer), I2C_STD); for(wait = 0; wait < 1000000; wait++){;} // Wait before doing another operation //CTRL_REG2_M buffer[0] = 0x21; // buffer[1] = 0x00; // table 112 113 114 ----4g i2cWrite(SAD_M_0, buffer, sizeof(buffer), I2C_STD); for(wait = 0; wait < 1000000; wait++){;} // Wait before doing another operation //CTRL_REG3_M buffer[0] = 0x22; // 0b00000000 -----Continuous-conversion mode buffer[1] = 0x00; // table 115 116 117 i2cWrite(SAD_M_0, buffer, sizeof(buffer), I2C_STD); for(wait = 0; wait < 1000000; wait++){;} // Wait before doing another operation //CTRL_REG4_M buffer[0] = 0x23; // 0b00001000 buffer[1] = 0x04; // table 118 119 120 i2cWrite(SAD_M_0, buffer, sizeof(buffer), I2C_STD); for(wait = 0; wait < 1000000; wait++){;} // Wait before doing another operation } void get_sensor_data_M(char address, int data, int *output){ // output[0] = x | output[1] = y | output[2] = z unsigned char buffer[6] = {0}; // each value has 2 byter (3 values x 2 byter = 6 bytes) unsigned char buffer1[1] = {0}; address = SAD_M_0; data = 0x28; buffer1[0] = data; i2cWrite(SAD_M_0,buffer1, 1, I2C_STD); // sequentially reads 6 registers i2cRead(SAD_M_0, buffer, 6, I2C_STD); output[0] = (buffer[1] << 8) | buffer[0]; // merge the 2 bytes in a single value, e.g. (OUT_X_H_G << 8) | OUT_X_L_G output[1] = (buffer[3] << 8) | buffer[2]; // xxx_x_H_x contains the most significant bytes and xxx_x_L_x contains the least significant bytes output[2] = (buffer[5] << 8) | buffer[4]; } |
|
相关推荐
3个回答
|
|
楼主弄好了吗 我新买了个板子 也有这个 还没弄呢
|
|
|
|
你弄出来了吗 我也在弄这个 可不可以留个联系方式交流一下
|
|
|
|
楼主可以留个联系方式吗
|
|
|
|
只有小组成员才能发言,加入小组>>
请问下图大疆lightbridge2遥控器主板电源芯片型号是什么?
4445 浏览 1 评论
使用常见的二极管、三极管和mos做MCU和模组的电平转换电路,但是模组和MCU无法正常通信,为什么?
322浏览 2评论
为了提高USIM卡电路的可靠性和稳定性,在电路设计中须注意的点有哪些?
311浏览 2评论
328浏览 2评论
329浏览 2评论
367浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-30 20:46 , Processed in 0.711539 second(s), Total 51, Slave 45 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号