//////////////////////////////////////////////////////////////////////////// ///@copyright Copyright (c) 2017, 传控科技 All rights reserved. ///------------------------------------------------------------------------- /// @file msa300.c /// @brief msa300 driver app ///------------------------------------------------------------------------- /// @version 1.0 /// @author CC /// @date 20170122 /// @note cc_AS_stc01 ////////////////////////////////////////////////////////////////////////////// /******************************************************************************/ /***************************** Include Files **********************************/ /******************************************************************************/ #include "msa300.h" struct _s_gsens_ s_as1,s_as2; void L1_msa300_init(void) { /// 上电后是standby 模式 需要设置 L2_I2C_WriteCmd(D_i2c_addr_AS1,0x11,0x1e); // 进入normal 模式 L2_I2C_WriteCmd(D_i2c_addr_AS2,0x11,0x1e); // 进入normal 模式 } void L1_as1_readXYZ(void) { ///read data //S ADD W A REG A //S ADD R A D1 A D2 A.....DX N P L2_I2C_ReadReg(D_i2c_addr_AS1,0x02,(unsigned char *)&s_as1,6); // L2_I2C_ReadReg(D_i2c_addr_AS2,0,(unsigned char *)&s_as2,3); } void L1_as2_readXYZ(void) { ///read data //S ADD W A REG A //S ADD R A D1 A D2 A.....DX N P L2_I2C_ReadReg(D_i2c_addr_AS2,0x02,(unsigned char *)&s_as2,6); } #if 0 L2_I2C_ReadReg(D_i2c_addr_HP303B,0x0d,d,1); L0_MUART_uc(d[0]); L2_I2C_ReadReg(D_i2c_addr_AS1,0x05,d,1);// 11 =0f L0_MUART_uc(d[0]); L2_I2C_ReadReg(D_i2c_addr_AS2,0x05,d,1);//10 =0f L0_MUART_uc(d[0]); L1_as1_readXYZ(); s_p_rf.ucR1 = (U8)(s_as1.x>>8); s_p_rf.ucR2 = (U8)(s_as1.y>>8); s_p_rf.ucR3 = (U8)(s_as1.z>>8); p = (U8*)&s_p_rf; L0_MUART_uc(s_p_rf.ucR1); L0_MUART_uc(s_p_rf.ucR2); L0_MUART_uc(s_p_rf.ucR3); L0_MUART_uc(0xc7); #endif