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.
Dependents: ECE4180FinalProjectFall22
ens160_i2c_regs.h
00001 #include "mbed.h" 00002 #include <stdint.h> 00003 00004 #define SFE_ENS160_PART_ID 0x00 00005 00006 typedef struct 00007 { 00008 uint8_t part_id_msb : 8; // Value = 0x01 00009 uint8_t part_id_lsb : 8; // Value = 0x60 00010 } sfe_ens160_part_id_t; 00011 00012 #define SFE_ENS160_OP_MODE 0x10 00013 // Possible Operating Mode defines: 00014 #define SFE_ENS160_DEEP_SLEEP 0x00 00015 #define SFE_ENS160_IDLE 0x01 00016 #define SFE_ENS160_STANDARD 0x02 00017 #define SFE_ENS160_RESET 0xF0 00018 typedef struct 00019 { 00020 uint8_t op_mode : 8; 00021 } sfe_ens160_op_mode_t; 00022 00023 #define SFE_ENS160_CONFIG 0x11 00024 typedef struct 00025 { 00026 uint8_t reserved_three : 1; 00027 uint8_t int_pol : 1; 00028 uint8_t int_cfg : 1; 00029 uint8_t reserved_two : 1; 00030 uint8_t int_gpr : 1; 00031 uint8_t reserved_one : 1; 00032 uint8_t int_dat : 1; 00033 uint8_t int_en : 1; 00034 } sfe_ens160_config_t; 00035 00036 #define SFE_ENS160_COMMAND 0x12 00037 // All commands must be issued when device is idle. 00038 #define SFE_ENS160_COMMAND_NOP 0x00 00039 // Get Firwmware App Version - version is placed in General Purpose Read Registers as follows: 00040 // GPR_READ04 - Version (Major) 00041 // GPR_READ05 - Version (Minor) 00042 // GPR_READ06 - Version (Release) 00043 #define SFE_ENS160_COMMAND_GET_APPVER 0x0E 00044 // Clear General Purpose Read Register 00045 #define SFE_ENS160_COMMAND_CLRGPR 0xCC 00046 typedef struct 00047 { 00048 uint8_t command : 8; 00049 } sfe_ens160_command_t; 00050 00051 #define SFE_ENS160_TEMP_IN 0x13 00052 // Temperature compensation can be given to the sensor for more accurate 00053 // readings. 00054 // Temperature should be given in Kelvin in the following format: 00055 // Value: Temperature in Kelvin * 64 00056 // Converting Celsius to Kelvin = Temp + 273.15 00057 // Ergo: (Temp + 273.15) * 64 00058 typedef struct 00059 { 00060 uint8_t temp_in_msb : 8; //0x14 -- Integer Part 00061 uint8_t temp_in_lsb : 8; //0x13 -- Fractions Part 00062 } sfe_ens160_temp_in_t; 00063 00064 #define SFE_ENS160_RH_IN 0x15 00065 // Relative Humidity compensation can be given to the sensor for more accurate 00066 // readings. 00067 // RH should be given in %rH * 512 00068 typedef struct 00069 { 00070 uint8_t rh_in_msb : 8; //0x16 -- Integer Part 00071 uint8_t rh_in_lsb : 8; //0x15 -- Fraction Part 00072 } sfe_ens160_rh_in_t; 00073 00074 #define SFE_ENS160_DEVICE_STATUS 0x20 00075 typedef struct 00076 { 00077 uint8_t stat_as : 1; 00078 uint8_t stat_er : 1; 00079 uint8_t reserved_two : 1; 00080 uint8_t reserved_one : 1; 00081 uint8_t validity_flag : 2; 00082 uint8_t new_dat : 1; 00083 uint8_t new_gpr : 1; 00084 } sfe_ens160_device_status_t; 00085 00086 #define SFE_ENS160_DATA_AQI 0x21 00087 typedef struct 00088 { 00089 uint8_t reserved_one : 6; 00090 uint8_t aqi_uba : 2; 00091 } sfe_ens160_data_aqi_t; 00092 00093 #define SFE_ENS160_DATA_TVOC 0x22 00094 // TVOC Data - shares register with ethanol data 00095 typedef struct 00096 { 00097 uint8_t tvoc_msb : 8; 00098 uint8_t tvoc_lsb : 8; 00099 } sfe_ens160_data_tvoc_t; 00100 00101 #define SFE_ENS160_DATA_ETOH 0x22 00102 // Ethanol Data - shares register with TVOC data 00103 typedef struct 00104 { 00105 uint8_t etoh_msb : 8; 00106 uint8_t etoh_lsb : 8; 00107 } sfe_ens160_data_etho_t; 00108 00109 #define SFE_ENS160_DATA_ECO2 0x24 00110 // CO2 Data 00111 typedef struct 00112 { 00113 uint8_t eco2_msb : 8; 00114 uint8_t eco2_lsb : 8; 00115 } sfe_ens160_data_eco2_t; 00116 00117 #define SFE_ENS160_DATA_T 0x30 00118 // Reports the temperature data given to TEMP_IN in the following manner: 00119 // Temperature in Kelvin: Register Value / 64 00120 // Converting Kelvin to Celsius = Temperature in Kelvin - 273.15 00121 // Ergo: (Register Value / 64) - 273.15 00122 typedef struct 00123 { 00124 uint8_t data_t_msb : 8; // Fractions -- 0x31 00125 uint8_t data_t_lsb : 8; // Integer -- 0x30 00126 } sfe_ens160_data_t_t; 00127 00128 #define SFE_ENS160_DATA_RH 0x32 00129 // Reports the Relative Humidity compensation given to RH_IN in the following manner 00130 // RH = Register Value / 512 00131 typedef struct 00132 { 00133 uint8_t data_rh_msb : 8; // Fractions -- 0x33 00134 uint8_t data_rh_lsb : 8; // Integer -- 0x32 00135 } sfe_ens160_data_rh_t; 00136 00137 #define SFE_ENS160_DATA_MISR 0x38 00138 #define POLY 0x1D 00139 // Gives calculated checksum of "DATA_" registers 00140 typedef struct 00141 { 00142 uint8_t data_misr : 8; 00143 } sfe_ens160_data_misr_t; 00144 00145 // General Purpose Write registers 00146 #define SFE_ENS160_GPR_WRITE0 0x40 00147 #define SFE_ENS160_GPR_WRITE1 0x41 00148 #define SFE_ENS160_GPR_WRITE2 0x42 00149 #define SFE_ENS160_GPR_WRITE3 0x43 00150 #define SFE_ENS160_GPR_WRITE4 0x44 00151 #define SFE_ENS160_GPR_WRITE5 0x45 00152 #define SFE_ENS160_GPR_WRITE6 0x46 00153 #define SFE_ENS160_GPR_WRITE7 0x47 00154 00155 // General Purpose Read registers 00156 #define SFE_ENS160_GPR_READ0 0x48 00157 #define SFE_ENS160_GPR_READ1 0x49 00158 #define SFE_ENS160_GPR_READ2 0x4A 00159 #define SFE_ENS160_GPR_READ3 0x4B 00160 #define SFE_ENS160_GPR_READ4 0x4C 00161 #define SFE_ENS160_GPR_READ5 0x4D 00162 #define SFE_ENS160_GPR_READ6 0x4E 00163 #define SFE_ENS160_GPR_READ7 0x4F
Generated on Thu Dec 8 2022 16:51:02 by
1.7.2