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.
Fork of STC3100 by
STC3100Sensor.h
00001 #ifndef STC3100Sensor_H_ 00002 #define STC3100Sensor_H_ 00003 00004 /** 00005 * I2C Device address 00006 * ------------------ 00007 * The mbed API uses 8 bit addresses, so make sure to thake the 7 bit address 00008 * and left shift it by 1 before passing it. 00009 * The eight bit presents a R/W bit, see datasheet STC3100 page 12. 00010 */ 00011 #define STC3100_ADDRESS_READ 0b11100000 00012 #define STC3100_ADRESS_WRITE 0b11100001 00013 00014 /** 00015 * INTERNAL REGISTER MAP 00016 * --------------------- 00017 * For this application the RAM registers are not used 00018 */ 00019 #define REG_MODE 0 // Mode register (R/W) 00020 #define REG_CTRL 1 // Control and status register (R/W) 00021 #define REG_CHARGE_LOW 2 // Gas gauge charge data, bits 0-7 (R) 00022 #define REG_CHARGE_HIGH 3 // Gas gauge charge data, bits 8-15 (R) 00023 #define REG_COUNTER_LOW 4 // Number of conversions, bits 0-7 (R) 00024 #define REG_COUNTER_HIGH 5 // Number of conversions, bits 8-15 (R) 00025 #define REG_CURRENT_LOW 6 // Battery current value, bits 0-7 (R) 00026 #define REG_CURRENT_HIGH 7 // Battery current value, bits 8-15 (R) 00027 #define REG_VOLTAGE_LOW 8 // Battery voltage value, bits 0-7 (R) 00028 #define REG_VOLTAGE_HIGH 9 // Battery voltage value, bits 8-15 (R) 00029 //#define REG_TEMPERATURE_LOW 10 // Temperature value, bits 0-7 (R) 00030 //#define REG_TEMPERATURE_HIGH 11 // Temperature value, bits 8-15 (R) 00031 00032 //The following registers are the Device ID registers (R) 00033 //#define REG_ID0 24 00034 //#define REG_ID1 25 00035 //#define REG_ID2 26 00036 //#define REG_ID3 27 00037 //#define REG_ID4 28 00038 //#define REG_ID5 29 00039 //#define REG_ID6 30 00040 //#define REG_ID7 31 00041 00042 unsigned char Mode; 00043 unsigned char ControlStatus; 00044 unsigned char ChargeLow; 00045 unsigned char ChargeHigh; 00046 unsigned char CounterLow; 00047 unsigned char CounterHigh; 00048 unsigned char CurrentLow; 00049 unsigned char CurrentHigh; 00050 unsigned char VoltageLow; 00051 unsigned char VoltageHigh; 00052 // unsigned char TemperatureLow; 00053 // unsigned char TemperatureHigh; 00054 // unsigned char Reserved[13]; 00055 // unsigned char ID0; 00056 // unsigned char ID1; 00057 // unsigned char ID2; 00058 // unsigned char ID3; 00059 // unsigned char ID4; 00060 // unsigned char ID5; 00061 // unsigned char ID6; 00062 // unsigned char ID7; 00063 00064 /** 00065 * Struct that stores the updated values. 00066 */ 00067 // Voltage in mV 00068 float voltage; 00069 // Current in mA 00070 float current; 00071 // Current charge of the battery mAh 00072 float charge; 00073 // // Temperature in °C 00074 // float temperature; 00075 00076 //STC3100ActualData stc3100ActualData; 00077 //STC3100Data stc3100Data; 00078 // Reading of the chip will be stored in the byteArray 00079 char byteArray[10]; 00080 00081 void stc3100Configure(void); 00082 void stc3100ReadChip(void); 00083 void updateData(void); 00084 float getVoltage(void); 00085 float getCurrent(void); 00086 float getCharge(void); 00087 //float getTemperature(void); 00088 00089 #endif /* STC3100Sensor_H_ */
Generated on Fri Jul 15 2022 12:54:40 by
1.7.2
