1 /* 2 * Copyright (c) 2021 Leica Geosystems AG 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_DRIVERS_SENSOR_SBS_GAUGE_H_ 8 #define ZEPHYR_DRIVERS_SENSOR_SBS_GAUGE_H_ 9 10 #include <stdint.h> 11 #include <zephyr/drivers/i2c.h> 12 13 /*** Standard Commands ***/ 14 #define SBS_GAUGE_CMD_MANUFACTURER_ACCESS 0x00 /* ManufacturerAccess */ 15 #define SBS_GAUGE_CMD_REM_CAPACITY_ALARM 0x01 /* LowCapacityAlarmThreshold */ 16 #define SBS_GAUGE_CMD_REM_TIME_ALARM 0x02 /* RemainingTimeToEmptyThreshold */ 17 #define SBS_GAUGE_CMD_BATTERY_MODE 0x03 /* BatteryOperatingMode */ 18 #define SBS_GAUGE_CMD_AR 0x04 /* AtRate */ 19 #define SBS_GAUGE_CMD_ARTTF 0x05 /* AtRateTimeToFull */ 20 #define SBS_GAUGE_CMD_ARTTE 0x06 /* AtRateTimeToEmpty */ 21 #define SBS_GAUGE_CMD_AROK 0x07 /* AtRateOK */ 22 #define SBS_GAUGE_CMD_TEMP 0x08 /* Temperature */ 23 #define SBS_GAUGE_CMD_VOLTAGE 0x09 /* Voltage */ 24 #define SBS_GAUGE_CMD_CURRENT 0x0A /* Current */ 25 #define SBS_GAUGE_CMD_AVG_CURRENT 0x0B /* AverageCurrent */ 26 #define SBS_GAUGE_CMD_MAX_ERROR 0x0C /* MaxError */ 27 #define SBS_GAUGE_CMD_RSOC 0x0D /* RelativeStateOfCharge */ 28 #define SBS_GAUGE_CMD_ASOC 0x0E /* AbsoluteStateOfCharge */ 29 #define SBS_GAUGE_CMD_REM_CAPACITY 0x0F /* RemainingCapacity */ 30 #define SBS_GAUGE_CMD_FULL_CAPACITY 0x10 /* FullChargeCapacity */ 31 #define SBS_GAUGE_CMD_RUNTIME2EMPTY 0x11 /* RunTimeToEmpty */ 32 #define SBS_GAUGE_CMD_AVG_TIME2EMPTY 0x12 /* AverageTimeToEmpty */ 33 #define SBS_GAUGE_CMD_AVG_TIME2FULL 0x13 /* AverageTimeToFull */ 34 #define SBS_GAUGE_CMD_CHG_CURRENT 0x14 /* ChargeCurrent */ 35 #define SBS_GAUGE_CMD_CHG_VOLTAGE 0x15 /* ChargeVoltage */ 36 #define SBS_GAUGE_CMD_FLAGS 0x16 /* BatteryStatus */ 37 #define SBS_GAUGE_CMD_CYCLE_COUNT 0x17 /* CycleCount */ 38 #define SBS_GAUGE_CMD_NOM_CAPACITY 0x18 /* DesignCapacity */ 39 #define SBS_GAUGE_CMD_DESIGN_VOLTAGE 0x19 /* DesignVoltage */ 40 #define SBS_GAUGE_CMD_SPECS_INFO 0x1A /* SpecificationInfo */ 41 #define SBS_GAUGE_CMD_MANUFACTURER_DATE 0x1B /* ManufacturerDate */ 42 #define SBS_GAUGE_CMD_SN 0x1C /* SerialNumber */ 43 #define SBS_GAUGE_CMD_MANUFACTURER_NAME 0x20 /* ManufacturerName */ 44 #define SBS_GAUGE_CMD_DEVICE_NAME 0x21 /* DeviceName */ 45 #define SBS_GAUGE_CMD_DEVICE_CHEM 0x22 /* DeviceChemistry */ 46 #define SBS_GAUGE_CMD_MANUFACTURER_DATA 0x23 /* ManufacturerData */ 47 #define SBS_GAUGE_CMD_DESIGN_MAX_POWER 0x24 /* DesignMaxPower */ 48 #define SBS_GAUGE_CMD_START_TIME 0x25 /* StartTime */ 49 #define SBS_GAUGE_CMD_TOTAL_RUNTIME 0x26 /* TotalRuntime */ 50 #define SBS_GAUGE_CMD_FC_TEMP 0x27 /* FCTemp */ 51 #define SBS_GAUGE_CMD_FC_STATUS 0x28 /* FCStatus */ 52 #define SBS_GAUGE_CMD_FC_MODE 0x29 /* FCMode */ 53 #define SBS_GAUGE_CMD_AUTO_SOFT_OFF 0x2A /* AutoSoftOff */ 54 #define SBS_GAUGE_CMD_AUTHENTICATE 0x2F /* Authenticate */ 55 #define SBS_GAUGE_CMD_CELL_V4 0x3C /* CellVoltage4 */ 56 #define SBS_GAUGE_CMD_CELL_V3 0x3D /* CellVoltage3 */ 57 #define SBS_GAUGE_CMD_CELL_V2 0x3E /* CellVoltage2 */ 58 #define SBS_GAUGE_CMD_CELL_V1 0x3F /* CellVoltage1 */ 59 60 #define SBS_GAUGE_DELAY 1000 61 62 struct sbs_gauge_data { 63 uint16_t voltage; 64 int16_t avg_current; 65 uint16_t state_of_charge; 66 uint16_t internal_temperature; 67 uint16_t full_charge_capacity; 68 uint16_t remaining_charge_capacity; 69 uint16_t nom_avail_capacity; 70 uint16_t full_avail_capacity; 71 uint16_t time_to_empty; 72 uint16_t time_to_full; 73 uint16_t cycle_count; 74 }; 75 76 struct sbs_gauge_config { 77 struct i2c_dt_spec i2c; 78 }; 79 80 #endif 81