Driver for Texas Instruments' battery state-of-charge estimator.

Dependents:   BQ34Z100G1-Utils BQ34Z100G1-ChemIDMeasurer

BQ34Z100G1 Driver

Newer releases of this driver have moved to GitHub: https://github.com/USCRPL/BQ34Z100G1-Driver

By USC Rocket Propulsion Lab / Arpad Kovesdy, Kyle Marino, Jamie Smith

After lots of development, testing, debugging, dead ends, backtracking, and retracing our steps, we at RPL are proud to present a complete driver for Texas Instruments' BQ34Z100G1 state-of-charge estimator. This handy chip handles all the complexities of monitoring a battery's charging and discharging cycle, and is one of the only real ways to have a real estimate of how much usable energy is left in a standard lithium-ion battery.

However, in order to perform this function, the IC needs a lot of information, including both the on-paper specifications of your battery system and the results of several different calibration runs of your real battery system. With one exception*, this driver can handle all the needed configuration, taking you from unconfigured to calibrated in as little time as possible.

Note: To initially program the Chem ID information into each chip to configure it for your battery, you will need an EV2300 or EV2400 programmer box from TI, as well as a header to plug it in on your board.

Calibrating the Chip

See here.

Credits

The initial version of this driver was taken from Ralim on GitHub here.

However, we have made a huge number of changes and additions since then, including porting the Arduino library to Mbed, cleaning up the code to use enums, breaking out the configuration to external constants, and fixing looots of bugs.

