MAX14690 Library
Dependents: MAX32630HSP3_IMU_HelloWorld MAX32630HSP3_IMU_HelloWorld max32630fthr max4146x_comp ... more
Fork of MAX14690 by
MAX14720.h@1:f8919b0c2052, 2016-09-28 (annotated)
- Committer:
- jbradshaw
- Date:
- Wed Sep 28 17:38:41 2016 +0000
- Revision:
- 1:f8919b0c2052
- Parent:
- 0:0e40db4a2b3e
- Child:
- 2:5bcfe7e294b6
Added example code in the header file
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jbradshaw | 0:0e40db4a2b3e | 1 | /******************************************************************************* |
jbradshaw | 0:0e40db4a2b3e | 2 | * Copyright (C) 2015 Maxim Integrated Products, Inc., All Rights Reserved. |
jbradshaw | 0:0e40db4a2b3e | 3 | * |
jbradshaw | 0:0e40db4a2b3e | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
jbradshaw | 0:0e40db4a2b3e | 5 | * copy of this software and associated documentation files (the "Software"), |
jbradshaw | 0:0e40db4a2b3e | 6 | * to deal in the Software without restriction, including without limitation |
jbradshaw | 0:0e40db4a2b3e | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
jbradshaw | 0:0e40db4a2b3e | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
jbradshaw | 0:0e40db4a2b3e | 9 | * Software is furnished to do so, subject to the following conditions: |
jbradshaw | 0:0e40db4a2b3e | 10 | * |
jbradshaw | 0:0e40db4a2b3e | 11 | * The above copyright notice and this permission notice shall be included |
jbradshaw | 0:0e40db4a2b3e | 12 | * in all copies or substantial portions of the Software. |
jbradshaw | 0:0e40db4a2b3e | 13 | * |
jbradshaw | 0:0e40db4a2b3e | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
jbradshaw | 0:0e40db4a2b3e | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
jbradshaw | 0:0e40db4a2b3e | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
jbradshaw | 0:0e40db4a2b3e | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
jbradshaw | 0:0e40db4a2b3e | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
jbradshaw | 0:0e40db4a2b3e | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
jbradshaw | 0:0e40db4a2b3e | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
jbradshaw | 0:0e40db4a2b3e | 21 | * |
jbradshaw | 0:0e40db4a2b3e | 22 | * Except as contained in this notice, the name of Maxim Integrated |
jbradshaw | 0:0e40db4a2b3e | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
jbradshaw | 0:0e40db4a2b3e | 24 | * Products, Inc. Branding Policy. |
jbradshaw | 0:0e40db4a2b3e | 25 | * |
jbradshaw | 0:0e40db4a2b3e | 26 | * The mere transfer of this software does not imply any licenses |
jbradshaw | 0:0e40db4a2b3e | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
jbradshaw | 0:0e40db4a2b3e | 28 | * trademarks, maskwork rights, or any other form of intellectual |
jbradshaw | 0:0e40db4a2b3e | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
jbradshaw | 0:0e40db4a2b3e | 30 | * ownership rights. |
jbradshaw | 0:0e40db4a2b3e | 31 | ******************************************************************************* |
jbradshaw | 0:0e40db4a2b3e | 32 | */ |
jbradshaw | 0:0e40db4a2b3e | 33 | |
jbradshaw | 0:0e40db4a2b3e | 34 | #ifndef PMIC_H_ |
jbradshaw | 0:0e40db4a2b3e | 35 | #define PMIC_H_ |
jbradshaw | 0:0e40db4a2b3e | 36 | |
jbradshaw | 0:0e40db4a2b3e | 37 | #include "mbed.h" |
jbradshaw | 0:0e40db4a2b3e | 38 | |
jbradshaw | 1:f8919b0c2052 | 39 | /** |
jbradshaw | 1:f8919b0c2052 | 40 | * Example for the MAX14720 PMIC Driver |
jbradshaw | 1:f8919b0c2052 | 41 | * |
jbradshaw | 1:f8919b0c2052 | 42 | * @code |
jbradshaw | 1:f8919b0c2052 | 43 | * #include <stdio.h> |
jbradshaw | 1:f8919b0c2052 | 44 | * #include "mbed.h" |
jbradshaw | 1:f8919b0c2052 | 45 | * #include "MAX14720.h" |
jbradshaw | 1:f8919b0c2052 | 46 | * |
jbradshaw | 1:f8919b0c2052 | 47 | * // I2C Master 2 |
jbradshaw | 1:f8919b0c2052 | 48 | * I2C i2c2(I2C2_SDA, I2C2_SCL); |
jbradshaw | 1:f8919b0c2052 | 49 | * MAX14720 max14720(&i2c2); |
jbradshaw | 1:f8919b0c2052 | 50 | * |
jbradshaw | 1:f8919b0c2052 | 51 | * int main(void) { |
jbradshaw | 1:f8919b0c2052 | 52 | * int result; |
jbradshaw | 1:f8919b0c2052 | 53 | * |
jbradshaw | 1:f8919b0c2052 | 54 | * // initialize BoostVSet on the MAX14720 PMIC to 4.5 Volts |
jbradshaw | 1:f8919b0c2052 | 55 | * printf("Init MAX14720\n"); |
jbradshaw | 1:f8919b0c2052 | 56 | * result = max14720.boostEn(MAX14720::BoostEn_Disable); |
jbradshaw | 1:f8919b0c2052 | 57 | * if (result == MAX14720_ERROR) printf("Error communicating with MAX14720"); |
jbradshaw | 1:f8919b0c2052 | 58 | * result = max14720.boostVSet(MAX14720::BoostVSet_45); |
jbradshaw | 1:f8919b0c2052 | 59 | * if (result == MAX14720_ERROR) printf("Error communicating with MAX14720"); |
jbradshaw | 1:f8919b0c2052 | 60 | * result = max14720.boostEn(MAX14720::BoostEn_Enable); |
jbradshaw | 1:f8919b0c2052 | 61 | * if (result == MAX14720_ERROR) printf("Error communicating with MAX14720"); |
jbradshaw | 1:f8919b0c2052 | 62 | * |
jbradshaw | 1:f8919b0c2052 | 63 | * while (1) { |
jbradshaw | 1:f8919b0c2052 | 64 | * } |
jbradshaw | 1:f8919b0c2052 | 65 | * } |
jbradshaw | 1:f8919b0c2052 | 66 | * @endcode |
jbradshaw | 1:f8919b0c2052 | 67 | */ |
jbradshaw | 1:f8919b0c2052 | 68 | |
jbradshaw | 0:0e40db4a2b3e | 69 | #define MAX14720_NO_ERROR 0 |
jbradshaw | 0:0e40db4a2b3e | 70 | #define MAX14720_ERROR -1 |
jbradshaw | 0:0e40db4a2b3e | 71 | |
jbradshaw | 0:0e40db4a2b3e | 72 | class MAX14720 |
jbradshaw | 0:0e40db4a2b3e | 73 | { |
jbradshaw | 0:0e40db4a2b3e | 74 | public: |
jbradshaw | 0:0e40db4a2b3e | 75 | typedef enum { // I2C Register Addresses |
jbradshaw | 0:0e40db4a2b3e | 76 | CHIP_ID = 0x00, |
jbradshaw | 0:0e40db4a2b3e | 77 | CHIP_REV = 0x01, |
jbradshaw | 0:0e40db4a2b3e | 78 | BOOST_C_DIV = 0x03, |
jbradshaw | 0:0e40db4a2b3e | 79 | BOOST_I_SET = 0x04, |
jbradshaw | 0:0e40db4a2b3e | 80 | BOOST_V_SET = 0x05, |
jbradshaw | 0:0e40db4a2b3e | 81 | BOOST_CFG = 0x06, |
jbradshaw | 0:0e40db4a2b3e | 82 | BUCK_V_SET = 0x07, |
jbradshaw | 0:0e40db4a2b3e | 83 | BUCK_CFG = 0x08, |
jbradshaw | 0:0e40db4a2b3e | 84 | BUCK_I_SET = 0x09, |
jbradshaw | 0:0e40db4a2b3e | 85 | LDOV_SET = 0x0A, |
jbradshaw | 0:0e40db4a2b3e | 86 | LDO_CFG = 0x0B, |
jbradshaw | 0:0e40db4a2b3e | 87 | SWITCH_CFG = 0x0C, |
jbradshaw | 0:0e40db4a2b3e | 88 | BAT_TIME = 0x0D, |
jbradshaw | 0:0e40db4a2b3e | 89 | BAT_CFG = 0x0E, |
jbradshaw | 0:0e40db4a2b3e | 90 | BAT_BCV = 0x0F, |
jbradshaw | 0:0e40db4a2b3e | 91 | BAT_OCV = 0x10, |
jbradshaw | 0:0e40db4a2b3e | 92 | BAT_LCV = 0x11, |
jbradshaw | 0:0e40db4a2b3e | 93 | MON_CFG = 0X19, |
jbradshaw | 0:0e40db4a2b3e | 94 | BOOT_CFG = 0x1A, |
jbradshaw | 0:0e40db4a2b3e | 95 | PIN_STAT = 0x1B, |
jbradshaw | 0:0e40db4a2b3e | 96 | BBB_EXTRA = 0x1C, |
jbradshaw | 0:0e40db4a2b3e | 97 | HAND_SHK = 0x1D, |
jbradshaw | 0:0e40db4a2b3e | 98 | UVLO_CFG = 0x1E, |
jbradshaw | 0:0e40db4a2b3e | 99 | PWR_OFF = 0x1F, |
jbradshaw | 0:0e40db4a2b3e | 100 | OTP_MAP_0 = 0x20, |
jbradshaw | 0:0e40db4a2b3e | 101 | OTP_MAP_1 = 0x21, |
jbradshaw | 0:0e40db4a2b3e | 102 | OTP_MAP_2 = 0x22, |
jbradshaw | 0:0e40db4a2b3e | 103 | OTP_MAP_3 = 0x23, |
jbradshaw | 0:0e40db4a2b3e | 104 | OTP_MAP_4 = 0x24, |
jbradshaw | 0:0e40db4a2b3e | 105 | OTP_MAP_5 = 0x25, |
jbradshaw | 0:0e40db4a2b3e | 106 | OTP_MAP_6 = 0x26, |
jbradshaw | 0:0e40db4a2b3e | 107 | OTP_MAP_7 = 0x27, |
jbradshaw | 0:0e40db4a2b3e | 108 | OTP_MAP_8 = 0x28, |
jbradshaw | 0:0e40db4a2b3e | 109 | OTP_MAP_9 = 0x29, |
jbradshaw | 0:0e40db4a2b3e | 110 | OTP_MAP_A = 0x2A, |
jbradshaw | 0:0e40db4a2b3e | 111 | OTP_MAP_b = 0x2B, |
jbradshaw | 0:0e40db4a2b3e | 112 | } MAX14720_REG_map_t; |
jbradshaw | 0:0e40db4a2b3e | 113 | |
jbradshaw | 0:0e40db4a2b3e | 114 | /// @brief ChipId Register (0x00) |
jbradshaw | 0:0e40db4a2b3e | 115 | typedef union ChipId_ { |
jbradshaw | 0:0e40db4a2b3e | 116 | char all; |
jbradshaw | 0:0e40db4a2b3e | 117 | } max14720_ChipId; |
jbradshaw | 0:0e40db4a2b3e | 118 | |
jbradshaw | 0:0e40db4a2b3e | 119 | /// @brief ChipRev Register (0x01) |
jbradshaw | 0:0e40db4a2b3e | 120 | typedef union ChipRev_ { |
jbradshaw | 0:0e40db4a2b3e | 121 | char all; |
jbradshaw | 0:0e40db4a2b3e | 122 | } max14720_ChipRev; |
jbradshaw | 0:0e40db4a2b3e | 123 | |
jbradshaw | 0:0e40db4a2b3e | 124 | /// @brief BoostCDiv Register (0x03) |
jbradshaw | 0:0e40db4a2b3e | 125 | typedef union BoostCDiv_ { |
jbradshaw | 0:0e40db4a2b3e | 126 | char all; |
jbradshaw | 0:0e40db4a2b3e | 127 | struct { |
jbradshaw | 0:0e40db4a2b3e | 128 | char ClkDivSet : 7; |
jbradshaw | 0:0e40db4a2b3e | 129 | char ClkDivEn : 1; |
jbradshaw | 0:0e40db4a2b3e | 130 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 131 | } max14720_BoostCDiv; |
jbradshaw | 0:0e40db4a2b3e | 132 | |
jbradshaw | 0:0e40db4a2b3e | 133 | /// @brief BoostISet Register (0x04) |
jbradshaw | 0:0e40db4a2b3e | 134 | typedef union BoostISet_ { |
jbradshaw | 0:0e40db4a2b3e | 135 | char all; |
jbradshaw | 0:0e40db4a2b3e | 136 | struct { |
jbradshaw | 0:0e40db4a2b3e | 137 | char BoostISet : 3; |
jbradshaw | 0:0e40db4a2b3e | 138 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 139 | } max14720_BoostISet; |
jbradshaw | 0:0e40db4a2b3e | 140 | |
jbradshaw | 0:0e40db4a2b3e | 141 | /// @brief BoostVSet Register (0x05) |
jbradshaw | 0:0e40db4a2b3e | 142 | typedef union BoostVSet_ { |
jbradshaw | 0:0e40db4a2b3e | 143 | char all; |
jbradshaw | 0:0e40db4a2b3e | 144 | struct { |
jbradshaw | 0:0e40db4a2b3e | 145 | char BoostVSet : 5; |
jbradshaw | 0:0e40db4a2b3e | 146 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 147 | } max14720_BoostVSet; |
jbradshaw | 0:0e40db4a2b3e | 148 | |
jbradshaw | 0:0e40db4a2b3e | 149 | /// @brief BoostCfg Register (0x06) |
jbradshaw | 0:0e40db4a2b3e | 150 | typedef union BoostCfg_ { |
jbradshaw | 0:0e40db4a2b3e | 151 | char all; |
jbradshaw | 0:0e40db4a2b3e | 152 | struct { |
jbradshaw | 0:0e40db4a2b3e | 153 | char BoostInd : 1; |
jbradshaw | 0:0e40db4a2b3e | 154 | char BoostEMI : 1; |
jbradshaw | 0:0e40db4a2b3e | 155 | char reserved : 1; |
jbradshaw | 0:0e40db4a2b3e | 156 | char BoostEn : 2; |
jbradshaw | 0:0e40db4a2b3e | 157 | char BoostSeq : 3; |
jbradshaw | 0:0e40db4a2b3e | 158 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 159 | } max14720_BoostCfg; |
jbradshaw | 0:0e40db4a2b3e | 160 | |
jbradshaw | 0:0e40db4a2b3e | 161 | /// @brief BuckVSet Register (0x07) |
jbradshaw | 0:0e40db4a2b3e | 162 | typedef union BuckVSet_ { |
jbradshaw | 0:0e40db4a2b3e | 163 | char all; |
jbradshaw | 0:0e40db4a2b3e | 164 | struct { |
jbradshaw | 0:0e40db4a2b3e | 165 | char BuckVSet : 6; |
jbradshaw | 0:0e40db4a2b3e | 166 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 167 | } max14720_BuckVSet; |
jbradshaw | 0:0e40db4a2b3e | 168 | |
jbradshaw | 0:0e40db4a2b3e | 169 | /// @brief BuckCfg Register (0x08) |
jbradshaw | 0:0e40db4a2b3e | 170 | typedef union BuckCfg_ { |
jbradshaw | 0:0e40db4a2b3e | 171 | char all; |
jbradshaw | 0:0e40db4a2b3e | 172 | struct { |
jbradshaw | 0:0e40db4a2b3e | 173 | char BuckFst : 1; |
jbradshaw | 0:0e40db4a2b3e | 174 | char BuckMd : 2; |
jbradshaw | 0:0e40db4a2b3e | 175 | char BoostEn : 2; |
jbradshaw | 0:0e40db4a2b3e | 176 | char BuckSeq : 3; |
jbradshaw | 0:0e40db4a2b3e | 177 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 178 | } max14720_BuckCfg; |
jbradshaw | 0:0e40db4a2b3e | 179 | |
jbradshaw | 0:0e40db4a2b3e | 180 | /// @brief BuckISet Register (0x09) |
jbradshaw | 0:0e40db4a2b3e | 181 | typedef union BuckISet_ { |
jbradshaw | 0:0e40db4a2b3e | 182 | char all; |
jbradshaw | 0:0e40db4a2b3e | 183 | struct { |
jbradshaw | 0:0e40db4a2b3e | 184 | char BuckInteg : 1; |
jbradshaw | 0:0e40db4a2b3e | 185 | char BuckMinOT : 1; |
jbradshaw | 0:0e40db4a2b3e | 186 | char BuckHysOff : 1; |
jbradshaw | 0:0e40db4a2b3e | 187 | char BuckInd : 1; |
jbradshaw | 0:0e40db4a2b3e | 188 | char BuckCfg : 1; |
jbradshaw | 0:0e40db4a2b3e | 189 | char BuckISet : 3; |
jbradshaw | 0:0e40db4a2b3e | 190 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 191 | } max14720_BuckISet; |
jbradshaw | 0:0e40db4a2b3e | 192 | |
jbradshaw | 0:0e40db4a2b3e | 193 | /// @brief LDOVSet Register (0x0A) |
jbradshaw | 0:0e40db4a2b3e | 194 | typedef union LDOVSet_ { |
jbradshaw | 0:0e40db4a2b3e | 195 | char all; |
jbradshaw | 0:0e40db4a2b3e | 196 | struct { |
jbradshaw | 0:0e40db4a2b3e | 197 | char LDOVSet : 5; |
jbradshaw | 0:0e40db4a2b3e | 198 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 199 | } max14720_LDOVSet; |
jbradshaw | 0:0e40db4a2b3e | 200 | |
jbradshaw | 0:0e40db4a2b3e | 201 | /// @brief LDOCfg Register (0x0B) |
jbradshaw | 0:0e40db4a2b3e | 202 | typedef union LDOCfg_ { |
jbradshaw | 0:0e40db4a2b3e | 203 | char all; |
jbradshaw | 0:0e40db4a2b3e | 204 | struct { |
jbradshaw | 0:0e40db4a2b3e | 205 | char LDOMode : 1; |
jbradshaw | 0:0e40db4a2b3e | 206 | char LDOEn : 2; |
jbradshaw | 0:0e40db4a2b3e | 207 | char LDO_ActDSC : 1; |
jbradshaw | 0:0e40db4a2b3e | 208 | char LDO_PasDSC : 1; |
jbradshaw | 0:0e40db4a2b3e | 209 | char LDOSeq : 3; |
jbradshaw | 0:0e40db4a2b3e | 210 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 211 | } max14720_LDOCfg; |
jbradshaw | 0:0e40db4a2b3e | 212 | |
jbradshaw | 0:0e40db4a2b3e | 213 | /// @brief SwitchCfg Register (0x0C) |
jbradshaw | 0:0e40db4a2b3e | 214 | typedef union SwitchCfg_ { |
jbradshaw | 0:0e40db4a2b3e | 215 | char all; |
jbradshaw | 0:0e40db4a2b3e | 216 | struct { |
jbradshaw | 0:0e40db4a2b3e | 217 | char SWSoftStart : 1; |
jbradshaw | 0:0e40db4a2b3e | 218 | char SWEn : 2; |
jbradshaw | 0:0e40db4a2b3e | 219 | char reserved : 2; |
jbradshaw | 0:0e40db4a2b3e | 220 | char SWSeq : 3; |
jbradshaw | 0:0e40db4a2b3e | 221 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 222 | } max14720_SwitchCfg; |
jbradshaw | 0:0e40db4a2b3e | 223 | |
jbradshaw | 0:0e40db4a2b3e | 224 | /// @brief BatTime Register (0x0D) |
jbradshaw | 0:0e40db4a2b3e | 225 | typedef union BatTime_ { |
jbradshaw | 0:0e40db4a2b3e | 226 | char all; |
jbradshaw | 0:0e40db4a2b3e | 227 | struct { |
jbradshaw | 0:0e40db4a2b3e | 228 | char LCVTm : 2; |
jbradshaw | 0:0e40db4a2b3e | 229 | char OCVTm : 2; |
jbradshaw | 0:0e40db4a2b3e | 230 | char BCVTm : 2; |
jbradshaw | 0:0e40db4a2b3e | 231 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 232 | } max14720_BatTime; |
jbradshaw | 0:0e40db4a2b3e | 233 | |
jbradshaw | 0:0e40db4a2b3e | 234 | /// @brief BatCfg Register (0x0E) |
jbradshaw | 0:0e40db4a2b3e | 235 | typedef union BatCfg_ { |
jbradshaw | 0:0e40db4a2b3e | 236 | char all; |
jbradshaw | 0:0e40db4a2b3e | 237 | struct { |
jbradshaw | 0:0e40db4a2b3e | 238 | char BatImpCur : 3; |
jbradshaw | 0:0e40db4a2b3e | 239 | char LcvDly2Skip : 1; |
jbradshaw | 0:0e40db4a2b3e | 240 | char reserved : 2; |
jbradshaw | 0:0e40db4a2b3e | 241 | char BIMAbort : 1; |
jbradshaw | 0:0e40db4a2b3e | 242 | char BIA : 1; |
jbradshaw | 0:0e40db4a2b3e | 243 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 244 | } max14720_BatCfg; |
jbradshaw | 0:0e40db4a2b3e | 245 | |
jbradshaw | 0:0e40db4a2b3e | 246 | /// @brief BatV Register (0x0F) |
jbradshaw | 0:0e40db4a2b3e | 247 | typedef union BatBCV_ { |
jbradshaw | 0:0e40db4a2b3e | 248 | char all; |
jbradshaw | 0:0e40db4a2b3e | 249 | } max14720_BatBCV; |
jbradshaw | 0:0e40db4a2b3e | 250 | |
jbradshaw | 0:0e40db4a2b3e | 251 | /// @brief BatOCV Register (0x10) |
jbradshaw | 0:0e40db4a2b3e | 252 | typedef union BatOCV_ { |
jbradshaw | 0:0e40db4a2b3e | 253 | char all; |
jbradshaw | 0:0e40db4a2b3e | 254 | } max14720_BatOCV; |
jbradshaw | 0:0e40db4a2b3e | 255 | |
jbradshaw | 0:0e40db4a2b3e | 256 | /// @brief BatLCV Register (0x11) |
jbradshaw | 0:0e40db4a2b3e | 257 | typedef union BatLCV_ { |
jbradshaw | 0:0e40db4a2b3e | 258 | char all; |
jbradshaw | 0:0e40db4a2b3e | 259 | } max14720_BatLCV; |
jbradshaw | 0:0e40db4a2b3e | 260 | |
jbradshaw | 0:0e40db4a2b3e | 261 | /// @brief MONCfg Register (0x19) |
jbradshaw | 0:0e40db4a2b3e | 262 | typedef union MONCfg_ { |
jbradshaw | 0:0e40db4a2b3e | 263 | char all; |
jbradshaw | 0:0e40db4a2b3e | 264 | struct { |
jbradshaw | 0:0e40db4a2b3e | 265 | char MONCtr : 3; |
jbradshaw | 0:0e40db4a2b3e | 266 | char MONHiZ : 1; |
jbradshaw | 0:0e40db4a2b3e | 267 | char reserved : 3; |
jbradshaw | 0:0e40db4a2b3e | 268 | char MONEn : 1; |
jbradshaw | 0:0e40db4a2b3e | 269 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 270 | } max14720_MONCfg; |
jbradshaw | 0:0e40db4a2b3e | 271 | |
jbradshaw | 0:0e40db4a2b3e | 272 | /// @brief BootCfg Register (0x1A) |
jbradshaw | 0:0e40db4a2b3e | 273 | typedef union BootCfg_ { |
jbradshaw | 0:0e40db4a2b3e | 274 | char all; |
jbradshaw | 0:0e40db4a2b3e | 275 | struct { |
jbradshaw | 0:0e40db4a2b3e | 276 | char BootDly : 2; |
jbradshaw | 0:0e40db4a2b3e | 277 | char PFNPUDCfg : 1; |
jbradshaw | 0:0e40db4a2b3e | 278 | char SftRstCfg : 1; |
jbradshaw | 0:0e40db4a2b3e | 279 | char PwrRstCfg : 4; |
jbradshaw | 0:0e40db4a2b3e | 280 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 281 | } max14720_BootCfg; |
jbradshaw | 0:0e40db4a2b3e | 282 | |
jbradshaw | 0:0e40db4a2b3e | 283 | /// @brief PinStat Register (0x1B) |
jbradshaw | 0:0e40db4a2b3e | 284 | typedef union PinStat_ { |
jbradshaw | 0:0e40db4a2b3e | 285 | char all; |
jbradshaw | 0:0e40db4a2b3e | 286 | struct { |
jbradshaw | 0:0e40db4a2b3e | 287 | char RST_LEN : 1; |
jbradshaw | 0:0e40db4a2b3e | 288 | char MPC_BEN : 1; |
jbradshaw | 0:0e40db4a2b3e | 289 | char KOUT_HVEN : 1; |
jbradshaw | 0:0e40db4a2b3e | 290 | char KIN_SWEN : 1; |
jbradshaw | 0:0e40db4a2b3e | 291 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 292 | } max14720_PinStat; |
jbradshaw | 0:0e40db4a2b3e | 293 | |
jbradshaw | 0:0e40db4a2b3e | 294 | /// @brief BBBExtra Register (0x1C) |
jbradshaw | 0:0e40db4a2b3e | 295 | typedef union BBBExtra_ { |
jbradshaw | 0:0e40db4a2b3e | 296 | char all; |
jbradshaw | 0:0e40db4a2b3e | 297 | struct { |
jbradshaw | 0:0e40db4a2b3e | 298 | char BuckFScl : 1; |
jbradshaw | 0:0e40db4a2b3e | 299 | char BuckActDsc : 1; |
jbradshaw | 0:0e40db4a2b3e | 300 | char BuckPasDsc : 1; |
jbradshaw | 0:0e40db4a2b3e | 301 | char reserved : 2; |
jbradshaw | 0:0e40db4a2b3e | 302 | char Boost_ActDsc : 1; |
jbradshaw | 0:0e40db4a2b3e | 303 | char BoostPasDsc : 1; |
jbradshaw | 0:0e40db4a2b3e | 304 | char Boost_HysOff : 1; |
jbradshaw | 0:0e40db4a2b3e | 305 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 306 | } max14720_BBBExtra; |
jbradshaw | 0:0e40db4a2b3e | 307 | |
jbradshaw | 0:0e40db4a2b3e | 308 | /// @brief HandShk Register (0x1D) |
jbradshaw | 0:0e40db4a2b3e | 309 | typedef union HandShk_ { |
jbradshaw | 0:0e40db4a2b3e | 310 | char all; |
jbradshaw | 0:0e40db4a2b3e | 311 | struct { |
jbradshaw | 0:0e40db4a2b3e | 312 | char StayOn : 1; |
jbradshaw | 0:0e40db4a2b3e | 313 | char reserved : 5; |
jbradshaw | 0:0e40db4a2b3e | 314 | char GlbPasDsc : 1; |
jbradshaw | 0:0e40db4a2b3e | 315 | char StartOff : 1; |
jbradshaw | 0:0e40db4a2b3e | 316 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 317 | } max14720_HandShk; |
jbradshaw | 0:0e40db4a2b3e | 318 | |
jbradshaw | 0:0e40db4a2b3e | 319 | /// @brief UVLOCfg Register (0x1E) |
jbradshaw | 0:0e40db4a2b3e | 320 | typedef union UVLOCfg_ { |
jbradshaw | 0:0e40db4a2b3e | 321 | char all; |
jbradshaw | 0:0e40db4a2b3e | 322 | struct { |
jbradshaw | 0:0e40db4a2b3e | 323 | char LDO_UVLOsel : 1; |
jbradshaw | 0:0e40db4a2b3e | 324 | char BBBUVLOsel : 1; |
jbradshaw | 0:0e40db4a2b3e | 325 | } bit; |
jbradshaw | 0:0e40db4a2b3e | 326 | } max14720_UVLOCfg; |
jbradshaw | 0:0e40db4a2b3e | 327 | |
jbradshaw | 0:0e40db4a2b3e | 328 | /// @brief PWRCFG Register (0x1F) |
jbradshaw | 0:0e40db4a2b3e | 329 | typedef union PWROFF_ { |
jbradshaw | 0:0e40db4a2b3e | 330 | char all; |
jbradshaw | 0:0e40db4a2b3e | 331 | } max14720_PWROFF; |
jbradshaw | 0:0e40db4a2b3e | 332 | |
jbradshaw | 0:0e40db4a2b3e | 333 | /// All of the possible BoostVSet values |
jbradshaw | 0:0e40db4a2b3e | 334 | typedef enum { |
jbradshaw | 0:0e40db4a2b3e | 335 | BoostVSet_25, |
jbradshaw | 0:0e40db4a2b3e | 336 | BoostVSet_26, |
jbradshaw | 0:0e40db4a2b3e | 337 | BoostVSet_27, |
jbradshaw | 0:0e40db4a2b3e | 338 | BoostVSet_28, |
jbradshaw | 0:0e40db4a2b3e | 339 | BoostVSet_29, |
jbradshaw | 0:0e40db4a2b3e | 340 | BoostVSet_30, |
jbradshaw | 0:0e40db4a2b3e | 341 | BoostVSet_31, |
jbradshaw | 0:0e40db4a2b3e | 342 | BoostVSet_32, |
jbradshaw | 0:0e40db4a2b3e | 343 | BoostVSet_33, |
jbradshaw | 0:0e40db4a2b3e | 344 | BoostVSet_34, |
jbradshaw | 0:0e40db4a2b3e | 345 | BoostVSet_35, |
jbradshaw | 0:0e40db4a2b3e | 346 | BoostVSet_36, |
jbradshaw | 0:0e40db4a2b3e | 347 | BoostVSet_37, |
jbradshaw | 0:0e40db4a2b3e | 348 | BoostVSet_38, |
jbradshaw | 0:0e40db4a2b3e | 349 | BoostVSet_39, |
jbradshaw | 0:0e40db4a2b3e | 350 | BoostVSet_40, |
jbradshaw | 0:0e40db4a2b3e | 351 | BoostVSet_41, |
jbradshaw | 0:0e40db4a2b3e | 352 | BoostVSet_42, |
jbradshaw | 0:0e40db4a2b3e | 353 | BoostVSet_43, |
jbradshaw | 0:0e40db4a2b3e | 354 | BoostVSet_44, |
jbradshaw | 0:0e40db4a2b3e | 355 | BoostVSet_45, |
jbradshaw | 0:0e40db4a2b3e | 356 | BoostVSet_46, |
jbradshaw | 0:0e40db4a2b3e | 357 | BoostVSet_47, |
jbradshaw | 0:0e40db4a2b3e | 358 | BoostVSet_48, |
jbradshaw | 0:0e40db4a2b3e | 359 | BoostVSet_49, |
jbradshaw | 0:0e40db4a2b3e | 360 | BoostVSet_50, |
jbradshaw | 0:0e40db4a2b3e | 361 | } BoostVSet_Values; |
jbradshaw | 0:0e40db4a2b3e | 362 | |
jbradshaw | 0:0e40db4a2b3e | 363 | typedef enum { |
jbradshaw | 0:0e40db4a2b3e | 364 | BoostEn_Disable, |
jbradshaw | 0:0e40db4a2b3e | 365 | BoostEn_Enable, |
jbradshaw | 0:0e40db4a2b3e | 366 | BoostEn_Enable_MPC_High, |
jbradshaw | 0:0e40db4a2b3e | 367 | } BoostEn_Values; |
jbradshaw | 0:0e40db4a2b3e | 368 | |
jbradshaw | 0:0e40db4a2b3e | 369 | typedef enum { |
jbradshaw | 0:0e40db4a2b3e | 370 | BoostISet_0, |
jbradshaw | 0:0e40db4a2b3e | 371 | BoostISet_50mA, |
jbradshaw | 0:0e40db4a2b3e | 372 | BoostISet_100mA, |
jbradshaw | 0:0e40db4a2b3e | 373 | BoostISet_150mA, |
jbradshaw | 0:0e40db4a2b3e | 374 | BoostISet_200mA, |
jbradshaw | 0:0e40db4a2b3e | 375 | BoostISet_250mA, |
jbradshaw | 0:0e40db4a2b3e | 376 | BoostISet_300mA, |
jbradshaw | 0:0e40db4a2b3e | 377 | BoostISet_350mA, |
jbradshaw | 0:0e40db4a2b3e | 378 | } BoostISet_Values; |
jbradshaw | 0:0e40db4a2b3e | 379 | |
jbradshaw | 0:0e40db4a2b3e | 380 | typedef enum { |
jbradshaw | 0:0e40db4a2b3e | 381 | BoostSeq_Disabled, |
jbradshaw | 0:0e40db4a2b3e | 382 | BoostSeq_Reserved, |
jbradshaw | 0:0e40db4a2b3e | 383 | BoostSeq_Enabled_0, |
jbradshaw | 0:0e40db4a2b3e | 384 | BoostSeq_Enabled_25, |
jbradshaw | 0:0e40db4a2b3e | 385 | BoostSeq_Enabled_50, |
jbradshaw | 0:0e40db4a2b3e | 386 | BoostSeq_Reserved2, |
jbradshaw | 0:0e40db4a2b3e | 387 | BoostSeq_Controlled_HVEN, |
jbradshaw | 0:0e40db4a2b3e | 388 | BoostSeq_Controlled_BoostEn, |
jbradshaw | 0:0e40db4a2b3e | 389 | } BoostSeq_Values; |
jbradshaw | 0:0e40db4a2b3e | 390 | |
jbradshaw | 0:0e40db4a2b3e | 391 | typedef enum { |
jbradshaw | 0:0e40db4a2b3e | 392 | BoostEMI_Active, |
jbradshaw | 0:0e40db4a2b3e | 393 | BoostEMI_Disabled, |
jbradshaw | 0:0e40db4a2b3e | 394 | } BoostEMI_Values; |
jbradshaw | 0:0e40db4a2b3e | 395 | |
jbradshaw | 0:0e40db4a2b3e | 396 | typedef enum { |
jbradshaw | 0:0e40db4a2b3e | 397 | BoostInd_3_3, |
jbradshaw | 0:0e40db4a2b3e | 398 | BoostInd_4_7, |
jbradshaw | 0:0e40db4a2b3e | 399 | } BoostInd_Values; |
jbradshaw | 0:0e40db4a2b3e | 400 | |
jbradshaw | 0:0e40db4a2b3e | 401 | /** |
jbradshaw | 0:0e40db4a2b3e | 402 | * MAX14720 constructor. |
jbradshaw | 0:0e40db4a2b3e | 403 | * |
jbradshaw | 0:0e40db4a2b3e | 404 | * @param sda mbed pin to use for SDA line of I2C interface. |
jbradshaw | 0:0e40db4a2b3e | 405 | * @param scl mbed pin to use for SCL line of I2C interface. |
jbradshaw | 0:0e40db4a2b3e | 406 | * @param slaveAddress Slave Address of the device. |
jbradshaw | 0:0e40db4a2b3e | 407 | */ |
jbradshaw | 0:0e40db4a2b3e | 408 | MAX14720(PinName sda, PinName scl, int slaveAddress); |
jbradshaw | 0:0e40db4a2b3e | 409 | |
jbradshaw | 0:0e40db4a2b3e | 410 | /** |
jbradshaw | 0:0e40db4a2b3e | 411 | * MAX14720 constructor. |
jbradshaw | 0:0e40db4a2b3e | 412 | * |
jbradshaw | 0:0e40db4a2b3e | 413 | * @param i2c I2C object to use. |
jbradshaw | 0:0e40db4a2b3e | 414 | * @param slaveAddress Slave Address of the device. |
jbradshaw | 0:0e40db4a2b3e | 415 | */ |
jbradshaw | 0:0e40db4a2b3e | 416 | MAX14720(I2C *i2c, int slaveAddress); |
jbradshaw | 0:0e40db4a2b3e | 417 | |
jbradshaw | 0:0e40db4a2b3e | 418 | /** |
jbradshaw | 0:0e40db4a2b3e | 419 | * MAX14720 destructor. |
jbradshaw | 0:0e40db4a2b3e | 420 | */ |
jbradshaw | 0:0e40db4a2b3e | 421 | ~MAX14720(); |
jbradshaw | 0:0e40db4a2b3e | 422 | |
jbradshaw | 0:0e40db4a2b3e | 423 | /** |
jbradshaw | 0:0e40db4a2b3e | 424 | * Enable or disable Boost |
jbradshaw | 0:0e40db4a2b3e | 425 | */ |
jbradshaw | 0:0e40db4a2b3e | 426 | int boostEn(BoostEn_Values value); |
jbradshaw | 0:0e40db4a2b3e | 427 | /** |
jbradshaw | 0:0e40db4a2b3e | 428 | * Set the Boost Output Voltage from 2.5V to 5V with 100mV increments |
jbradshaw | 0:0e40db4a2b3e | 429 | */ |
jbradshaw | 0:0e40db4a2b3e | 430 | int boostVSet(BoostVSet_Values value); |
jbradshaw | 0:0e40db4a2b3e | 431 | /** |
jbradshaw | 0:0e40db4a2b3e | 432 | * Read the Boost Output Voltage |
jbradshaw | 0:0e40db4a2b3e | 433 | */ |
jbradshaw | 0:0e40db4a2b3e | 434 | int readBoostVSet(BoostVSet_Values *value); |
jbradshaw | 0:0e40db4a2b3e | 435 | /** |
jbradshaw | 0:0e40db4a2b3e | 436 | * Set the Buck-Boost Peak Current-Limit |
jbradshaw | 0:0e40db4a2b3e | 437 | */ |
jbradshaw | 0:0e40db4a2b3e | 438 | int boostISet(BoostISet_Values value); |
jbradshaw | 0:0e40db4a2b3e | 439 | /** |
jbradshaw | 0:0e40db4a2b3e | 440 | * Read the Buck-Boost Peak Current-Limit |
jbradshaw | 0:0e40db4a2b3e | 441 | */ |
jbradshaw | 0:0e40db4a2b3e | 442 | int readBoostISet(BoostISet_Values *value); |
jbradshaw | 0:0e40db4a2b3e | 443 | |
jbradshaw | 0:0e40db4a2b3e | 444 | /** |
jbradshaw | 0:0e40db4a2b3e | 445 | * Write a device register |
jbradshaw | 0:0e40db4a2b3e | 446 | */ |
jbradshaw | 0:0e40db4a2b3e | 447 | int writeReg(MAX14720_REG_map_t reg, char value); |
jbradshaw | 0:0e40db4a2b3e | 448 | /** |
jbradshaw | 0:0e40db4a2b3e | 449 | * Read a device register |
jbradshaw | 0:0e40db4a2b3e | 450 | */ |
jbradshaw | 0:0e40db4a2b3e | 451 | int readReg(MAX14720_REG_map_t reg, char *value); |
jbradshaw | 0:0e40db4a2b3e | 452 | private: |
jbradshaw | 0:0e40db4a2b3e | 453 | /// I2C pointer |
jbradshaw | 0:0e40db4a2b3e | 454 | I2C *i2c; |
jbradshaw | 0:0e40db4a2b3e | 455 | /// Is this object the owner of the I2C object |
jbradshaw | 0:0e40db4a2b3e | 456 | bool isOwner; |
jbradshaw | 0:0e40db4a2b3e | 457 | /// Device slave address |
jbradshaw | 0:0e40db4a2b3e | 458 | int slaveAddress; |
jbradshaw | 0:0e40db4a2b3e | 459 | |
jbradshaw | 0:0e40db4a2b3e | 460 | }; |
jbradshaw | 0:0e40db4a2b3e | 461 | |
jbradshaw | 0:0e40db4a2b3e | 462 | #endif /* PMIC_H_ */ |