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:
Mon Apr 10 11:04:15 2017 +0100
Revision:
1:ed57b6ca43ab
Child:
2:f0bbe0269d67
Add files to repo, removing README.md as that description is now in the repo description of the on-line IDE.

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
rob.meades@u-blox.com 1:ed57b6ca43ab 25 // ----------------------------------------------------------------
rob.meades@u-blox.com 1:ed57b6ca43ab 26 // COMPILE-TIME MACROS
rob.meades@u-blox.com 1:ed57b6ca43ab 27 // ----------------------------------------------------------------
rob.meades@u-blox.com 1:ed57b6ca43ab 28
rob.meades@u-blox.com 1:ed57b6ca43ab 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
rob.meades@u-blox.com 1:ed57b6ca43ab 32 // ----------------------------------------------------------------
rob.meades@u-blox.com 1:ed57b6ca43ab 33 // CLASSES
rob.meades@u-blox.com 1:ed57b6ca43ab 34 // ----------------------------------------------------------------
rob.meades@u-blox.com 1:ed57b6ca43ab 35
rob.meades@u-blox.com 1:ed57b6ca43ab 36 /// BQ27441 battery charger driver.
rob.meades@u-blox.com 1:ed57b6ca43ab 37 class BatteryChargerBq24295 {
rob.meades@u-blox.com 1:ed57b6ca43ab 38 public:
rob.meades@u-blox.com 1:ed57b6ca43ab 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
rob.meades@u-blox.com 1:ed57b6ca43ab 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
rob.meades@u-blox.com 1:ed57b6ca43ab 66 /// Constructor.
rob.meades@u-blox.com 1:ed57b6ca43ab 67 BatteryChargerBq24295(void);
rob.meades@u-blox.com 1:ed57b6ca43ab 68 /// Destructor.
rob.meades@u-blox.com 1:ed57b6ca43ab 69 ~BatteryChargerBq24295(void);
rob.meades@u-blox.com 1:ed57b6ca43ab 70
rob.meades@u-blox.com 1:ed57b6ca43ab 71 /// Initialise the BQ24295 chip.
rob.meades@u-blox.com 1:ed57b6ca43ab 72 // After initialisation the chip will be put into its lowest
rob.meades@u-blox.com 1:ed57b6ca43ab 73 // power state and should be configured if the default settings
rob.meades@u-blox.com 1:ed57b6ca43ab 74 // are not satisfactory. Once the chip is correctly configured,
rob.meades@u-blox.com 1:ed57b6ca43ab 75 // charging should be enabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 76 // \param pI2c a pointer to the I2C instance to use.
rob.meades@u-blox.com 1:ed57b6ca43ab 77 //\ param address 7-bit I2C address of the battery charger chip.
rob.meades@u-blox.com 1:ed57b6ca43ab 78 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 79 bool init (I2C * pI2c, uint8_t address = BATTERY_CHARGER_BQ24295_ADDRESS);
rob.meades@u-blox.com 1:ed57b6ca43ab 80
rob.meades@u-blox.com 1:ed57b6ca43ab 81 /// Get the charger state.
rob.meades@u-blox.com 1:ed57b6ca43ab 82 // \return the charge state.
rob.meades@u-blox.com 1:ed57b6ca43ab 83 ChargerState getChargerState(void);
rob.meades@u-blox.com 1:ed57b6ca43ab 84
rob.meades@u-blox.com 1:ed57b6ca43ab 85 /// Get whether external power is present or not.
rob.meades@u-blox.com 1:ed57b6ca43ab 86 // \return true if external power is present, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 87 bool isExternalPowerPresent(void);
rob.meades@u-blox.com 1:ed57b6ca43ab 88
rob.meades@u-blox.com 1:ed57b6ca43ab 89 /// Enable charging.
rob.meades@u-blox.com 1:ed57b6ca43ab 90 // Default is disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 91 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 92 bool enableCharging (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 93
rob.meades@u-blox.com 1:ed57b6ca43ab 94 /// Disable charging.
rob.meades@u-blox.com 1:ed57b6ca43ab 95 // Default is disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 96 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 97 bool disableCharging (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 98
rob.meades@u-blox.com 1:ed57b6ca43ab 99 /// Get the state of charging (enabled or disabled).
rob.meades@u-blox.com 1:ed57b6ca43ab 100 // \return true if charging is enabled, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 101 bool isChargingEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 102
rob.meades@u-blox.com 1:ed57b6ca43ab 103 /// Enable OTG charging.
rob.meades@u-blox.com 1:ed57b6ca43ab 104 // Default is enabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 105 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 106 bool enableOtg (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 107
rob.meades@u-blox.com 1:ed57b6ca43ab 108 /// Disable OTG charging.
rob.meades@u-blox.com 1:ed57b6ca43ab 109 // Default is enabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 110 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 111 bool disableOtg (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 112
rob.meades@u-blox.com 1:ed57b6ca43ab 113 /// Determine whether OTG charging is enabled or not.
rob.meades@u-blox.com 1:ed57b6ca43ab 114 // \return true if OTG charging is enabled, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 115 bool isOtgEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 116
rob.meades@u-blox.com 1:ed57b6ca43ab 117 /// Set the system voltage (the voltage which the
rob.meades@u-blox.com 1:ed57b6ca43ab 118 // chip will attempt to maintain the system at).
rob.meades@u-blox.com 1:ed57b6ca43ab 119 // \param voltageMV the voltage limit, in milliVolts.
rob.meades@u-blox.com 1:ed57b6ca43ab 120 // Range is 3000 mV to 3700 mV, default 3500 mV.
rob.meades@u-blox.com 1:ed57b6ca43ab 121 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 122 bool setSystemVoltage (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 123
rob.meades@u-blox.com 1:ed57b6ca43ab 124 /// Get the system voltage.
rob.meades@u-blox.com 1:ed57b6ca43ab 125 // \param pVoltageMV a place to put the system voltage limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 126 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 127 bool getSystemVoltage (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 128
rob.meades@u-blox.com 1:ed57b6ca43ab 129 /// Set the fast charging current limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 130 // \param currentMA the fast charging current limit, in milliAmps.
rob.meades@u-blox.com 1:ed57b6ca43ab 131 // Range is 512 mA to 3008 mA, default 1024 mA.
rob.meades@u-blox.com 1:ed57b6ca43ab 132 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 133 bool setFastChargingCurrentLimit (int32_t currentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 134
rob.meades@u-blox.com 1:ed57b6ca43ab 135 /// Get the fast charging current limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 136 // \param pCurrentMA a place to put the fast charging current limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 137 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 138 bool getFastChargingCurrentLimit (int32_t *pCurrentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 139
rob.meades@u-blox.com 1:ed57b6ca43ab 140 /// Set the fast charging safety timer.
rob.meades@u-blox.com 1:ed57b6ca43ab 141 // \param timerHours the charging safety timer value.
rob.meades@u-blox.com 1:ed57b6ca43ab 142 // Use a value of 0 to indicate that the timer should be disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 143 // Timer values will be translated to the nearest (lower) value
rob.meades@u-blox.com 1:ed57b6ca43ab 144 // out of 5, 8, 12, and 20 hours, default 12 hours.
rob.meades@u-blox.com 1:ed57b6ca43ab 145 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 146 bool setFastChargingSafetyTimer (int32_t timerHours);
rob.meades@u-blox.com 1:ed57b6ca43ab 147
rob.meades@u-blox.com 1:ed57b6ca43ab 148 /// Get the fast charging safety timer value.
rob.meades@u-blox.com 1:ed57b6ca43ab 149 // \param pTimerHours a place to put the charging safety timer value.
rob.meades@u-blox.com 1:ed57b6ca43ab 150 // Returned value is zero if the fast charging safety timer is disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 151 // \return true if charging termination is enabled, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 152 bool getFastChargingSafetyTimer (int32_t *pTimerHours);
rob.meades@u-blox.com 1:ed57b6ca43ab 153
rob.meades@u-blox.com 1:ed57b6ca43ab 154 /// Set ICHG/IPRECH margin (see section 8.3.3.5 of the chip data sheet).
rob.meades@u-blox.com 1:ed57b6ca43ab 155 // Default is disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 156 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 157 bool enableIcghIprechMargin (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 158
rob.meades@u-blox.com 1:ed57b6ca43ab 159 /// Clear the ICHG/IPRECH margin (see section 8.3.3.5 of the chip data sheet).
rob.meades@u-blox.com 1:ed57b6ca43ab 160 // Default is disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 161 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 162 bool disableIcghIprechMargin (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 163
rob.meades@u-blox.com 1:ed57b6ca43ab 164 /// Check if the ICHG/IPRECH margin is set (see section 8.3.3.5 of
rob.meades@u-blox.com 1:ed57b6ca43ab 165 // the chip data sheet).
rob.meades@u-blox.com 1:ed57b6ca43ab 166 // \return true if the ICHG/IPRECH margin is enabled, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 167 bool isIcghIprechMarginEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 168
rob.meades@u-blox.com 1:ed57b6ca43ab 169 /// Set the charging termination current.
rob.meades@u-blox.com 1:ed57b6ca43ab 170 // \param currentMA the charging termination current, in milliAmps.
rob.meades@u-blox.com 1:ed57b6ca43ab 171 // Range is 128 mA to 2048 mA, default is 256 mA.
rob.meades@u-blox.com 1:ed57b6ca43ab 172 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 173 bool setChargingTerminationCurrent (int32_t currentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 174
rob.meades@u-blox.com 1:ed57b6ca43ab 175 /// Get the charging termination current.
rob.meades@u-blox.com 1:ed57b6ca43ab 176 // \param pCurrentMA a place to put the charging termination current.
rob.meades@u-blox.com 1:ed57b6ca43ab 177 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 178 bool getChargingTerminationCurrent (int32_t *pCurrentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 179
rob.meades@u-blox.com 1:ed57b6ca43ab 180 /// Enable charging termination.
rob.meades@u-blox.com 1:ed57b6ca43ab 181 // Default is enabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 182 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 183 bool enableChargingTermination (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 184
rob.meades@u-blox.com 1:ed57b6ca43ab 185 /// Disable charging termination.
rob.meades@u-blox.com 1:ed57b6ca43ab 186 // Default is enabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 187 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 188 bool disableChargingTermination (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 189
rob.meades@u-blox.com 1:ed57b6ca43ab 190 /// Get the state of charging termination (enabled or disabled).
rob.meades@u-blox.com 1:ed57b6ca43ab 191 // \return true if charging termination is enabled, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 192 bool isChargingTerminationEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 193
rob.meades@u-blox.com 1:ed57b6ca43ab 194 /// Set the pre-charging current limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 195 // \param currentMA the pre-charging current limit, in milliAmps.
rob.meades@u-blox.com 1:ed57b6ca43ab 196 // Range is 128 mA to 2048 mA, default is 256 mA.
rob.meades@u-blox.com 1:ed57b6ca43ab 197 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 198 bool setPrechargingCurrentLimit (int32_t currentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 199
rob.meades@u-blox.com 1:ed57b6ca43ab 200 /// Get the pre-charging current limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 201 // \param pCurrentMA a place to put the pre-charging current limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 202 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 203 bool getPrechargingCurrentLimit (int32_t *pCurrentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 204
rob.meades@u-blox.com 1:ed57b6ca43ab 205 /// Set the charging voltage limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 206 // \param voltageMV the charging voltage limit, in milliVolts.
rob.meades@u-blox.com 1:ed57b6ca43ab 207 // Range is 3504 mV to 4400 mV, default is 4208 mV.
rob.meades@u-blox.com 1:ed57b6ca43ab 208 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 209 bool setChargingVoltageLimit (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 210
rob.meades@u-blox.com 1:ed57b6ca43ab 211 /// Get the charging voltage limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 212 // \param pVoltageMV a place to put the charging voltage limit,
rob.meades@u-blox.com 1:ed57b6ca43ab 213 // in milliVolts.
rob.meades@u-blox.com 1:ed57b6ca43ab 214 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 215 bool getChargingVoltageLimit (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 216
rob.meades@u-blox.com 1:ed57b6ca43ab 217 /// Set the pre-charge to fast-charge voltage threshold.
rob.meades@u-blox.com 1:ed57b6ca43ab 218 // \param voltageMV the threshold, in milliVolts.
rob.meades@u-blox.com 1:ed57b6ca43ab 219 // Values will be translated to the nearest (highest)
rob.meades@u-blox.com 1:ed57b6ca43ab 220 // voltage out of 2800 mV and 3000 mV, default is 3000 mV.
rob.meades@u-blox.com 1:ed57b6ca43ab 221 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 222 bool setFastChargingVoltageThreshold (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 223
rob.meades@u-blox.com 1:ed57b6ca43ab 224 /// Get the pre-charge to fast-charge voltage threshold.
rob.meades@u-blox.com 1:ed57b6ca43ab 225 // \param pVoltageMV a place to put the threshold, in milliVolts.
rob.meades@u-blox.com 1:ed57b6ca43ab 226 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 227 bool getFastChargingVoltageThreshold (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 228
rob.meades@u-blox.com 1:ed57b6ca43ab 229 /// Set the recharging voltage threshold.
rob.meades@u-blox.com 1:ed57b6ca43ab 230 // \param voltageMV the recharging voltage threshold, in milliVolts.
rob.meades@u-blox.com 1:ed57b6ca43ab 231 // Values will be translated to the nearest (highest)
rob.meades@u-blox.com 1:ed57b6ca43ab 232 // voltage out of 100 mV and 300 mV, default is 100 mV.
rob.meades@u-blox.com 1:ed57b6ca43ab 233 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 234 bool setRechargingVoltageThreshold (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 235
rob.meades@u-blox.com 1:ed57b6ca43ab 236 /// Get the recharging voltage threshold.
rob.meades@u-blox.com 1:ed57b6ca43ab 237 // \param pVoltageMV a place to put the charging voltage threshold, in milliVolts.
rob.meades@u-blox.com 1:ed57b6ca43ab 238 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 239 bool getRechargingVoltageThreshold (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 240
rob.meades@u-blox.com 1:ed57b6ca43ab 241 /// Set the boost voltage.
rob.meades@u-blox.com 1:ed57b6ca43ab 242 // \param voltageMV the boost voltage, in milliVolts.
rob.meades@u-blox.com 1:ed57b6ca43ab 243 // Range is 4550 mV to 5510 mV, default is 5126 mV.
rob.meades@u-blox.com 1:ed57b6ca43ab 244 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 245 bool setBoostVoltage (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 246
rob.meades@u-blox.com 1:ed57b6ca43ab 247 /// Get the boost voltage.
rob.meades@u-blox.com 1:ed57b6ca43ab 248 // \param pVoltageMV a place to put the boost voltage, in milliVolts.
rob.meades@u-blox.com 1:ed57b6ca43ab 249 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 250 bool getBoostVoltage (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 251
rob.meades@u-blox.com 1:ed57b6ca43ab 252 /// Set the boost mode upper temperature limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 253 // \param temperatureC the temperature in C.
rob.meades@u-blox.com 1:ed57b6ca43ab 254 // Values will be translated to the nearest (lower)
rob.meades@u-blox.com 1:ed57b6ca43ab 255 // of 55 C, 60 C and 65 C (disabled by default).
rob.meades@u-blox.com 1:ed57b6ca43ab 256 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 257 bool setBoostUpperTemperatureLimit (int32_t temperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 258
rob.meades@u-blox.com 1:ed57b6ca43ab 259 /// Get the boost mode upper temperature limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 260 // If the boost mode upper temperature limit is not
rob.meades@u-blox.com 1:ed57b6ca43ab 261 // enabled then pTemperatureC will remain untouched and false
rob.meades@u-blox.com 1:ed57b6ca43ab 262 // will be returned.
rob.meades@u-blox.com 1:ed57b6ca43ab 263 // \param pTemperatureC a place to put the temperature.
rob.meades@u-blox.com 1:ed57b6ca43ab 264 // \return true if successful and a limit was set, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 265 bool getBoostUpperTemperatureLimit (int32_t *pTemperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 266
rob.meades@u-blox.com 1:ed57b6ca43ab 267 /// Check whether the boost mode upper temperature limit is enabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 268 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 269 bool isBoostUpperTemperatureLimitEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 270
rob.meades@u-blox.com 1:ed57b6ca43ab 271 /// Disable the boost mode upper temperature limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 272 // Default is disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 273 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 274 bool disableBoostUpperTemperatureLimit (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 275
rob.meades@u-blox.com 1:ed57b6ca43ab 276 /// Set the boost mode low temperature limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 277 // \param temperatureC the temperature in C.
rob.meades@u-blox.com 1:ed57b6ca43ab 278 // Values will be translated to the nearest (higher)
rob.meades@u-blox.com 1:ed57b6ca43ab 279 // of -10 C and -20 C, default is -10 C.
rob.meades@u-blox.com 1:ed57b6ca43ab 280 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 281 bool setBoostLowerTemperatureLimit (int32_t temperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 282
rob.meades@u-blox.com 1:ed57b6ca43ab 283 /// Get the boost mode low temperature limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 284 // \param pTemperatureC a place to put the temperature.
rob.meades@u-blox.com 1:ed57b6ca43ab 285 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 286 bool getBoostLowerTemperatureLimit (int32_t *pTemperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 287
rob.meades@u-blox.com 1:ed57b6ca43ab 288 /// Set the input voltage limit. If the input falls below
rob.meades@u-blox.com 1:ed57b6ca43ab 289 // this level then charging will be ramped down. The limit
rob.meades@u-blox.com 1:ed57b6ca43ab 290 // does not take effect until enableInputLimits() is called
rob.meades@u-blox.com 1:ed57b6ca43ab 291 // (default setting is disabled).
rob.meades@u-blox.com 1:ed57b6ca43ab 292 // \param voltageMV the input voltage limit, in milliVolts.
rob.meades@u-blox.com 1:ed57b6ca43ab 293 // Range is 3880 mV to 5080 mV, default is 4760 mV.
rob.meades@u-blox.com 1:ed57b6ca43ab 294 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 295 bool setInputVoltageLimit (int32_t voltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 296
rob.meades@u-blox.com 1:ed57b6ca43ab 297 /// Get the input voltage limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 298 // \param pVoltageMV a place to put the input voltage limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 299 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 300 bool getInputVoltageLimit (int32_t *pVoltageMV);
rob.meades@u-blox.com 1:ed57b6ca43ab 301
rob.meades@u-blox.com 1:ed57b6ca43ab 302 /// Set the input current limit. If the current drawn
rob.meades@u-blox.com 1:ed57b6ca43ab 303 // goes above this limit then charging will be ramped down.
rob.meades@u-blox.com 1:ed57b6ca43ab 304 // The limit does not take effect until enableInputLimits()
rob.meades@u-blox.com 1:ed57b6ca43ab 305 // is called (default setting is disabled).
rob.meades@u-blox.com 1:ed57b6ca43ab 306 // \param currentMA the input current limit, in milliAmps.
rob.meades@u-blox.com 1:ed57b6ca43ab 307 // Range is 100 mA to 3000 mA, default depends upon
rob.meades@u-blox.com 1:ed57b6ca43ab 308 // hardware configuration, see section 8.3.1.4.3 of
rob.meades@u-blox.com 1:ed57b6ca43ab 309 // the data sheet.
rob.meades@u-blox.com 1:ed57b6ca43ab 310 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 311 bool setInputCurrentLimit (int32_t currentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 312
rob.meades@u-blox.com 1:ed57b6ca43ab 313 /// Get the input current limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 314 // \param pCurrentMA a place to put the input current limit.
rob.meades@u-blox.com 1:ed57b6ca43ab 315 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 316 bool getInputCurrentLimit (int32_t *pCurrentMA);
rob.meades@u-blox.com 1:ed57b6ca43ab 317
rob.meades@u-blox.com 1:ed57b6ca43ab 318 /// Enable input voltage and current limits.
rob.meades@u-blox.com 1:ed57b6ca43ab 319 // Default is disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 320 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 321 bool enableInputLimits (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 322
rob.meades@u-blox.com 1:ed57b6ca43ab 323 /// Remove any input voltage or current limits.
rob.meades@u-blox.com 1:ed57b6ca43ab 324 // Default is disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 325 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 326 bool disableInputLimits (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 327
rob.meades@u-blox.com 1:ed57b6ca43ab 328 /// Check whether input limits are enabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 329 // \return true if input limits are enabled, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 330 bool areInputLimitsEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 331
rob.meades@u-blox.com 1:ed57b6ca43ab 332 /// Set the thermal regulation threshold for the chip.
rob.meades@u-blox.com 1:ed57b6ca43ab 333 // \param temperatureC the temperature in C.
rob.meades@u-blox.com 1:ed57b6ca43ab 334 // Values will be translated to the nearest (lower)
rob.meades@u-blox.com 1:ed57b6ca43ab 335 // of 60 C, 80 C, 100 C and 120 C, default 120 C.
rob.meades@u-blox.com 1:ed57b6ca43ab 336 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 337 bool setChipThermalRegulationThreshold (int32_t temperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 338
rob.meades@u-blox.com 1:ed57b6ca43ab 339 /// Get the thermal regulation threshold for the chip.
rob.meades@u-blox.com 1:ed57b6ca43ab 340 // \param pTemperatureC a place to put the temperature.
rob.meades@u-blox.com 1:ed57b6ca43ab 341 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 342 bool getChipThermalRegulationThreshold (int32_t *pTemperatureC);
rob.meades@u-blox.com 1:ed57b6ca43ab 343
rob.meades@u-blox.com 1:ed57b6ca43ab 344 /// Get the charger faults.
rob.meades@u-blox.com 1:ed57b6ca43ab 345 // Note: as with all the other API functions here, this should
rob.meades@u-blox.com 1:ed57b6ca43ab 346 // not be called from an interrupt function as the comms with the
rob.meades@u-blox.com 1:ed57b6ca43ab 347 // chip over I2C will take too long.
rob.meades@u-blox.com 1:ed57b6ca43ab 348 // \return a bit-map of that can be tested against ChargerFault.
rob.meades@u-blox.com 1:ed57b6ca43ab 349 char getChargerFaults(void);
rob.meades@u-blox.com 1:ed57b6ca43ab 350
rob.meades@u-blox.com 1:ed57b6ca43ab 351 /// Enable shipping mode.
rob.meades@u-blox.com 1:ed57b6ca43ab 352 // In shipping mode the battery is disconnected from the system
rob.meades@u-blox.com 1:ed57b6ca43ab 353 // to avoid leakage. Default is disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 354 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 355 bool enableShippingMode (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 356
rob.meades@u-blox.com 1:ed57b6ca43ab 357 /// Disable shipping mode.
rob.meades@u-blox.com 1:ed57b6ca43ab 358 // In shipping mode the battery is disconnected from the system
rob.meades@u-blox.com 1:ed57b6ca43ab 359 // to avoid leakage. Default is disabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 360 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 361 bool disableShippingMode (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 362
rob.meades@u-blox.com 1:ed57b6ca43ab 363 /// Check whether shipping mode is enabled.
rob.meades@u-blox.com 1:ed57b6ca43ab 364 // \return true if input limits are enabled, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 365 bool isShippingModeEnabled (void);
rob.meades@u-blox.com 1:ed57b6ca43ab 366
rob.meades@u-blox.com 1:ed57b6ca43ab 367 /// Advanced function to read a register on the chip.
rob.meades@u-blox.com 1:ed57b6ca43ab 368 // \param address the address to read from.
rob.meades@u-blox.com 1:ed57b6ca43ab 369 // \param pValue a place to put the returned value.
rob.meades@u-blox.com 1:ed57b6ca43ab 370 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 371 bool advancedGet(char address, char *pValue);
rob.meades@u-blox.com 1:ed57b6ca43ab 372
rob.meades@u-blox.com 1:ed57b6ca43ab 373 /// Advanced function to set a register on the chip.
rob.meades@u-blox.com 1:ed57b6ca43ab 374 // \param address the address to write to.
rob.meades@u-blox.com 1:ed57b6ca43ab 375 // \param value the value to write.
rob.meades@u-blox.com 1:ed57b6ca43ab 376 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 377 bool advancedSet(char address, char value);
rob.meades@u-blox.com 1:ed57b6ca43ab 378
rob.meades@u-blox.com 1:ed57b6ca43ab 379 protected:
rob.meades@u-blox.com 1:ed57b6ca43ab 380 /// Pointer to the I2C interface.
rob.meades@u-blox.com 1:ed57b6ca43ab 381 I2C * gpI2c;
rob.meades@u-blox.com 1:ed57b6ca43ab 382 /// The address of the device.
rob.meades@u-blox.com 1:ed57b6ca43ab 383 uint8_t gAddress;
rob.meades@u-blox.com 1:ed57b6ca43ab 384 /// Flag to indicate device is ready
rob.meades@u-blox.com 1:ed57b6ca43ab 385 bool gReady;
rob.meades@u-blox.com 1:ed57b6ca43ab 386
rob.meades@u-blox.com 1:ed57b6ca43ab 387 /// Read a register.
rob.meades@u-blox.com 1:ed57b6ca43ab 388 // Note: gpI2c should be locked before this is called.
rob.meades@u-blox.com 1:ed57b6ca43ab 389 // \param address the address to read from.
rob.meades@u-blox.com 1:ed57b6ca43ab 390 // \param pValue a place to put the returned value.
rob.meades@u-blox.com 1:ed57b6ca43ab 391 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 392 bool getRegister(char address, char *pValue);
rob.meades@u-blox.com 1:ed57b6ca43ab 393
rob.meades@u-blox.com 1:ed57b6ca43ab 394 /// Set a register.
rob.meades@u-blox.com 1:ed57b6ca43ab 395 // Note: gpI2c should be locked before this is called.
rob.meades@u-blox.com 1:ed57b6ca43ab 396 // \param address the address to write to.
rob.meades@u-blox.com 1:ed57b6ca43ab 397 // \param value the value to write.
rob.meades@u-blox.com 1:ed57b6ca43ab 398 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 399 bool setRegister(char address, char value);
rob.meades@u-blox.com 1:ed57b6ca43ab 400
rob.meades@u-blox.com 1:ed57b6ca43ab 401 /// Set a mask of bits in a register.
rob.meades@u-blox.com 1:ed57b6ca43ab 402 // Note: gpI2c should be locked before this is called.
rob.meades@u-blox.com 1:ed57b6ca43ab 403 // \param address the address to write to.
rob.meades@u-blox.com 1:ed57b6ca43ab 404 // \param mask the mask of bits to set.
rob.meades@u-blox.com 1:ed57b6ca43ab 405 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 406 bool setRegisterBits(char address, char mask);
rob.meades@u-blox.com 1:ed57b6ca43ab 407
rob.meades@u-blox.com 1:ed57b6ca43ab 408 /// Clear a mask of bits in a register.
rob.meades@u-blox.com 1:ed57b6ca43ab 409 // Note: gpI2c should be locked before this is called.
rob.meades@u-blox.com 1:ed57b6ca43ab 410 // \param address the address to write to.
rob.meades@u-blox.com 1:ed57b6ca43ab 411 // \param mask the mask of bits to clear.
rob.meades@u-blox.com 1:ed57b6ca43ab 412 // \return true if successful, otherwise false.
rob.meades@u-blox.com 1:ed57b6ca43ab 413 bool clearRegisterBits(char address, char mask);
rob.meades@u-blox.com 1:ed57b6ca43ab 414 };
rob.meades@u-blox.com 1:ed57b6ca43ab 415
rob.meades@u-blox.com 1:ed57b6ca43ab 416 #endif
rob.meades@u-blox.com 1:ed57b6ca43ab 417
rob.meades@u-blox.com 1:ed57b6ca43ab 418 // End Of File