This class provides APIs to all of the registers of the TI BQ24295 battery charger chip, as used on the u-blox C030 board. This class is not required to charge a battery connected to the C030 board, charging will begin automatically when a battery is connected. This class is only required if the user wishes to monitor the charger's state or change the charger's settings. The caller should instantiate an I2C interface and pass this to init(), which will initialise the chip and place it into its lowest power state. The chip may then be configured using the API calls. Once the chip is configured, battery charging can be enabled. If battery charging is disabled the chip will once more be put into its lowest power state.

Dependents:   example-battery-charger-bq24295 example-C030-out-of-box-demo example-C030-out-of-box-demo Amit

Committer:
rob.meades@u-blox.com
Date:
Wed Aug 02 13:33:58 2017 +0100
Revision:
8:2a758bf86bb7
Parent:
3:340d65a1a133
Add comment concerning the response to getChargerState() on a C030 board and removed spurious "/".

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rob.meades@u-blox.com 1:ed57b6ca43ab 1 /* mbed Microcontroller Library
rob.meades@u-blox.com 1:ed57b6ca43ab 2 * Copyright (c) 2017 u-blox
rob.meades@u-blox.com 1:ed57b6ca43ab 3 *
rob.meades@u-blox.com 1:ed57b6ca43ab 4 * Licensed under the Apache License, Version 2.0 (the "License");
rob.meades@u-blox.com 1:ed57b6ca43ab 5 * you may not use this file except in compliance with the License.
rob.meades@u-blox.com 1:ed57b6ca43ab 6 * You may obtain a copy of the License at
rob.meades@u-blox.com 1:ed57b6ca43ab 7 *
rob.meades@u-blox.com 1:ed57b6ca43ab 8 * http://www.apache.org/licenses/LICENSE-2.0
rob.meades@u-blox.com 1:ed57b6ca43ab 9 *
rob.meades@u-blox.com 1:ed57b6ca43ab 10 * Unless required by applicable law or agreed to in writing, software
rob.meades@u-blox.com 1:ed57b6ca43ab 11 * distributed under the License is distributed on an "AS IS" BASIS,
rob.meades@u-blox.com 1:ed57b6ca43ab 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rob.meades@u-blox.com 1:ed57b6ca43ab 13 * See the License for the specific language governing permissions and
rob.meades@u-blox.com 1:ed57b6ca43ab 14 * limitations under the License.
rob.meades@u-blox.com 1:ed57b6ca43ab 15 */
rob.meades@u-blox.com 1:ed57b6ca43ab 16
rob.meades@u-blox.com 1:ed57b6ca43ab 17 #ifndef BATTERY_CHARGER_BQ24295_H
rob.meades@u-blox.com 1:ed57b6ca43ab 18 #define BATTERY_CHARGER_BQ24295_H
rob.meades@u-blox.com 1:ed57b6ca43ab 19
rob.meades@u-blox.com 1:ed57b6ca43ab 20 /**
rob.meades@u-blox.com 1:ed57b6ca43ab 21 * @file battery_charger_bq24295.h
rob.meades@u-blox.com 1:ed57b6ca43ab 22 * This file defines the API to the TI BQ24295 battery charger chip.
rob.meades@u-blox.com 1:ed57b6ca43ab 23 */
rob.meades@u-blox.com 1:ed57b6ca43ab 24
RobMeades 2:f0bbe0269d67 25 /* ----------------------------------------------------------------
RobMeades 2:f0bbe0269d67 26 * COMPILE-TIME MACROS
RobMeades 2:f0bbe0269d67 27 * -------------------------------------------------------------- */
rob.meades@u-blox.com 1:ed57b6ca43ab 28
RobMeades 2:f0bbe0269d67 29 /** Device I2C address. */
rob.meades@u-blox.com 1:ed57b6ca43ab 30 #define BATTERY_CHARGER_BQ24295_ADDRESS 0x6B
rob.meades@u-blox.com 1:ed57b6ca43ab 31
RobMeades 2:f0bbe0269d67 32 /* ----------------------------------------------------------------
RobMeades 2:f0bbe0269d67 33 * CLASSES
RobMeades 2:f0bbe0269d67 34 * -------------------------------------------------------------- */
rob.meades@u-blox.com 1:ed57b6ca43ab 35
RobMeades 2:f0bbe0269d67 36 /** BQ27441 battery charger driver. */
rob.meades@u-blox.com 1:ed57b6ca43ab 37 class BatteryChargerBq24295 {
rob.meades@u-blox.com 1:ed57b6ca43ab 38 public:
RobMeades 2:f0bbe0269d67 39 /** Charger state. */
rob.meades@u-blox.com 1:ed57b6ca43ab 40 typedef enum {
rob.meades@u-blox.com 1:ed57b6ca43ab 41 CHARGER_STATE_UNKNOWN,
rob.meades@u-blox.com 1:ed57b6ca43ab 42 CHARGER_STATE_DISABLED,
rob.meades@u-blox.com 1:ed57b6ca43ab 43 CHARGER_STATE_NO_EXTERNAL_POWER,
rob.meades@u-blox.com 1:ed57b6ca43ab 44 CHARGER_STATE_NOT_CHARGING,
rob.meades@u-blox.com 1:ed57b6ca43ab 45 CHARGER_STATE_PRECHARGE,
rob.meades@u-blox.com 1:ed57b6ca43ab 46 CHARGER_STATE_FAST_CHARGE,
rob.meades@u-blox.com 1:ed57b6ca43ab 47 CHARGER_STATE_COMPLETE,
rob.meades@u-blox.com 1:ed57b6ca43ab 48 MAX_NUM_CHARGER_STATES
rob.meades@u-blox.com 1:ed57b6ca43ab 49 } ChargerState;
rob.meades@u-blox.com 1:ed57b6ca43ab 50
RobMeades 2:f0bbe0269d67 51 /** Charger faults as a bitmap that matches the chip REG09 definitions. */
rob.meades@u-blox.com 1:ed57b6ca43ab 52 typedef enum {
rob.meades@u-blox.com 1:ed57b6ca43ab 53 CHARGER_FAULT_NONE = 0x00,
rob.meades@u-blox.com 1:ed57b6ca43ab 54 CHARGER_FAULT_THERMISTOR_TOO_HOT = 0x01,
rob.meades@u-blox.com 1:ed57b6ca43ab 55 CHARGER_FAULT_THERMISTOR_TOO_COLD = 0x02,
rob.meades@u-blox.com 1:ed57b6ca43ab 56 // Value 0x04 is reserved
rob.meades@u-blox.com 1:ed57b6ca43ab 57 CHARGER_FAULT_BATTERY_OVER_VOLTAGE = 0x08,
rob.meades@u-blox.com 1:ed57b6ca43ab 58 CHARGER_FAULT_INPUT_FAULT = 0x10, //!< Note that the value of CHARGER_FAULT_CHARGE_TIMER_EXPIRED overlaps this, be careful when testing the bitmap.
rob.meades@u-blox.com 1:ed57b6ca43ab 59 CHARGER_FAULT_THERMAL_SHUTDOWN = 0x20, //!< Note that the value of CHARGER_FAULT_CHARGE_TIMER_EXPIRED overlaps this, be careful when testing the bitmap.
rob.meades@u-blox.com 1:ed57b6ca43ab 60 CHARGER_FAULT_CHARGE_TIMER_EXPIRED = 0x30, //!< This looks odd as it overlaps the two above but it matches the register meaning as defined by the chip.
rob.meades@u-blox.com 1:ed57b6ca43ab 61 CHARGER_FAULT_OTG = 0x40,
rob.meades@u-blox.com 1:ed57b6ca43ab 62 CHARGER_FAULT_WATCHDOG_EXPIRED = 0x80,
rob.meades@u-blox.com 1:ed57b6ca43ab 63 MAX_NUM_CHARGER_FAULTS
rob.meades@u-blox.com 1:ed57b6ca43ab 64 } ChargerFault;
rob.meades@u-blox.com 1:ed57b6ca43ab 65
RobMeades 2:f0bbe0269d67 66 /** Constructor. */
rob.meades@u-blox.com 1:ed57b6ca43ab 67 BatteryChargerBq24295(void);
RobMeades 2:f0bbe0269d67 68 /** Destructor. */
rob.meades@u-blox.com 1:ed57b6ca43ab 69 ~BatteryChargerBq24295(void);
rob.meades@u-blox.com 1:ed57b6ca43ab 70
RobMeades 2:f0bbe0269d67 71 /** Initialise the BQ24295 chip.
RobMeades 2:f0bbe0269d67 72 * After initialisation the chip will be put into its lowest
RobMeades 2:f0bbe0269d67 73 * power state and should be configured if the default settings
rob.meades@u-blox.com 3:340d65a1a133 74 * are not satisfactory.
rob.meades@u-blox.com 3:340d65a1a133 75 * Note: the BQ24295 charging chip will automonously charge a
rob.meades@u-blox.com 3:340d65a1a133 76 * LiPo cell that is connected to it, without host interaction.
rob.meades@u-blox.com 3:340d65a1a133 77 * This class is only required where the configuration of the
rob.meades@u-blox.com 3:340d65a1a133 78 * chip needs to be changed or the charger state is to be monitored.
RobMeades 2:f0bbe0269d67 79 * @param pI2c a pointer to the I2C instance to use.
RobMeades 2:f0bbe0269d67 80 * @param address 7-bit I2C address of the battery charger chip.
RobMeades 2:f0bbe0269d67 81 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 82 */
rob.meades@u-blox.com 1:ed57b6ca43ab 83 bool init (I2C * pI2c, uint8_t address = BATTERY_CHARGER_BQ24295_ADDRESS);
rob.meades@u-blox.com 1:ed57b6ca43ab 84
RobMeades 2:f0bbe0269d67 85 /** Get the charger state.
rob.meades@u-blox.com 8:2a758bf86bb7 86 * Note: on a u-blox C030 board with no battery connected this will report
rob.meades@u-blox.com 8:2a758bf86bb7 87 * CHARGER_STATE_COMPLETE or CHARGER_STATE_FAST_CHARGE rather than
rob.meades@u-blox.com 8:2a758bf86bb7 88 * CHARGER_STATE_NOT_CHARGING.
RobMeades 2:f0bbe0269d67 89 * @return the charge state.
RobMeades 2:f0bbe0269d67 90 */
rob.meades@u-blox.com 1:ed57b6ca43ab 91 ChargerState getChargerState(void);
rob.meades@u-blox.com 1:ed57b6ca43ab 92
RobMeades 2:f0bbe0269d67 93 /** Get whether external power is present or not.
RobMeades 2:f0bbe0269d67 94 * @return true if external power is present, otherwise false.
RobMeades 2:f0bbe0269d67 95 */
rob.meades@u-blox.com 1:ed57b6ca43ab 96 bool isExternalPowerPresent(void);
rob.meades@u-blox.com 1:ed57b6ca43ab 97
RobMeades 2:f0bbe0269d67 98 /** Enable charging.
RobMeades 2:f0bbe0269d67 99 * Default is disabled.
RobMeades 2:f0bbe0269d67 100 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 101 */
rob.meades@u-blox.com 1:ed57b6ca43ab 102 bool enableCharging (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 103
RobMeades 2:f0bbe0269d67 104 /** Disable charging.
RobMeades 2:f0bbe0269d67 105 * Default is disabled.
RobMeades 2:f0bbe0269d67 106 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 107 */
rob.meades@u-blox.com 1:ed57b6ca43ab 108 bool disableCharging (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 109
RobMeades 2:f0bbe0269d67 110 /** Get the state of charging (enabled or disabled).
RobMeades 2:f0bbe0269d67 111 * @return true if charging is enabled, otherwise false.
RobMeades 2:f0bbe0269d67 112 */
rob.meades@u-blox.com 1:ed57b6ca43ab 113 bool isChargingEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 114
RobMeades 2:f0bbe0269d67 115 /** Enable OTG charging.
RobMeades 2:f0bbe0269d67 116 * Default is enabled.
RobMeades 2:f0bbe0269d67 117 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 118 */
rob.meades@u-blox.com 1:ed57b6ca43ab 119 bool enableOtg (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 120
RobMeades 2:f0bbe0269d67 121 /** Disable OTG charging.
RobMeades 2:f0bbe0269d67 122 * Default is enabled.
RobMeades 2:f0bbe0269d67 123 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 124 */
rob.meades@u-blox.com 1:ed57b6ca43ab 125 bool disableOtg (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 126
RobMeades 2:f0bbe0269d67 127 /** Determine whether OTG charging is enabled or not.
RobMeades 2:f0bbe0269d67 128 * @return true if OTG charging is enabled, otherwise false.
RobMeades 2:f0bbe0269d67 129 */
rob.meades@u-blox.com 1:ed57b6ca43ab 130 bool isOtgEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 131
RobMeades 2:f0bbe0269d67 132 /** Set the system voltage (the voltage which the
RobMeades 2:f0bbe0269d67 133 * chip will attempt to maintain the system at).
RobMeades 2:f0bbe0269d67 134 * @param voltageMV the voltage limit, in milliVolts.
RobMeades 2:f0bbe0269d67 135 * Range is 3000 mV to 3700 mV, default 3500 mV.
RobMeades 2:f0bbe0269d67 136 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 137 */
rob.meades@u-blox.com 1:ed57b6ca43ab 138 bool setSystemVoltage (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 139
RobMeades 2:f0bbe0269d67 140 /** Get the system voltage.
RobMeades 2:f0bbe0269d67 141 * @param pVoltageMV a place to put the system voltage limit.
RobMeades 2:f0bbe0269d67 142 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 143 */
rob.meades@u-blox.com 1:ed57b6ca43ab 144 bool getSystemVoltage (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 145
RobMeades 2:f0bbe0269d67 146 /** Set the fast charging current limit.
RobMeades 2:f0bbe0269d67 147 * @param currentMA the fast charging current limit, in milliAmps.
RobMeades 2:f0bbe0269d67 148 * Range is 512 mA to 3008 mA, default 1024 mA.
RobMeades 2:f0bbe0269d67 149 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 150 */
rob.meades@u-blox.com 1:ed57b6ca43ab 151 bool setFastChargingCurrentLimit (int32_t currentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 152
RobMeades 2:f0bbe0269d67 153 /** Get the fast charging current limit.
RobMeades 2:f0bbe0269d67 154 * @param pCurrentMA a place to put the fast charging current limit.
RobMeades 2:f0bbe0269d67 155 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 156 */
rob.meades@u-blox.com 1:ed57b6ca43ab 157 bool getFastChargingCurrentLimit (int32_t *pCurrentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 158
RobMeades 2:f0bbe0269d67 159 /** Set the fast charging safety timer.
RobMeades 2:f0bbe0269d67 160 * @param timerHours the charging safety timer value.
RobMeades 2:f0bbe0269d67 161 * Use a value of 0 to indicate that the timer should be disabled.
RobMeades 2:f0bbe0269d67 162 * Timer values will be translated to the nearest (lower) value
RobMeades 2:f0bbe0269d67 163 * out of 5, 8, 12, and 20 hours, default 12 hours.
RobMeades 2:f0bbe0269d67 164 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 165 */
rob.meades@u-blox.com 1:ed57b6ca43ab 166 bool setFastChargingSafetyTimer (int32_t timerHours);
rob.meades@u-blox.com 1:ed57b6ca43ab 167
RobMeades 2:f0bbe0269d67 168 /** Get the fast charging safety timer value.
RobMeades 2:f0bbe0269d67 169 * @param pTimerHours a place to put the charging safety timer value.
RobMeades 2:f0bbe0269d67 170 * Returned value is zero if the fast charging safety timer is disabled.
RobMeades 2:f0bbe0269d67 171 * @return true if charging termination is enabled, otherwise false.
RobMeades 2:f0bbe0269d67 172 */
rob.meades@u-blox.com 1:ed57b6ca43ab 173 bool getFastChargingSafetyTimer (int32_t *pTimerHours);
rob.meades@u-blox.com 1:ed57b6ca43ab 174
RobMeades 2:f0bbe0269d67 175 /** Set ICHG/IPRECH margin (see section 8.3.3.5 of the chip data sheet).
RobMeades 2:f0bbe0269d67 176 * Default is disabled.
RobMeades 2:f0bbe0269d67 177 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 178 */
rob.meades@u-blox.com 1:ed57b6ca43ab 179 bool enableIcghIprechMargin (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 180
RobMeades 2:f0bbe0269d67 181 /** Clear the ICHG/IPRECH margin (see section 8.3.3.5 of the chip data sheet).
RobMeades 2:f0bbe0269d67 182 * Default is disabled.
RobMeades 2:f0bbe0269d67 183 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 184 */
rob.meades@u-blox.com 1:ed57b6ca43ab 185 bool disableIcghIprechMargin (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 186
RobMeades 2:f0bbe0269d67 187 /** Check if the ICHG/IPRECH margin is set (see section 8.3.3.5 of
RobMeades 2:f0bbe0269d67 188 * the chip data sheet).
RobMeades 2:f0bbe0269d67 189 * @return true if the ICHG/IPRECH margin is enabled, otherwise false.
RobMeades 2:f0bbe0269d67 190 */
rob.meades@u-blox.com 1:ed57b6ca43ab 191 bool isIcghIprechMarginEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 192
RobMeades 2:f0bbe0269d67 193 /** Set the charging termination current.
RobMeades 2:f0bbe0269d67 194 * @param currentMA the charging termination current, in milliAmps.
RobMeades 2:f0bbe0269d67 195 * Range is 128 mA to 2048 mA, default is 256 mA.
RobMeades 2:f0bbe0269d67 196 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 197 */
rob.meades@u-blox.com 1:ed57b6ca43ab 198 bool setChargingTerminationCurrent (int32_t currentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 199
RobMeades 2:f0bbe0269d67 200 /** Get the charging termination current.
RobMeades 2:f0bbe0269d67 201 * @param pCurrentMA a place to put the charging termination current.
RobMeades 2:f0bbe0269d67 202 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 203 */
rob.meades@u-blox.com 1:ed57b6ca43ab 204 bool getChargingTerminationCurrent (int32_t *pCurrentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 205
RobMeades 2:f0bbe0269d67 206 /** Enable charging termination.
RobMeades 2:f0bbe0269d67 207 * Default is enabled.
RobMeades 2:f0bbe0269d67 208 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 209 */
rob.meades@u-blox.com 1:ed57b6ca43ab 210 bool enableChargingTermination (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 211
RobMeades 2:f0bbe0269d67 212 /** Disable charging termination.
RobMeades 2:f0bbe0269d67 213 * Default is enabled.
RobMeades 2:f0bbe0269d67 214 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 215 */
rob.meades@u-blox.com 1:ed57b6ca43ab 216 bool disableChargingTermination (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 217
RobMeades 2:f0bbe0269d67 218 /** Get the state of charging termination (enabled or disabled).
RobMeades 2:f0bbe0269d67 219 * @return true if charging termination is enabled, otherwise false.
RobMeades 2:f0bbe0269d67 220 */
rob.meades@u-blox.com 1:ed57b6ca43ab 221 bool isChargingTerminationEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 222
RobMeades 2:f0bbe0269d67 223 /** Set the pre-charging current limit.
RobMeades 2:f0bbe0269d67 224 * @param currentMA the pre-charging current limit, in milliAmps.
RobMeades 2:f0bbe0269d67 225 * Range is 128 mA to 2048 mA, default is 256 mA.
RobMeades 2:f0bbe0269d67 226 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 227 */
rob.meades@u-blox.com 1:ed57b6ca43ab 228 bool setPrechargingCurrentLimit (int32_t currentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 229
RobMeades 2:f0bbe0269d67 230 /** Get the pre-charging current limit.
RobMeades 2:f0bbe0269d67 231 * @param pCurrentMA a place to put the pre-charging current limit.
RobMeades 2:f0bbe0269d67 232 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 233 */
rob.meades@u-blox.com 1:ed57b6ca43ab 234 bool getPrechargingCurrentLimit (int32_t *pCurrentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 235
RobMeades 2:f0bbe0269d67 236 /** Set the charging voltage limit.
RobMeades 2:f0bbe0269d67 237 * @param voltageMV the charging voltage limit, in milliVolts.
RobMeades 2:f0bbe0269d67 238 * Range is 3504 mV to 4400 mV, default is 4208 mV.
RobMeades 2:f0bbe0269d67 239 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 240 */
rob.meades@u-blox.com 1:ed57b6ca43ab 241 bool setChargingVoltageLimit (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 242
RobMeades 2:f0bbe0269d67 243 /** Get the charging voltage limit.
RobMeades 2:f0bbe0269d67 244 * @param pVoltageMV a place to put the charging voltage limit,
RobMeades 2:f0bbe0269d67 245 * in milliVolts.
RobMeades 2:f0bbe0269d67 246 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 247 */
rob.meades@u-blox.com 1:ed57b6ca43ab 248 bool getChargingVoltageLimit (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 249
RobMeades 2:f0bbe0269d67 250 /** Set the pre-charge to fast-charge voltage threshold.
RobMeades 2:f0bbe0269d67 251 * @param voltageMV the threshold, in milliVolts.
RobMeades 2:f0bbe0269d67 252 * Values will be translated to the nearest (highest)
RobMeades 2:f0bbe0269d67 253 * voltage out of 2800 mV and 3000 mV, default is 3000 mV.
RobMeades 2:f0bbe0269d67 254 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 255 */
rob.meades@u-blox.com 1:ed57b6ca43ab 256 bool setFastChargingVoltageThreshold (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 257
RobMeades 2:f0bbe0269d67 258 /** Get the pre-charge to fast-charge voltage threshold.
RobMeades 2:f0bbe0269d67 259 * @param pVoltageMV a place to put the threshold, in milliVolts.
RobMeades 2:f0bbe0269d67 260 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 261 */
rob.meades@u-blox.com 1:ed57b6ca43ab 262 bool getFastChargingVoltageThreshold (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 263
RobMeades 2:f0bbe0269d67 264 /** Set the recharging voltage threshold.
RobMeades 2:f0bbe0269d67 265 * @param voltageMV the recharging voltage threshold, in milliVolts.
RobMeades 2:f0bbe0269d67 266 * Values will be translated to the nearest (highest)
RobMeades 2:f0bbe0269d67 267 * voltage out of 100 mV and 300 mV, default is 100 mV.
RobMeades 2:f0bbe0269d67 268 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 269 */
rob.meades@u-blox.com 1:ed57b6ca43ab 270 bool setRechargingVoltageThreshold (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 271
RobMeades 2:f0bbe0269d67 272 /** Get the recharging voltage threshold.
RobMeades 2:f0bbe0269d67 273 * @param pVoltageMV a place to put the charging voltage threshold, in milliVolts.
RobMeades 2:f0bbe0269d67 274 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 275 */
rob.meades@u-blox.com 1:ed57b6ca43ab 276 bool getRechargingVoltageThreshold (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 277
RobMeades 2:f0bbe0269d67 278 /** Set the boost voltage.
RobMeades 2:f0bbe0269d67 279 * @param voltageMV the boost voltage, in milliVolts.
RobMeades 2:f0bbe0269d67 280 * Range is 4550 mV to 5510 mV, default is 5126 mV.
RobMeades 2:f0bbe0269d67 281 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 282 */
rob.meades@u-blox.com 1:ed57b6ca43ab 283 bool setBoostVoltage (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 284
RobMeades 2:f0bbe0269d67 285 /** Get the boost voltage.
RobMeades 2:f0bbe0269d67 286 * @param pVoltageMV a place to put the boost voltage, in milliVolts.
RobMeades 2:f0bbe0269d67 287 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 288 */
rob.meades@u-blox.com 1:ed57b6ca43ab 289 bool getBoostVoltage (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 290
RobMeades 2:f0bbe0269d67 291 /** Set the boost mode upper temperature limit.
RobMeades 2:f0bbe0269d67 292 * @param temperatureC the temperature in C.
RobMeades 2:f0bbe0269d67 293 * Values will be translated to the nearest (lower)
RobMeades 2:f0bbe0269d67 294 * of 55 C, 60 C and 65 C (disabled by default).
RobMeades 2:f0bbe0269d67 295 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 296 */
rob.meades@u-blox.com 1:ed57b6ca43ab 297 bool setBoostUpperTemperatureLimit (int32_t temperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 298
RobMeades 2:f0bbe0269d67 299 /** Get the boost mode upper temperature limit.
RobMeades 2:f0bbe0269d67 300 * If the boost mode upper temperature limit is not
RobMeades 2:f0bbe0269d67 301 * enabled then pTemperatureC will remain untouched and false
RobMeades 2:f0bbe0269d67 302 * will be returned.
RobMeades 2:f0bbe0269d67 303 * @param pTemperatureC a place to put the temperature.
RobMeades 2:f0bbe0269d67 304 * @return true if successful and a limit was set, otherwise false.
RobMeades 2:f0bbe0269d67 305 */
rob.meades@u-blox.com 1:ed57b6ca43ab 306 bool getBoostUpperTemperatureLimit (int32_t *pTemperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 307
RobMeades 2:f0bbe0269d67 308 /** Check whether the boost mode upper temperature limit is enabled.
RobMeades 2:f0bbe0269d67 309 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 310 */
rob.meades@u-blox.com 1:ed57b6ca43ab 311 bool isBoostUpperTemperatureLimitEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 312
RobMeades 2:f0bbe0269d67 313 /** Disable the boost mode upper temperature limit.
RobMeades 2:f0bbe0269d67 314 * Default is disabled.
RobMeades 2:f0bbe0269d67 315 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 316 */
rob.meades@u-blox.com 1:ed57b6ca43ab 317 bool disableBoostUpperTemperatureLimit (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 318
RobMeades 2:f0bbe0269d67 319 /** Set the boost mode low temperature limit.
RobMeades 2:f0bbe0269d67 320 * @param temperatureC the temperature in C.
RobMeades 2:f0bbe0269d67 321 * Values will be translated to the nearest (higher)
RobMeades 2:f0bbe0269d67 322 * of -10 C and -20 C, default is -10 C.
RobMeades 2:f0bbe0269d67 323 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 324 */
rob.meades@u-blox.com 1:ed57b6ca43ab 325 bool setBoostLowerTemperatureLimit (int32_t temperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 326
RobMeades 2:f0bbe0269d67 327 /** Get the boost mode low temperature limit.
RobMeades 2:f0bbe0269d67 328 * @param pTemperatureC a place to put the temperature.
RobMeades 2:f0bbe0269d67 329 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 330 */
rob.meades@u-blox.com 1:ed57b6ca43ab 331 bool getBoostLowerTemperatureLimit (int32_t *pTemperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 332
RobMeades 2:f0bbe0269d67 333 /** Set the input voltage limit. If the input falls below
RobMeades 2:f0bbe0269d67 334 * this level then charging will be ramped down. The limit
RobMeades 2:f0bbe0269d67 335 * does not take effect until enableInputLimits() is called
RobMeades 2:f0bbe0269d67 336 * (default setting is disabled).
RobMeades 2:f0bbe0269d67 337 * @param voltageMV the input voltage limit, in milliVolts.
RobMeades 2:f0bbe0269d67 338 * Range is 3880 mV to 5080 mV, default is 4760 mV.
RobMeades 2:f0bbe0269d67 339 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 340 */
rob.meades@u-blox.com 1:ed57b6ca43ab 341 bool setInputVoltageLimit (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 342
RobMeades 2:f0bbe0269d67 343 /** Get the input voltage limit.
RobMeades 2:f0bbe0269d67 344 * @param pVoltageMV a place to put the input voltage limit.
RobMeades 2:f0bbe0269d67 345 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 346 */
rob.meades@u-blox.com 1:ed57b6ca43ab 347 bool getInputVoltageLimit (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 348
RobMeades 2:f0bbe0269d67 349 /** Set the input current limit. If the current drawn
RobMeades 2:f0bbe0269d67 350 * goes above this limit then charging will be ramped down.
RobMeades 2:f0bbe0269d67 351 * The limit does not take effect until enableInputLimits()
RobMeades 2:f0bbe0269d67 352 * is called (default setting is disabled).
RobMeades 2:f0bbe0269d67 353 * @param currentMA the input current limit, in milliAmps.
RobMeades 2:f0bbe0269d67 354 * Range is 100 mA to 3000 mA, default depends upon
RobMeades 2:f0bbe0269d67 355 * hardware configuration, see section 8.3.1.4.3 of
RobMeades 2:f0bbe0269d67 356 * the data sheet.
RobMeades 2:f0bbe0269d67 357 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 358 */
rob.meades@u-blox.com 1:ed57b6ca43ab 359 bool setInputCurrentLimit (int32_t currentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 360
RobMeades 2:f0bbe0269d67 361 /** Get the input current limit.
RobMeades 2:f0bbe0269d67 362 * @param pCurrentMA a place to put the input current limit.
RobMeades 2:f0bbe0269d67 363 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 364 */
rob.meades@u-blox.com 1:ed57b6ca43ab 365 bool getInputCurrentLimit (int32_t *pCurrentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 366
RobMeades 2:f0bbe0269d67 367 /** Enable input voltage and current limits.
RobMeades 2:f0bbe0269d67 368 * Default is disabled.
RobMeades 2:f0bbe0269d67 369 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 370 */
rob.meades@u-blox.com 1:ed57b6ca43ab 371 bool enableInputLimits (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 372
RobMeades 2:f0bbe0269d67 373 /** Remove any input voltage or current limits.
RobMeades 2:f0bbe0269d67 374 * Default is disabled.
RobMeades 2:f0bbe0269d67 375 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 376 */
rob.meades@u-blox.com 1:ed57b6ca43ab 377 bool disableInputLimits (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 378
RobMeades 2:f0bbe0269d67 379 /** Check whether input limits are enabled.
RobMeades 2:f0bbe0269d67 380 * @return true if input limits are enabled, otherwise false.
RobMeades 2:f0bbe0269d67 381 */
rob.meades@u-blox.com 1:ed57b6ca43ab 382 bool areInputLimitsEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 383
RobMeades 2:f0bbe0269d67 384 /** Set the thermal regulation threshold for the chip.
RobMeades 2:f0bbe0269d67 385 * @param temperatureC the temperature in C.
RobMeades 2:f0bbe0269d67 386 * Values will be translated to the nearest (lower)
RobMeades 2:f0bbe0269d67 387 * of 60 C, 80 C, 100 C and 120 C, default 120 C.
RobMeades 2:f0bbe0269d67 388 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 389 */
rob.meades@u-blox.com 1:ed57b6ca43ab 390 bool setChipThermalRegulationThreshold (int32_t temperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 391
RobMeades 2:f0bbe0269d67 392 /** Get the thermal regulation threshold for the chip.
RobMeades 2:f0bbe0269d67 393 * @param pTemperatureC a place to put the temperature.
RobMeades 2:f0bbe0269d67 394 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 395 */
rob.meades@u-blox.com 1:ed57b6ca43ab 396 bool getChipThermalRegulationThreshold (int32_t *pTemperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 397
RobMeades 2:f0bbe0269d67 398 /** Get the charger faults.
RobMeades 2:f0bbe0269d67 399 * Note: as with all the other API functions here, this should
RobMeades 2:f0bbe0269d67 400 * not be called from an interrupt function as the comms with the
RobMeades 2:f0bbe0269d67 401 * chip over I2C will take too long.
RobMeades 2:f0bbe0269d67 402 * @return a bit-map of that can be tested against ChargerFault.
RobMeades 2:f0bbe0269d67 403 */
rob.meades@u-blox.com 1:ed57b6ca43ab 404 char getChargerFaults(void);
rob.meades@u-blox.com 1:ed57b6ca43ab 405
rob.meades@u-blox.com 3:340d65a1a133 406 /** Feed the watchdog timer.
rob.meades@u-blox.com 3:340d65a1a133 407 * Use this if it is necessary to keep the BQ24295 chip in Host
rob.meades@u-blox.com 3:340d65a1a133 408 * mode (see section 8.4.1 of the data sheet for details).
rob.meades@u-blox.com 3:340d65a1a133 409 * @return true if successful, otherwise false.
rob.meades@u-blox.com 3:340d65a1a133 410 */
rob.meades@u-blox.com 3:340d65a1a133 411 bool feedWatchdog(void);
rob.meades@u-blox.com 3:340d65a1a133 412
rob.meades@u-blox.com 3:340d65a1a133 413 /** Get the watchdog timer of the BQ24295 chip.
rob.meades@u-blox.com 3:340d65a1a133 414 * @param pWatchdogS a place to put the watchdog timer (in seconds).
rob.meades@u-blox.com 3:340d65a1a133 415 * @return true if successful, otherwise false.
rob.meades@u-blox.com 3:340d65a1a133 416 */
rob.meades@u-blox.com 3:340d65a1a133 417 bool getWatchdog (int32_t *pWatchdogS);
rob.meades@u-blox.com 3:340d65a1a133 418
rob.meades@u-blox.com 3:340d65a1a133 419 /** Set the watchdog timer of the BQ24295 chip.
rob.meades@u-blox.com 3:340d65a1a133 420 * @param watchdogS the watchdog timer (in seconds), 0 to disable,
rob.meades@u-blox.com 3:340d65a1a133 421 * max 160 seconds.
rob.meades@u-blox.com 3:340d65a1a133 422 * @return true if successful, otherwise false.
rob.meades@u-blox.com 3:340d65a1a133 423 */
rob.meades@u-blox.com 3:340d65a1a133 424 bool setWatchdog (int32_t watchdogS);
rob.meades@u-blox.com 3:340d65a1a133 425
RobMeades 2:f0bbe0269d67 426 /** Enable shipping mode.
RobMeades 2:f0bbe0269d67 427 * In shipping mode the battery is disconnected from the system
RobMeades 2:f0bbe0269d67 428 * to avoid leakage. Default is disabled.
RobMeades 2:f0bbe0269d67 429 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 430 */
rob.meades@u-blox.com 1:ed57b6ca43ab 431 bool enableShippingMode (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 432
RobMeades 2:f0bbe0269d67 433 /** Disable shipping mode.
RobMeades 2:f0bbe0269d67 434 * In shipping mode the battery is disconnected from the system
RobMeades 2:f0bbe0269d67 435 * to avoid leakage. Default is disabled.
RobMeades 2:f0bbe0269d67 436 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 437 */
rob.meades@u-blox.com 1:ed57b6ca43ab 438 bool disableShippingMode (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 439
RobMeades 2:f0bbe0269d67 440 /** Check whether shipping mode is enabled.
RobMeades 2:f0bbe0269d67 441 * @return true if input limits are enabled, otherwise false.
RobMeades 2:f0bbe0269d67 442 */
rob.meades@u-blox.com 1:ed57b6ca43ab 443 bool isShippingModeEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 444
RobMeades 2:f0bbe0269d67 445 /** Advanced function to read a register on the chip.
RobMeades 2:f0bbe0269d67 446 * @param address the address to read from.
RobMeades 2:f0bbe0269d67 447 * @param pValue a place to put the returned value.
RobMeades 2:f0bbe0269d67 448 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 449 */
rob.meades@u-blox.com 1:ed57b6ca43ab 450 bool advancedGet(char address, char *pValue);
rob.meades@u-blox.com 1:ed57b6ca43ab 451
RobMeades 2:f0bbe0269d67 452 /** Advanced function to set a register on the chip.
RobMeades 2:f0bbe0269d67 453 * @param address the address to write to.
RobMeades 2:f0bbe0269d67 454 * @param value the value to write.
RobMeades 2:f0bbe0269d67 455 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 456 */
rob.meades@u-blox.com 1:ed57b6ca43ab 457 bool advancedSet(char address, char value);
rob.meades@u-blox.com 1:ed57b6ca43ab 458
rob.meades@u-blox.com 1:ed57b6ca43ab 459 protected:
RobMeades 2:f0bbe0269d67 460 /** Pointer to the I2C interface. */
rob.meades@u-blox.com 1:ed57b6ca43ab 461 I2C * gpI2c;
RobMeades 2:f0bbe0269d67 462 /** The address of the device. */
rob.meades@u-blox.com 1:ed57b6ca43ab 463 uint8_t gAddress;
RobMeades 2:f0bbe0269d67 464 /** Flag to indicate device is ready */
rob.meades@u-blox.com 1:ed57b6ca43ab 465 bool gReady;
rob.meades@u-blox.com 1:ed57b6ca43ab 466
RobMeades 2:f0bbe0269d67 467 /** Read a register.
RobMeades 2:f0bbe0269d67 468 * Note: gpI2c should be locked before this is called.
RobMeades 2:f0bbe0269d67 469 * @param address the address to read from.
RobMeades 2:f0bbe0269d67 470 * @param pValue a place to put the returned value.
RobMeades 2:f0bbe0269d67 471 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 472 */
rob.meades@u-blox.com 1:ed57b6ca43ab 473 bool getRegister(char address, char *pValue);
rob.meades@u-blox.com 1:ed57b6ca43ab 474
RobMeades 2:f0bbe0269d67 475 /** Set a register.
RobMeades 2:f0bbe0269d67 476 * Note: gpI2c should be locked before this is called.
RobMeades 2:f0bbe0269d67 477 * @param address the address to write to.
RobMeades 2:f0bbe0269d67 478 * @param value the value to write.
RobMeades 2:f0bbe0269d67 479 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 480 */
rob.meades@u-blox.com 1:ed57b6ca43ab 481 bool setRegister(char address, char value);
rob.meades@u-blox.com 1:ed57b6ca43ab 482
RobMeades 2:f0bbe0269d67 483 /** Set a mask of bits in a register.
RobMeades 2:f0bbe0269d67 484 * Note: gpI2c should be locked before this is called.
RobMeades 2:f0bbe0269d67 485 * @param address the address to write to.
RobMeades 2:f0bbe0269d67 486 * @param mask the mask of bits to set.
RobMeades 2:f0bbe0269d67 487 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 488 */
rob.meades@u-blox.com 1:ed57b6ca43ab 489 bool setRegisterBits(char address, char mask);
rob.meades@u-blox.com 1:ed57b6ca43ab 490
RobMeades 2:f0bbe0269d67 491 /** Clear a mask of bits in a register.
RobMeades 2:f0bbe0269d67 492 * Note: gpI2c should be locked before this is called.
RobMeades 2:f0bbe0269d67 493 * @param address the address to write to.
RobMeades 2:f0bbe0269d67 494 * @param mask the mask of bits to clear.
RobMeades 2:f0bbe0269d67 495 * @return true if successful, otherwise false.
RobMeades 2:f0bbe0269d67 496 */
rob.meades@u-blox.com 1:ed57b6ca43ab 497 bool clearRegisterBits(char address, char mask);
rob.meades@u-blox.com 1:ed57b6ca43ab 498 };
rob.meades@u-blox.com 1:ed57b6ca43ab 499
rob.meades@u-blox.com 1:ed57b6ca43ab 500 #endif
rob.meades@u-blox.com 1:ed57b6ca43ab 501
RobMeades 2:f0bbe0269d67 502 /* End Of File */