Committer:
Jamie Smith
Date:
Sun Feb 07 01:17:28 2021 -0800
Revision:
0:6d09d3ad58aa
Child:
1:6483d36150c3
Import from RPL internal repository

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jamie Smith 0:6d09d3ad58aa 1 /*
Jamie Smith 0:6d09d3ad58aa 2 USCRPL
Jamie Smith 0:6d09d3ad58aa 3 BQ34Z100-G1 Sensor Driver
Jamie Smith 0:6d09d3ad58aa 4
Jamie Smith 0:6d09d3ad58aa 5 Reads the current state of the main battery, can determine charge remaining inside
Jamie Smith 0:6d09d3ad58aa 6 as well as read instantaneous voltage, current, or temperature.
Jamie Smith 0:6d09d3ad58aa 7
Jamie Smith 0:6d09d3ad58aa 8 Datasheet: http://www.ti.com/lit/ds/symlink/bq34z100-g1.pdf
Jamie Smith 0:6d09d3ad58aa 9 Existing arduino code to reference from unknown author: https://github.com/Ralim/BQ34Z100
Jamie Smith 0:6d09d3ad58aa 10 Partial library from TI that may be useful: http://www.ti.com/lit/an/slua801/slua801.pdf
Jamie Smith 0:6d09d3ad58aa 11 */
Jamie Smith 0:6d09d3ad58aa 12
Jamie Smith 0:6d09d3ad58aa 13 #ifndef BQ34Z100_H
Jamie Smith 0:6d09d3ad58aa 14 #define BQ34Z100_H
Jamie Smith 0:6d09d3ad58aa 15
Jamie Smith 0:6d09d3ad58aa 16 #include <cstdint>
Jamie Smith 0:6d09d3ad58aa 17
Jamie Smith 0:6d09d3ad58aa 18 //Definitions
Jamie Smith 0:6d09d3ad58aa 19 #define GAUGE_ADDRESS 0xAA
Jamie Smith 0:6d09d3ad58aa 20
Jamie Smith 0:6d09d3ad58aa 21 //Battery configuration settings
Jamie Smith 0:6d09d3ad58aa 22 //Stored in flash: run flashSettings() then reset sensor to save
Jamie Smith 0:6d09d3ad58aa 23 //battery information:
Jamie Smith 0:6d09d3ad58aa 24 //https://www.batteryspace.com/polymerli-ioncell37v1400mah703562-10c518wh10adrainrate-ullisted.aspx
Jamie Smith 0:6d09d3ad58aa 25 #define DESIGNCAP 1400 //mAh, per cell (Page 48, offset 11)
Jamie Smith 0:6d09d3ad58aa 26 #define DESIGNENERGY 5180 //mWh, per cell (Page 48, offset 14)
Jamie Smith 0:6d09d3ad58aa 27 #define CELLCOUNT 0x04 //number of series cells (Page 65, offset 7)
Jamie Smith 0:6d09d3ad58aa 28 #define LEDCONFIG 0x4b //5-LED Expander with I2C host comm (Page 64, offset 5)
Jamie Smith 0:6d09d3ad58aa 29 #define VOLTSEL true //Switches to an external battery voltage divider
Jamie Smith 0:6d09d3ad58aa 30 #define ZEROCHARGEVOLT 3375 //mV, charge cut-off voltage/Cell terminate voltages
Jamie Smith 0:6d09d3ad58aa 31 #define FLASH_UPDATE_OK_VOLT 2800 // mV, below this voltage per cell flash writes will not go through
Jamie Smith 0:6d09d3ad58aa 32
Jamie Smith 0:6d09d3ad58aa 33 #define QMAX0 10000 //mAh, same as c-rate
Jamie Smith 0:6d09d3ad58aa 34 //The voltage divider works by this formula: Gain = (TOP LEG R/BOTTOM LEG R)*1000
Jamie Smith 0:6d09d3ad58aa 35 //Top leg: 294Kohm and bottom leg: 16.5Kohm
Jamie Smith 0:6d09d3ad58aa 36 //This only works if you enable the external voltage divider (VOLTSEL) option for the sensor
Jamie Smith 0:6d09d3ad58aa 37 //Note: requires calibration after setting in flash
Jamie Smith 0:6d09d3ad58aa 38 #define VOLTAGEGAIN 17818
Jamie Smith 0:6d09d3ad58aa 39 #define LOADSELECT 0x01 // "Load Select defines the type of power or current model to be used to compute load-compensated capacity in the Impedance Track algorithm"
Jamie Smith 0:6d09d3ad58aa 40 #define LOADMODE 0x00 // "Load Mode is used to select either the constant current or constant power model for the Impedance Track algorithm"
Jamie Smith 0:6d09d3ad58aa 41 #define RESETVOLTAGE 22200 //mV, voltage to reset to after unsuccessful voltage calibration
Jamie Smith 0:6d09d3ad58aa 42
Jamie Smith 0:6d09d3ad58aa 43 //Sense resistor value
Jamie Smith 0:6d09d3ad58aa 44 #define SENSE_RES 5.0f //mOhms, value of guage sense resistor
Jamie Smith 0:6d09d3ad58aa 45
Jamie Smith 0:6d09d3ad58aa 46 #define USE_EXTERNAL_THERMISTOR 0 // If 1, use an external thermistor connected to the IT pin. If 0, use the internal temp sensor.
Jamie Smith 0:6d09d3ad58aa 47
Jamie Smith 0:6d09d3ad58aa 48 #include "mbed.h"
Jamie Smith 0:6d09d3ad58aa 49
Jamie Smith 0:6d09d3ad58aa 50 class BQ34Z100
Jamie Smith 0:6d09d3ad58aa 51 {
Jamie Smith 0:6d09d3ad58aa 52 // Top-level commands - the first byte that you can send on an I2C transaction
Jamie Smith 0:6d09d3ad58aa 53 enum class Command : uint8_t
Jamie Smith 0:6d09d3ad58aa 54 {
Jamie Smith 0:6d09d3ad58aa 55 Control = 0x0,
Jamie Smith 0:6d09d3ad58aa 56 StateOfCharge = 0x2,
Jamie Smith 0:6d09d3ad58aa 57 MaxError = 0x3,
Jamie Smith 0:6d09d3ad58aa 58 RemainingCapacity = 0x4,
Jamie Smith 0:6d09d3ad58aa 59 FullChargeCapacity = 0x6,
Jamie Smith 0:6d09d3ad58aa 60 Voltage = 0x8,
Jamie Smith 0:6d09d3ad58aa 61 AverageCurrent = 0xA,
Jamie Smith 0:6d09d3ad58aa 62 Temperature = 0xC,
Jamie Smith 0:6d09d3ad58aa 63 Flags = 0xE,
Jamie Smith 0:6d09d3ad58aa 64 Current = 0x10,
Jamie Smith 0:6d09d3ad58aa 65 FlagsB = 0x12,
Jamie Smith 0:6d09d3ad58aa 66 // ...
Jamie Smith 0:6d09d3ad58aa 67 SerialNumber = 0x28,
Jamie Smith 0:6d09d3ad58aa 68 InternalTemperature = 0x2A,
Jamie Smith 0:6d09d3ad58aa 69 CycleCount = 0x2C,
Jamie Smith 0:6d09d3ad58aa 70 StateOfHealth = 0x2E,
Jamie Smith 0:6d09d3ad58aa 71 // ...
Jamie Smith 0:6d09d3ad58aa 72 DataFlashClass = 0x3E,
Jamie Smith 0:6d09d3ad58aa 73 DataFlashBlock = 0x3F,
Jamie Smith 0:6d09d3ad58aa 74 BlockData = 0x40,
Jamie Smith 0:6d09d3ad58aa 75 // ...
Jamie Smith 0:6d09d3ad58aa 76 BlockDataCheckSum = 0x60,
Jamie Smith 0:6d09d3ad58aa 77 BlockDataControl = 0x61
Jamie Smith 0:6d09d3ad58aa 78 };
Jamie Smith 0:6d09d3ad58aa 79
Jamie Smith 0:6d09d3ad58aa 80 // subcommands for Control command
Jamie Smith 0:6d09d3ad58aa 81 enum class Control : uint16_t
Jamie Smith 0:6d09d3ad58aa 82 {
Jamie Smith 0:6d09d3ad58aa 83 CONTROL_STATUS = 0x0,
Jamie Smith 0:6d09d3ad58aa 84 DEVICE_TYPE = 0x1,
Jamie Smith 0:6d09d3ad58aa 85 FW_VERSION = 0x02,
Jamie Smith 0:6d09d3ad58aa 86 HW_VERSION = 0x03,
Jamie Smith 0:6d09d3ad58aa 87 RESET_DATA = 0x5,
Jamie Smith 0:6d09d3ad58aa 88 PREV_MACWRITE = 0x7,
Jamie Smith 0:6d09d3ad58aa 89 CHEM_ID = 0x8,
Jamie Smith 0:6d09d3ad58aa 90 BOARD_OFFSET = 0x9,
Jamie Smith 0:6d09d3ad58aa 91 CC_OFFSET = 0xA,
Jamie Smith 0:6d09d3ad58aa 92 CC_OFFSET_SAVE = 0xB,
Jamie Smith 0:6d09d3ad58aa 93 DF_VERSION = 0xC,
Jamie Smith 0:6d09d3ad58aa 94 SET_FULLSLEEP = 0x10,
Jamie Smith 0:6d09d3ad58aa 95 STATIC_CHEM_CHECKSUM = 0x17,
Jamie Smith 0:6d09d3ad58aa 96 SEALED = 0x20,
Jamie Smith 0:6d09d3ad58aa 97 IT_ENABLE = 0x21,
Jamie Smith 0:6d09d3ad58aa 98 CAL_ENABLE = 0x2D,
Jamie Smith 0:6d09d3ad58aa 99 RESET = 0x41,
Jamie Smith 0:6d09d3ad58aa 100 EXIT_CAL = 0x80,
Jamie Smith 0:6d09d3ad58aa 101 ENTER_CAL = 0x81,
Jamie Smith 0:6d09d3ad58aa 102 OFFSET_CAL = 0x82,
Jamie Smith 0:6d09d3ad58aa 103
Jamie Smith 0:6d09d3ad58aa 104 // unseal key, from datasheet p.21
Jamie Smith 0:6d09d3ad58aa 105 UNSEAL_KEY1 = 0x0414,
Jamie Smith 0:6d09d3ad58aa 106 UNSEAL_KEY2 = 0x3672
Jamie Smith 0:6d09d3ad58aa 107 };
Jamie Smith 0:6d09d3ad58aa 108
Jamie Smith 0:6d09d3ad58aa 109 public:
Jamie Smith 0:6d09d3ad58aa 110 /** Create an GQ34Z100-G1 object connected to the specified I2C pins
Jamie Smith 0:6d09d3ad58aa 111 *
Jamie Smith 0:6d09d3ad58aa 112 * @param sda The I2C data pin.
Jamie Smith 0:6d09d3ad58aa 113 * @param scl The I2C clock pin.
Jamie Smith 0:6d09d3ad58aa 114 * @param hz The I2C bus frequency (400kHz acc. to datasheet).
Jamie Smith 0:6d09d3ad58aa 115 */
Jamie Smith 0:6d09d3ad58aa 116 BQ34Z100(PinName sda, PinName scl, int hz = 400000);
Jamie Smith 0:6d09d3ad58aa 117
Jamie Smith 0:6d09d3ad58aa 118 //returs status of key features
Jamie Smith 0:6d09d3ad58aa 119 uint16_t getStatus();
Jamie Smith 0:6d09d3ad58aa 120
Jamie Smith 0:6d09d3ad58aa 121 //Allows use of the entry and exit functions to the CALIBRATION mode
Jamie Smith 0:6d09d3ad58aa 122 //Use before enterCal or exitCal()
Jamie Smith 0:6d09d3ad58aa 123 void enableCal();
Jamie Smith 0:6d09d3ad58aa 124
Jamie Smith 0:6d09d3ad58aa 125 //Enables CALIBRATION mode
Jamie Smith 0:6d09d3ad58aa 126 void enterCal();
Jamie Smith 0:6d09d3ad58aa 127
Jamie Smith 0:6d09d3ad58aa 128 //Exits CALIBRATION mode
Jamie Smith 0:6d09d3ad58aa 129 void exitCal();
Jamie Smith 0:6d09d3ad58aa 130
Jamie Smith 0:6d09d3ad58aa 131 //Allows the sensor to begin the Impednance Track algorithm (learns about
Jamie Smith 0:6d09d3ad58aa 132 //the battery and begins to find the SOC)
Jamie Smith 0:6d09d3ad58aa 133 void ITEnable();
Jamie Smith 0:6d09d3ad58aa 134
Jamie Smith 0:6d09d3ad58aa 135 //Returns the predicted remaining battery capacity expressed as a percentage
Jamie Smith 0:6d09d3ad58aa 136 //From 0% to 100%
Jamie Smith 0:6d09d3ad58aa 137 uint8_t getSOC();
Jamie Smith 0:6d09d3ad58aa 138
Jamie Smith 0:6d09d3ad58aa 139 //Returns the expected margin of error in the SOC calculation ranging from
Jamie Smith 0:6d09d3ad58aa 140 //1% to 100%. The value is updated continuously internally in increments
Jamie Smith 0:6d09d3ad58aa 141 //of 0.05%
Jamie Smith 0:6d09d3ad58aa 142 uint16_t getError();
Jamie Smith 0:6d09d3ad58aa 143
Jamie Smith 0:6d09d3ad58aa 144 //Estimated remaining battery capacity (1 mAH per bit)
Jamie Smith 0:6d09d3ad58aa 145 uint16_t getRemaining();
Jamie Smith 0:6d09d3ad58aa 146
Jamie Smith 0:6d09d3ad58aa 147 //Returns the measured battery voltage in mV (0 to 65535 mV)
Jamie Smith 0:6d09d3ad58aa 148 uint16_t getVoltage();
Jamie Smith 0:6d09d3ad58aa 149
Jamie Smith 0:6d09d3ad58aa 150 //Returns measured current flow through the sense resistor (mA)
Jamie Smith 0:6d09d3ad58aa 151 int16_t getCurrent();
Jamie Smith 0:6d09d3ad58aa 152
Jamie Smith 0:6d09d3ad58aa 153 //Returns internal sensor temperature in units of celsius
Jamie Smith 0:6d09d3ad58aa 154 double getTemperature();
Jamie Smith 0:6d09d3ad58aa 155
Jamie Smith 0:6d09d3ad58aa 156 //Returns the current ChemID configured inside the chip.
Jamie Smith 0:6d09d3ad58aa 157 // Returns as a hex number, e.g. programming ID 2109 would cause
Jamie Smith 0:6d09d3ad58aa 158 // this function to return 8457 = 0x2109
Jamie Smith 0:6d09d3ad58aa 159 uint16_t getChemID();
Jamie Smith 0:6d09d3ad58aa 160
Jamie Smith 0:6d09d3ad58aa 161 //Returns a percent from 0 to 100 that is the ratio of the predicted FCC over the design capacity
Jamie Smith 0:6d09d3ad58aa 162 //FCC = the full charge capacity
Jamie Smith 0:6d09d3ad58aa 163 //For example, an old battery will not be able to charge fully to its design capacity
Jamie Smith 0:6d09d3ad58aa 164 //This sensor can tell us if we should throw the battery away because its worn out! Cool!
Jamie Smith 0:6d09d3ad58aa 165 uint16_t getStateOfHealth();
Jamie Smith 0:6d09d3ad58aa 166
Jamie Smith 0:6d09d3ad58aa 167 //Returns the pack serial number programmed in the data flash
Jamie Smith 0:6d09d3ad58aa 168 int getSerial();
Jamie Smith 0:6d09d3ad58aa 169
Jamie Smith 0:6d09d3ad58aa 170 //Instructs the fuel gauge to perform a full reset. This command is only
Jamie Smith 0:6d09d3ad58aa 171 //available when the fuel gauge is UNSEALED
Jamie Smith 0:6d09d3ad58aa 172 void reset();
Jamie Smith 0:6d09d3ad58aa 173
Jamie Smith 0:6d09d3ad58aa 174 //Unseal some registers, allowing writing (recommended before writing to flash)
Jamie Smith 0:6d09d3ad58aa 175 void unseal();
Jamie Smith 0:6d09d3ad58aa 176
Jamie Smith 0:6d09d3ad58aa 177 //Reverse unseal command, do not recommend ever using this
Jamie Smith 0:6d09d3ad58aa 178 void seal();
Jamie Smith 0:6d09d3ad58aa 179
Jamie Smith 0:6d09d3ad58aa 180 //Data flash functions
Jamie Smith 0:6d09d3ad58aa 181
Jamie Smith 0:6d09d3ad58aa 182 //Changes to a different register in BlockData()
Jamie Smith 0:6d09d3ad58aa 183 void changePage(char subclass, uint16_t offset);
Jamie Smith 0:6d09d3ad58aa 184
Jamie Smith 0:6d09d3ad58aa 185 //Reads the checksum and updates it using the flashbytes array
Jamie Smith 0:6d09d3ad58aa 186 //Required by the sensor to save changes to the flash
Jamie Smith 0:6d09d3ad58aa 187 void updateChecksum();
Jamie Smith 0:6d09d3ad58aa 188
Jamie Smith 0:6d09d3ad58aa 189 //Reads the blockData in the current page and saves it to
Jamie Smith 0:6d09d3ad58aa 190 //flashbytes array
Jamie Smith 0:6d09d3ad58aa 191 void readFlash();
Jamie Smith 0:6d09d3ad58aa 192
Jamie Smith 0:6d09d3ad58aa 193 //Writes a specific index in the page to a given value
Jamie Smith 0:6d09d3ad58aa 194 //given the length of the property
Jamie Smith 0:6d09d3ad58aa 195 void writeFlash(uint8_t index, uint32_t value, int len);
Jamie Smith 0:6d09d3ad58aa 196
Jamie Smith 0:6d09d3ad58aa 197 //Returns array (pointer) to flashbytes internal array
Jamie Smith 0:6d09d3ad58aa 198 //which stores the last updated page in flash
Jamie Smith 0:6d09d3ad58aa 199 uint8_t* getFlashBytes();
Jamie Smith 0:6d09d3ad58aa 200
Jamie Smith 0:6d09d3ad58aa 201 //The following functions change different pages
Jamie Smith 0:6d09d3ad58aa 202 //The number is the subClass ID that is being changed
Jamie Smith 0:6d09d3ad58aa 203 //Each page has different properties that are in those registers
Jamie Smith 0:6d09d3ad58aa 204 void changePage48();
Jamie Smith 0:6d09d3ad58aa 205 void changePage64();
Jamie Smith 0:6d09d3ad58aa 206 void changePage80();
Jamie Smith 0:6d09d3ad58aa 207 void changePage82();
Jamie Smith 0:6d09d3ad58aa 208
Jamie Smith 0:6d09d3ad58aa 209 //Calibrates the Voltage Divider register (run at least 3 times sequentially)
Jamie Smith 0:6d09d3ad58aa 210 // NOTE: Voltage divider changes seem to require a chip reset to take effect.
Jamie Smith 0:6d09d3ad58aa 211 // So you must reset the chip between each calibration.
Jamie Smith 0:6d09d3ad58aa 212 uint16_t calibrateVoltage(uint16_t currentVoltage);
Jamie Smith 0:6d09d3ad58aa 213
Jamie Smith 0:6d09d3ad58aa 214 //If a problem arises with the voltage divider calibration,
Jamie Smith 0:6d09d3ad58aa 215 //reset the register with this function
Jamie Smith 0:6d09d3ad58aa 216 void setVoltageDivider(uint16_t newVoltage = RESETVOLTAGE);
Jamie Smith 0:6d09d3ad58aa 217
Jamie Smith 0:6d09d3ad58aa 218 //Calibrate CCGain and CCOffset registers, which control current shunt
Jamie Smith 0:6d09d3ad58aa 219 //and therefore affect the current and voltage readouts
Jamie Smith 0:6d09d3ad58aa 220 void calibrateShunt(int16_t calCurrent);
Jamie Smith 0:6d09d3ad58aa 221
Jamie Smith 0:6d09d3ad58aa 222 //Set the Chem ID in the flash
Jamie Smith 0:6d09d3ad58aa 223 void setChemID();
Jamie Smith 0:6d09d3ad58aa 224
Jamie Smith 0:6d09d3ad58aa 225 //Set sense resistor - Calibrate shunt also works, but that requires and external
Jamie Smith 0:6d09d3ad58aa 226 //current measurement.
Jamie Smith 0:6d09d3ad58aa 227 void setSenseResistor();
Jamie Smith 0:6d09d3ad58aa 228
Jamie Smith 0:6d09d3ad58aa 229 // Read the device type. Should be 0x100 for the BQ34Z100.
Jamie Smith 0:6d09d3ad58aa 230 uint16_t readDeviceType();
Jamie Smith 0:6d09d3ad58aa 231
Jamie Smith 0:6d09d3ad58aa 232 // reads the contents of the SW and HW version registers.
Jamie Smith 0:6d09d3ad58aa 233 uint16_t readFWVersion();
Jamie Smith 0:6d09d3ad58aa 234 uint16_t readHWVersion();
Jamie Smith 0:6d09d3ad58aa 235
Jamie Smith 0:6d09d3ad58aa 236 // Convert float value to Xemics floating point used on the BQZ.
Jamie Smith 0:6d09d3ad58aa 237 // Documented in this app note: http://www.ti.com/lit/pdf/slva148
Jamie Smith 0:6d09d3ad58aa 238 static uint32_t floatToXemics(float value);
Jamie Smith 0:6d09d3ad58aa 239 static float xemicsToFloat(uint32_t xemics);
Jamie Smith 0:6d09d3ad58aa 240
Jamie Smith 0:6d09d3ad58aa 241 // Read the update status register from flash.
Jamie Smith 0:6d09d3ad58aa 242 // This gives the status of the Impedance Track algorithm and learning process.
Jamie Smith 0:6d09d3ad58aa 243 uint8_t getUpdateStatus();
Jamie Smith 0:6d09d3ad58aa 244
Jamie Smith 0:6d09d3ad58aa 245 /**
Jamie Smith 0:6d09d3ad58aa 246 * Use the Flags and FlagsB commands to get the contents of the Gas Gauge Status Register.
Jamie Smith 0:6d09d3ad58aa 247 * @return
Jamie Smith 0:6d09d3ad58aa 248 */
Jamie Smith 0:6d09d3ad58aa 249 std::pair<uint16_t, uint16_t> getFlags();
Jamie Smith 0:6d09d3ad58aa 250
Jamie Smith 0:6d09d3ad58aa 251 private:
Jamie Smith 0:6d09d3ad58aa 252 I2C _i2c;
Jamie Smith 0:6d09d3ad58aa 253 uint8_t currFlashPage = 0; // current flash page that we have read
Jamie Smith 0:6d09d3ad58aa 254 uint8_t currFlashBlockIndex = 0; // 32 bit block index into current flash page
Jamie Smith 0:6d09d3ad58aa 255 uint8_t flashbytes[32]; //Stores page in flash memory on Hamster
Jamie Smith 0:6d09d3ad58aa 256
Jamie Smith 0:6d09d3ad58aa 257 //Internal commands for writing/reading i2c
Jamie Smith 0:6d09d3ad58aa 258
Jamie Smith 0:6d09d3ad58aa 259 // Send a control command and return the result
Jamie Smith 0:6d09d3ad58aa 260 void sendControlCommand(Control control);
Jamie Smith 0:6d09d3ad58aa 261
Jamie Smith 0:6d09d3ad58aa 262 uint16_t readControlCommand(Control control);
Jamie Smith 0:6d09d3ad58aa 263
Jamie Smith 0:6d09d3ad58aa 264 void write(Command command, const uint8_t cmd); //1 byte only
Jamie Smith 0:6d09d3ad58aa 265 void write(Command command, const uint8_t cmd1, const uint8_t cmd2); //2 bytes
Jamie Smith 0:6d09d3ad58aa 266 uint32_t read(Command command, const uint8_t length);
Jamie Smith 0:6d09d3ad58aa 267
Jamie Smith 0:6d09d3ad58aa 268 // Calculate the checksum of the current flashbytes
Jamie Smith 0:6d09d3ad58aa 269 uint8_t calcChecksum();
Jamie Smith 0:6d09d3ad58aa 270 };
Jamie Smith 0:6d09d3ad58aa 271 #endif