Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API mbed-src nRF51822
EM7180.h
00001 #ifndef EM7180_H 00002 #define EM7180_H 00003 00004 //#include "mbed.h" 00005 00006 // EM7180 SENtral register map 00007 // see http://www.emdeveloper.com/downloads/7180/EMSentral_EM7180_Register_Map_v1_3.pdf 00008 // 00009 #define EM7180_QX 0x00 // this is a 32-bit normalized floating point number read from registers 0x00-03 00010 #define EM7180_QY 0x04 // this is a 32-bit normalized floating point number read from registers 0x04-07 00011 #define EM7180_QZ 0x08 // this is a 32-bit normalized floating point number read from registers 0x08-0B 00012 #define EM7180_QW 0x0C // this is a 32-bit normalized floating point number read from registers 0x0C-0F 00013 #define EM7180_QTIME 0x10 // this is a 16-bit unsigned integer read from registers 0x10-11 00014 #define EM7180_MX 0x12 // int16_t from registers 0x12-13 00015 #define EM7180_MY 0x14 // int16_t from registers 0x14-15 00016 #define EM7180_MZ 0x16 // int16_t from registers 0x16-17 00017 #define EM7180_MTIME 0x18 // uint16_t from registers 0x18-19 00018 #define EM7180_AX 0x1A // int16_t from registers 0x1A-1B 00019 #define EM7180_AY 0x1C // int16_t from registers 0x1C-1D 00020 #define EM7180_AZ 0x1E // int16_t from registers 0x1E-1F 00021 #define EM7180_ATIME 0x20 // uint16_t from registers 0x20-21 00022 #define EM7180_GX 0x22 // int16_t from registers 0x22-23 00023 #define EM7180_GY 0x24 // int16_t from registers 0x24-25 00024 #define EM7180_GZ 0x26 // int16_t from registers 0x26-27 00025 #define EM7180_GTIME 0x28 // uint16_t from registers 0x28-29 00026 #define EM7180_Baro 0x2A // start of two-byte MS5637 pressure data, 16-bit signed interger 00027 #define EM7180_BaroTIME 0x2C // start of two-byte MS5637 pressure timestamp, 16-bit unsigned 00028 #define EM7180_Temp 0x2E // start of two-byte MS5637 temperature data, 16-bit signed interger 00029 #define EM7180_TempTIME 0x30 // start of two-byte MS5637 temperature timestamp, 16-bit unsigned 00030 #define EM7180_QRateDivisor 0x32 // uint8_t 00031 #define EM7180_EnableEvents 0x33 00032 #define EM7180_HostControl 0x34 00033 #define EM7180_EventStatus 0x35 00034 #define EM7180_SensorStatus 0x36 00035 #define EM7180_SentralStatus 0x37 00036 #define EM7180_AlgorithmStatus 0x38 00037 #define EM7180_FeatureFlags 0x39 00038 #define EM7180_ParamAcknowledge 0x3A 00039 #define EM7180_SavedParamByte0 0x3B 00040 #define EM7180_SavedParamByte1 0x3C 00041 #define EM7180_SavedParamByte2 0x3D 00042 #define EM7180_SavedParamByte3 0x3E 00043 #define EM7180_ActualMagRate 0x45 00044 #define EM7180_ActualAccelRate 0x46 00045 #define EM7180_ActualGyroRate 0x47 00046 #define EM7180_ActualBaroRate 0x48 00047 #define EM7180_ActualTempRate 0x49 00048 #define EM7180_ErrorRegister 0x50 00049 #define EM7180_AlgorithmControl 0x54 00050 #define EM7180_MagRate 0x55 00051 #define EM7180_AccelRate 0x56 00052 #define EM7180_GyroRate 0x57 00053 #define EM7180_BaroRate 0x58 00054 #define EM7180_TempRate 0x59 00055 #define EM7180_LoadParamByte0 0x60 00056 #define EM7180_LoadParamByte1 0x61 00057 #define EM7180_LoadParamByte2 0x62 00058 #define EM7180_LoadParamByte3 0x63 00059 #define EM7180_ParamRequest 0x64 00060 #define EM7180_ROMVersion1 0x70 00061 #define EM7180_ROMVersion2 0x71 00062 #define EM7180_RAMVersion1 0x72 00063 #define EM7180_RAMVersion2 0x73 00064 #define EM7180_ProductID 0x90 00065 #define EM7180_RevisionID 0x91 00066 #define EM7180_RunStatus 0x92 00067 #define EM7180_UploadAddress 0x94 // uint16_t registers 0x94 (MSB)-5(LSB) 00068 #define EM7180_UploadData 0x96 00069 #define EM7180_CRCHost 0x97 // uint32_t from registers 0x97-9A 00070 #define EM7180_ResetRequest 0x9B 00071 #define EM7180_PassThruStatus 0x9E 00072 #define EM7180_PassThruControl 0xA0 00073 #define EM7180_ACC_LPF_BW 0x5B //Register GP36 00074 #define EM7180_GYRO_LPF_BW 0x5C //Register GP37 00075 #define EM7180_BARO_LPF_BW 0x5D //Register GP38 00076 00077 #define EM7180_ADDRESS 0x28<<1 // Address of the EM7180 SENtral sensor hub 00078 00079 00080 class EM7180 { 00081 00082 protected: 00083 00084 public: 00085 //=================================================================================================================== 00086 //====== Set of useful function to access pressure and temperature data 00087 //=================================================================================================================== 00088 00089 00090 void writeByte(uint8_t address, uint8_t subAddress, uint8_t data) 00091 { 00092 char data_write[2]; 00093 data_write[0] = subAddress; 00094 data_write[1] = data; 00095 i2c.write(address, data_write, 2, 0); 00096 } 00097 00098 char readByte(uint8_t address, uint8_t subAddress) 00099 { 00100 char data[1]; // `data` will store the register data 00101 char data_write[1]; 00102 data_write[0] = subAddress; 00103 i2c.write(address, data_write, 1, 1); // no stop 00104 i2c.read(address, data, 1, 0); 00105 return data[0]; 00106 } 00107 00108 void readBytes(uint8_t address, uint8_t subAddress, uint8_t count, uint8_t * dest) 00109 { 00110 char data[24]; 00111 char data_write[1]; 00112 data_write[0] = subAddress; 00113 i2c.write(address, data_write, 1, 1); // no stop 00114 i2c.read(address, data, count, 0); 00115 for(int ii = 0; ii < count; ii++) { 00116 dest[ii] = data[ii]; 00117 } 00118 } 00119 00120 00121 00122 00123 }; 00124 #endif
Generated on Sat Jul 16 2022 19:46:00 by
