1 /*
2  * Copyright 2018-2020 NXP
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef _FSL_PCA9420_H_
9 #define _FSL_PCA9420_H_
10 
11 /*******************************************************************************
12  * Includes
13  ******************************************************************************/
14 #include <stdint.h>
15 #include <stdbool.h>
16 #include "fsl_common.h"
17 
18 /*******************************************************************************
19  * Definitions
20  ******************************************************************************/
21 
22 /*! @brief PCA9420 Default I2C address. */
23 #define PCA9420_DEFAULT_I2C_ADDR 0x61U
24 
25 /*! @brief Define the Register Memory Map of PCA9420. */
26 #define PCA9420_DEV_INFO      (0x00U)
27 #define PCA9420_TOP_INT       (0x01U)
28 #define PCA9420_SUB_INT0      (0x02U)
29 #define PCA9420_SUB_INT0_MASK (0x03U)
30 #define PCA9420_SUB_INT1      (0x04U)
31 #define PCA9420_SUB_INT1_MASK (0x05U)
32 #define PCA9420_SUB_INT2      (0x06U)
33 #define PCA9420_SUB_INT2_MASK (0x07U)
34 #define PCA9420_TOP_CNTL0     (0x09U)
35 #define PCA9420_TOP_CNTL1     (0x0AU)
36 #define PCA9420_TOP_CNTL2     (0x0BU)
37 #define PCA9420_TOP_CNTL3     (0x0CU)
38 #define PCA9420_TOP_CNTL4     (0x0DU)
39 
40 #define PCA9420_CHG_CNTL0    (0x10U)
41 #define PCA9420_CHG_CNTL1    (0x11U)
42 #define PCA9420_CHG_CNTL2    (0x12U)
43 #define PCA9420_CHG_CNTL3    (0x13U)
44 #define PCA9420_CHG_CNTL4    (0x14U)
45 #define PCA9420_CHG_CNTL5    (0x15U)
46 #define PCA9420_CHG_CNTL6    (0x16U)
47 #define PCA9420_CHG_CNTL7    (0x17U)
48 #define PCA9420_CHG_STATUS_0 (0x18U)
49 #define PCA9420_CHG_STATUS_1 (0x19U)
50 #define PCA9420_CHG_STATUS_2 (0x1AU)
51 #define PCA9420_CHG_STATUS_3 (0x1BU)
52 
53 #define PCA9420_REG_STATUS           (0x20U)
54 #define PCA9420_ACT_DISCHARGE_CNTL_1 (0x21U)
55 #define PCA9420_MODECFG_0_0          (0x22U)
56 #define PCA9420_MODECFG_0_1          (0x23U)
57 #define PCA9420_MODECFG_0_2          (0x24U)
58 #define PCA9420_MODECFG_0_3          (0x25U)
59 #define PCA9420_MODECFG_1_0          (0x26U)
60 #define PCA9420_MODECFG_1_1          (0x27U)
61 #define PCA9420_MODECFG_1_2          (0x28U)
62 #define PCA9420_MODECFG_1_3          (0x29U)
63 #define PCA9420_MODECFG_2_0          (0x2AU)
64 #define PCA9420_MODECFG_2_1          (0x2BU)
65 #define PCA9420_MODECFG_2_2          (0x2CU)
66 #define PCA9420_MODECFG_2_3          (0x2DU)
67 #define PCA9420_MODECFG_3_0          (0x2EU)
68 #define PCA9420_MODECFG_3_1          (0x2FU)
69 #define PCA9420_MODECFG_3_2          (0x30U)
70 #define PCA9420_MODECFG_3_3          (0x31U)
71 
72 /*! @brief Define the Register Masks of PCA9420. */
73 #define PCA9420_TOP_CNTL3_MODE_I2C_MASK  (0x18U)
74 #define PCA9420_TOP_CNTL3_MODE_I2C_SHIFT (0x03U)
75 
76 #define PCA9420_MODECFG_0_SHIP_EN_MASK       (0x80U)
77 #define PCA9420_MODECFG_0_MODE_CTRL_SEL_MASK (0x40U)
78 #define PCA9420_MODECFG_0_SW1_OUT_MASK       (0x3FU)
79 #define PCA9420_MODECFG_1_ON_CFG_MASK        (0x40U)
80 #define PCA9420_MODECFG_1_SW2_OUT_MASK       (0x3FU)
81 #define PCA9420_MODECFG_2_LDO1_OUT_MASK      (0xF0U)
82 #define PCA9420_MODECFG_2_LDO1_OUT_SHIFT     (0x04U)
83 #define PCA9420_MODECFG_3_WD_TIMER_MASK      (0xC0U)
84 #define PCA9420_MODECFG_3_LDO2_OUT_MASK      (0x3FU)
85 
86 /*! @brief PCA9420 mode definition. */
87 typedef enum _pca9420_mode
88 {
89     kPCA9420_Mode0 = 0x00U, /* Mode 0. */
90     kPCA9420_Mode1 = 0x01U, /* Mode 1. */
91     kPCA9420_Mode2 = 0x02U, /* Mode 2. */
92     kPCA9420_Mode3 = 0x03U, /* Mode 3. */
93 } pca9420_mode_t;
94 
95 /*! @brief PCA9420 Regulator definition. */
96 typedef enum _pca9420_regulator
97 {
98     kPCA9420_RegulatorSwitch1 = 0x08U, /* Switch1 regulator. */
99     kPCA9420_RegulatorSwitch2 = 0x04U, /* Switch2 regulator. */
100     kPCA9420_RegulatorLdo1    = 0x02U, /* LDO1 regulator. */
101     kPCA9420_RegulatorLdo2    = 0x01U, /* LDO2 regulator. */
102 } pca9420_regulator_t;
103 
104 /*! @brief PCA9420 Interrupt Source definition. */
105 enum _pca9420_interrupt_source
106 {
107     /* Sub_INT0 */
108     kPCA9420_IntSrcSysVinOKChanged    = 0x1U,  /* VIN_OK changed interrupt source. */
109     kPCA9420_IntSrcSysWdogTimeout     = 0x2U,  /* Watchdog timeout interrupt source. */
110     kPCA9420_IntSrcSysAsysPreWarn     = 0x4U,  /* VSYS voltage falls below the VSYS_PRE_WRN interrupt source. */
111     kPCA9420_IntSrcSysThermalShutdown = 0x8U,  /* Thermal shutdown (Die temp >= THM_STDN) interrupt source. */
112     kPCA9420_IntSrcSysTempWarn        = 0x10U, /* Die temp pre-warning (Die temp >= T_WRN) interrupt source. */
113     kPCA9420_IntSrcSysAll             = 0x1FU, /* All system interrupt sources. */
114 
115     /* Sub_INT1 */
116     kPCA9420_IntSrcChgChgOk           = 0x100U,  /* CHG_OK changed interrupt source. */
117     kPCA9420_IntSrcChgVbatOk          = 0x200U,  /* VBAT_OK changed interrupt source. */
118     kPCA9420_IntSrcChgVbatDetOk       = 0x400U,  /* VBAT_DET_OK changed interrupt source. */
119     kPCA9420_IntSrcChgPreChgTimeout   = 0x800U,  /* Pre-qualification charge timeout interrupt source. */
120     kPCA9420_IntSrcChgFastChgTimeout  = 0x1000U, /* Fast charge timeout interrupt source. */
121     kPCA9420_IntSrcChgInputCurrentLmt = 0x2000U, /* Input current limit interrupt source. */
122     kPCA9420_IntSrcChgAll             = 0x3F00U, /* All charger interrupt sources. */
123 
124     /* Sub_INT2 */
125     kPCA9420_IntSrcLdo2VoutOk   = 0x10000U, /* VOUTLDO2_OK changed interrupt source. */
126     kPCA9420_IntSrcLdo1VoutOk   = 0x20000U, /* VOUTLDO1_OK changed interrupt source. */
127     kPCA9420_IntSrcSw2VoutOk    = 0x40000U, /* VOUTSW2_OK changed interrupt source. */
128     kPCA9420_IntSrcSw1VoutOk    = 0x80000U, /* VOUTSW1_OK changed interrupt source. */
129     kPCA9420_IntSrcRegulatorAll = 0xF0000U, /* All regulator interrupt sources. */
130 };
131 
132 /*! @brief PCA9420 VIN Current Limit Selection definition. */
133 typedef enum _pca9420_vin_ilim
134 {
135     kPCA9420_VinIlim_74_85_98      = 0x00U, /* min: 74mA, typ: 85mA, max: 98mA */
136     kPCA9420_VinIlim_222_225_293   = 0x20U, /* min: 222mA, typ: 225mA, max: 293mA */
137     kPCA9420_VinIlim_370_425_489   = 0x40U, /* min: 370mA, typ: 425mA, max: 489mA */
138     kPCA9420_VinIlim_517_595_684   = 0x60U, /* min: 517mA, typ: 595mA, max: 684mA */
139     kPCA9420_VinIlim_665_765_880   = 0x80U, /* min: 665mA, typ: 765mA, max: 880mA */
140     kPCA9420_VinIlim_813_935_1075  = 0xA0U, /* min: 813mA, typ: 935mA, max: 1075mA */
141     kPCA9420_VinIlim_961_1105_1271 = 0xC0U, /* min: 961mA, typ: 1105mA, max: 1271mA */
142     kPCA9420_VinIlim_Disabled      = 0xE0U, /* Input current limit disabled */
143 } pca9420_vin_ilim_t;
144 
145 /*! @brief PCA9420 Ship Wakeup config definition. */
146 typedef enum _pca9420_ship_wkup_cfg
147 {
148     kPCA9420_ShipWkup_PowerUp = 0x00U,   /* Upon VIN plug in, the chip will enable the battery charging process, and
149                                               start the power-up sequence for LDO1/LDO2/SW1/SW2 per the setting */
150     kPCA9420_ShipWkup_NoPowerUp = 0x10U, /* Upon VIN plug in, the chip will enable the charging process,
151                                               LDO1/LDO2/SW1/SW2 remain in shutdown mode and the chip will only enable
152                                               the power-up sequence upon ON pin falling edge */
153 } pca9420_ship_wkup_cfg_t;
154 
155 /*! @brief PCA9420 Power Down Sequence Enable definition. */
156 typedef enum _pca9420_pwr_dn_en
157 {
158     kPCA9420_PwrDnDisabled = 0x00U, /* Do not start power-down sequence */
159     kPCA9420_PwrDnEnabled  = 0x08U, /* Start power-down sequence */
160 } pca9420_pwr_dn_en_t;
161 
162 /*! @brief PCA9420 Ship Wakeup config definition. */
163 typedef enum _pca9420_chg_in_watchdog
164 {
165     kPCA9420_ChgInWatchdogChargerContinue = 0x00U, /* When the watchdog timer expires, charger continue its operation */
166     kPCA9420_ChgInWatchdogChargerDisabled = 0x04U, /* When the watchdog timer expires, charger is disabled */
167 } pca9420_chg_in_watchdog_t;
168 
169 /*! @brief PCA9420 Power Good Comparator Enable definition. */
170 typedef enum _pca9420_pgood_en
171 {
172     kPCA9420_PGoodDisabled = 0x00U, /* Output voltage power-good comparators are disabled. */
173     kPCA9420_PGoodEnabled  = 0x01U, /* Output voltage power-good comparators are enabled. */
174 } pca9420_pgood_en_t;
175 
176 /*! @brief PCA9420 VSYS Pre Warning Voltage Threshold definition. */
177 typedef enum _pca9420_asys_prewarning
178 {
179     kPCA9420_AsysPreWarn3V3 = 0x00U, /* VSYS pre-warning voltage threshold 3.3V */
180     kPCA9420_AsysPreWarn3V4 = 0x40U, /* VSYS pre-warning voltage threshold 3.4V */
181     kPCA9420_AsysPreWarn3V5 = 0x80U, /* VSYS pre-warning voltage threshold 3.5V */
182     kPCA9420_AsysPreWarn3V6 = 0xC0U, /* VSYS pre-warning voltage threshold 3.6V */
183 } pca9420_asys_prewarning_t;
184 
185 /*! @brief PCA9420 VSYS Input Source Selection definition. */
186 typedef enum _pca9420_asys_input_sel
187 {
188     kPCA9420_AsysInputSelVbatVin =
189         0x00U, /* VSYS is powered by either VBAT or VIN, VIN has higher priority if both are presented. */
190     kPCA9420_AsysInputSelVbat = 0x10U, /* VSYS is powered by VBAT only. */
191     kPCA9420_AsysInputSelVin  = 0x20U, /* VSYS is powered by VIN only. */
192     kPCA9420_AsysInputSelNone = 0x30U, /* VSYS is disconnected to either VBAT or VIN (test purpose only). */
193 } pca9420_asys_input_sel_t;
194 
195 /*! @brief PCA9420 VIN Over-voltage Protection Threshold Selection definition. */
196 typedef enum _pca9420_vin_ovp_sel
197 {
198     kPCA9420_VinOvpSel5V5 = 0x00U, /* VIN Over-Voltage Protection threshold 5.5V. */
199     kPCA9420_VinOvpSel6V0 = 0x04U, /* VIN Over-Voltage Protection threshold 6.0V. */
200 } pca9420_vin_ovp_sel_t;
201 
202 /*! @brief PCA9420 VIN Under-voltage Lockout Threshold Selection definition. */
203 typedef enum _pca9420_vin_uvlo_sel
204 {
205     kPCA9420_VinUvloSel2V9 = 0x0U, /* VIN Under-Voltage Lockout threshold 2.9V. */
206     kPCA9420_VinUvloSel3V1 = 0x1U, /* VIN Under-Voltage Lockout threshold 3.1V. */
207     kPCA9420_VinUvloSel3V3 = 0x2U, /* VIN Under-Voltage Lockout threshold 3.3V. */
208     kPCA9420_VinUvloSel3V5 = 0x3U, /* VIN Under-Voltage Lockout threshold 3.5V. */
209 } pca9420_vin_uvlo_sel_t;
210 
211 /*! @brief PCA9420 VSYS Under-voltage Lockout Threshold Selection definition. */
212 typedef enum _pca9420_asys_uvlo_sel
213 {
214     kPCA9420_AsysUvloSel2V4 = 0x00U, /* VSYS Under-Voltage Lockout threshold 2.4V. */
215     kPCA9420_AsysUvloSel2V5 = 0x40U, /* VSYS Under-Voltage Lockout threshold 2.5V. */
216     kPCA9420_AsysUvloSel2V6 = 0x80U, /* VSYS Under-Voltage Lockout threshold 2.6V. */
217     kPCA9420_AsysUvloSel2V7 = 0xC0U, /* VSYS Under-Voltage Lockout threshold 2.7V. */
218 } pca9420_asys_uvlo_sel_t;
219 
220 /*! @brief PCA9420 Disable Charge Termination definition. */
221 typedef enum _pca9420_charge_term_dis
222 {
223     kPCA9420_ChargeTermEnabled  = 0x00U, /* Enable the charge termination control. */
224     kPCA9420_ChargeTermDisabled = 0x20U, /* Disable the charge termination control, fast charge timer is reset. */
225 } pca9420_charge_term_dis_t;
226 
227 /*! @brief PCA9420 Thermal Shutdown Temperature Threshold definition. */
228 typedef enum _pca9420_them_shdn
229 {
230     kPCA9420_ThemShdn95C  = 0x00U, /* Thermal shutdown temperature threshold 95C. */
231     kPCA9420_ThemShdn100C = 0x04U, /* Thermal shutdown temperature threshold 100C. */
232     kPCA9420_ThemShdn105C = 0x08U, /* Thermal shutdown temperature threshold 105C. */
233     kPCA9420_ThemShdn110C = 0x0CU, /* Thermal shutdown temperature threshold 110C. */
234     kPCA9420_ThemShdn115C = 0x10U, /* Thermal shutdown temperature threshold 115C. */
235     kPCA9420_ThemShdn120C = 0x14U, /* Thermal shutdown temperature threshold 120C. */
236     kPCA9420_ThemShdn125C = 0x18U, /* Thermal shutdown temperature threshold 125C. */
237 } pca9420_them_shdn_t;
238 
239 /*! @brief PCA9420 Die Temperature Warning Threshold definition. */
240 typedef enum _pca9420_die_temp_warning
241 {
242     kPCA9420_DieTempWarn75C = 0x00U, /* Die temperature warning threshold 75C. */
243     kPCA9420_DieTempWarn80C = 0x01U, /* Die temperature warning threshold 80C. */
244     kPCA9420_DieTempWarn85C = 0x02U, /* Die temperature warning threshold 85C. */
245     kPCA9420_DieTempWarn90C = 0x03U, /* Die temperature warning threshold 90C. */
246 } pca9420_die_temp_warning_t;
247 
248 /*! @brief PCA9420 Mode I2C definition. */
249 typedef enum _pca9420_mode_i2c
250 {
251     kPCA9420_ModeI2cMode0 = 0x00U, /* PMIC mode set to mode 0, in case MODE_CTRL_SEL == 0. */
252     kPCA9420_ModeI2cMode1 = 0x08U, /* PMIC mode set to mode 1, in case MODE_CTRL_SEL == 0. */
253     kPCA9420_ModeI2cMode2 = 0x10U, /* PMIC mode set to mode 2, in case MODE_CTRL_SEL == 0. */
254     kPCA9420_ModeI2cMode3 = 0x18U, /* PMIC mode set to mode 3, in case MODE_CTRL_SEL == 0. */
255 } pca9420_mode_i2c_t;
256 
257 /*! @brief PCA9420 ON Pin Long Glitch Timer definition. */
258 typedef enum _pca9420_on_glt_long
259 {
260     kPCA9420_OnGltLong4s  = 0x00U, /* ON pin long glitch timer set to 4 sec. */
261     kPCA9420_OnGltLong8s  = 0x01U, /* ON pin long glitch timer set to 8 sec. */
262     kPCA9420_OnGltLong12s = 0x02U, /* ON pin long glitch timer set to 12 sec. */
263     kPCA9420_OnGltLong16s = 0x03U, /* ON pin long glitch timer set to 16 sec. */
264 } pca9420_on_glt_long_t;
265 
266 /* TODO: charger function */
267 
268 /*! @brief PCA9420 Regulator Status definition. */
269 typedef enum _pca9420_reg_status
270 {
271     kPCA9420_RegStatusVoutSw1OK  = 0x80U, /* SW1 VOUT Power good status */
272     kPCA9420_RegStatusVoutSw2OK  = 0x40U, /* SW2 VOUT Power good status */
273     kPCA9420_RegStatusVoutLdo1OK = 0x20U, /* LDO1 VOUT Power good status */
274     kPCA9420_RegStatusVoutLdo2OK = 0x10U, /* LDO2 VOUT Power good status */
275 } pca9420_reg_status_t;
276 
277 /*! @brief PCA9420 Regulator Control definition. */
278 typedef enum _pca9420_reg_ctl
279 {
280     kPCA9420_RegCtlSw1Bleed  = 0x08U, /* SW1 output active discharge control (0: enable, 1: disable). */
281     kPCA9420_RegCtlSw2Bleed  = 0x04U, /* SW2 output active discharge control (0: enable, 1: disable). */
282     kPCA9420_RegCtlLdo1Bleed = 0x02U, /* LDO1 output active discharge control (0: enable, 1: disable). */
283     kPCA9420_RegCtlLdo2Bleed = 0x01U, /* LDO2 output active discharge control (0: enable, 1: disable). */
284 } pca9420_reg_ctl_t;
285 
286 /*! @brief PCA9420 Ship Mode Enablement definition. */
287 typedef enum _pca9420_ship_en
288 {
289     kPCA9420_ShipModeDisabled = 0x00U, /* Ship mode disabled. */
290     kPCA9420_ShipModeEnabled  = 0x80U, /* Ship mode enabled, chip enters state with lowest quiescent consumption. */
291 } pca9420_ship_en_t;
292 
293 /*! @brief PCA9420 Mode Control Selection definition. */
294 typedef enum _pca9420_mode_sel
295 {
296     kPCA9420_ModeSelI2C = 0x00U, /* Mode control select by I2C register bits. */
297     kPCA9420_ModeSelPin = 0x40U, /* Mode control select by external pins. */
298 } pca9420_mode_sel_t;
299 
300 /*! @brief PCA9420 SW1 Output Voltage definition. */
301 typedef enum _pca9420_sw1_out
302 {
303     kPCA9420_Sw1OutVolt0V500 = 0x00U, /* SW1 output voltage 0.500V. */
304     kPCA9420_Sw1OutVolt0V525 = 0x01U, /* SW1 output voltage 0.525V. */
305     kPCA9420_Sw1OutVolt0V550 = 0x02U, /* SW1 output voltage 0.550V. */
306     kPCA9420_Sw1OutVolt0V575 = 0x03U, /* SW1 output voltage 0.575V. */
307     kPCA9420_Sw1OutVolt0V600 = 0x04U, /* SW1 output voltage 0.600V. */
308     kPCA9420_Sw1OutVolt0V625 = 0x05U, /* SW1 output voltage 0.625V. */
309     kPCA9420_Sw1OutVolt0V650 = 0x06U, /* SW1 output voltage 0.650V. */
310     kPCA9420_Sw1OutVolt0V675 = 0x07U, /* SW1 output voltage 0.675V. */
311     kPCA9420_Sw1OutVolt0V700 = 0x08U, /* SW1 output voltage 0.700V. */
312     kPCA9420_Sw1OutVolt0V725 = 0x09U, /* SW1 output voltage 0.725V. */
313     kPCA9420_Sw1OutVolt0V750 = 0x0AU, /* SW1 output voltage 0.750V. */
314     kPCA9420_Sw1OutVolt0V775 = 0x0BU, /* SW1 output voltage 0.775V. */
315     kPCA9420_Sw1OutVolt0V800 = 0x0CU, /* SW1 output voltage 0.800V. */
316     kPCA9420_Sw1OutVolt0V825 = 0x0DU, /* SW1 output voltage 0.825V. */
317     kPCA9420_Sw1OutVolt0V850 = 0x0EU, /* SW1 output voltage 0.850V. */
318     kPCA9420_Sw1OutVolt0V875 = 0x0FU, /* SW1 output voltage 0.875V. */
319     kPCA9420_Sw1OutVolt0V900 = 0x10U, /* SW1 output voltage 0.900V. */
320     kPCA9420_Sw1OutVolt0V925 = 0x11U, /* SW1 output voltage 0.925V. */
321     kPCA9420_Sw1OutVolt0V950 = 0x12U, /* SW1 output voltage 0.950V. */
322     kPCA9420_Sw1OutVolt0V975 = 0x13U, /* SW1 output voltage 0.975V. */
323     kPCA9420_Sw1OutVolt1V000 = 0x14U, /* SW1 output voltage 1.000V. */
324     kPCA9420_Sw1OutVolt1V025 = 0x15U, /* SW1 output voltage 1.025V. */
325     kPCA9420_Sw1OutVolt1V050 = 0x16U, /* SW1 output voltage 1.050V. */
326     kPCA9420_Sw1OutVolt1V075 = 0x17U, /* SW1 output voltage 1.075V. */
327     kPCA9420_Sw1OutVolt1V100 = 0x18U, /* SW1 output voltage 1.100V. */
328     kPCA9420_Sw1OutVolt1V125 = 0x19U, /* SW1 output voltage 1.125V. */
329     kPCA9420_Sw1OutVolt1V150 = 0x1AU, /* SW1 output voltage 1.150V. */
330     kPCA9420_Sw1OutVolt1V175 = 0x1BU, /* SW1 output voltage 1.175V. */
331     kPCA9420_Sw1OutVolt1V200 = 0x1CU, /* SW1 output voltage 1.200V. */
332     kPCA9420_Sw1OutVolt1V225 = 0x1DU, /* SW1 output voltage 1.225V. */
333     kPCA9420_Sw1OutVolt1V250 = 0x1EU, /* SW1 output voltage 1.250V. */
334     kPCA9420_Sw1OutVolt1V275 = 0x1FU, /* SW1 output voltage 1.275V. */
335     kPCA9420_Sw1OutVolt1V300 = 0x20U, /* SW1 output voltage 1.300V. */
336     kPCA9420_Sw1OutVolt1V325 = 0x21U, /* SW1 output voltage 1.325V. */
337     kPCA9420_Sw1OutVolt1V350 = 0x22U, /* SW1 output voltage 1.350V. */
338     kPCA9420_Sw1OutVolt1V375 = 0x23U, /* SW1 output voltage 1.375V. */
339     kPCA9420_Sw1OutVolt1V400 = 0x24U, /* SW1 output voltage 1.400V. */
340     kPCA9420_Sw1OutVolt1V425 = 0x25U, /* SW1 output voltage 1.425V. */
341     kPCA9420_Sw1OutVolt1V450 = 0x26U, /* SW1 output voltage 1.450V. */
342     kPCA9420_Sw1OutVolt1V475 = 0x27U, /* SW1 output voltage 1.475V. */
343     kPCA9420_Sw1OutVolt1V500 = 0x28U, /* SW1 output voltage 1.500V. */
344     kPCA9420_Sw1OutVolt1V800 = 0x3FU, /* SW1 output voltage 1.800V. */
345 } pca9420_sw1_out_t;
346 
347 /*! @brief PCA9420 ON Key Config definition for mode switch. */
348 typedef enum _pca9420_on_cfg
349 {
350     kPCA9420_OnCfgEnableModeSwitch =
351         0x00U, /* Upon valid falling edge applied on ON pin, the device will switch back to mode 0. */
352     kPCA9420_OnCfgDisableModeSwitch = 0x40U, /* Upon valid falling edge applied on ON pin, no mode switch. */
353 } pca9420_on_cfg_t;
354 
355 /*! @brief PCA9420 SW2 Output Voltage definition. */
356 typedef enum _pca9420_sw2_out
357 {
358     kPCA9420_Sw2OutVolt1V500 = 0x00U, /* SW2 output voltage 1.500V. */
359     kPCA9420_Sw2OutVolt1V525 = 0x01U, /* SW2 output voltage 1.525V. */
360     kPCA9420_Sw2OutVolt1V550 = 0x02U, /* SW2 output voltage 1.550V. */
361     kPCA9420_Sw2OutVolt1V575 = 0x03U, /* SW2 output voltage 1.575V. */
362     kPCA9420_Sw2OutVolt1V600 = 0x04U, /* SW2 output voltage 1.600V. */
363     kPCA9420_Sw2OutVolt1V625 = 0x05U, /* SW2 output voltage 1.625V. */
364     kPCA9420_Sw2OutVolt1V650 = 0x06U, /* SW2 output voltage 1.650V. */
365     kPCA9420_Sw2OutVolt1V675 = 0x07U, /* SW2 output voltage 1.675V. */
366     kPCA9420_Sw2OutVolt1V700 = 0x08U, /* SW2 output voltage 1.700V. */
367     kPCA9420_Sw2OutVolt1V725 = 0x09U, /* SW2 output voltage 1.725V. */
368     kPCA9420_Sw2OutVolt1V750 = 0x0AU, /* SW2 output voltage 1.750V. */
369     kPCA9420_Sw2OutVolt1V775 = 0x0BU, /* SW2 output voltage 1.775V. */
370     kPCA9420_Sw2OutVolt1V800 = 0x0CU, /* SW2 output voltage 1.800V. */
371     kPCA9420_Sw2OutVolt1V825 = 0x0DU, /* SW2 output voltage 1.825V. */
372     kPCA9420_Sw2OutVolt1V850 = 0x0EU, /* SW2 output voltage 1.850V. */
373     kPCA9420_Sw2OutVolt1V875 = 0x0FU, /* SW2 output voltage 1.875V. */
374     kPCA9420_Sw2OutVolt1V900 = 0x10U, /* SW2 output voltage 1.900V. */
375     kPCA9420_Sw2OutVolt1V925 = 0x11U, /* SW2 output voltage 1.925V. */
376     kPCA9420_Sw2OutVolt1V950 = 0x12U, /* SW2 output voltage 1.950V. */
377     kPCA9420_Sw2OutVolt1V975 = 0x13U, /* SW2 output voltage 1.975V. */
378     kPCA9420_Sw2OutVolt2V000 = 0x14U, /* SW2 output voltage 2.000V. */
379     kPCA9420_Sw2OutVolt2V025 = 0x15U, /* SW2 output voltage 2.025V. */
380     kPCA9420_Sw2OutVolt2V050 = 0x16U, /* SW2 output voltage 2.050V. */
381     kPCA9420_Sw2OutVolt2V075 = 0x17U, /* SW2 output voltage 2.075V. */
382     kPCA9420_Sw2OutVolt2V100 = 0x18U, /* SW2 output voltage 2.100V. */
383 
384     kPCA9420_Sw2OutVolt2V700 = 0x20U, /* SW2 output voltage 2.700V. */
385     kPCA9420_Sw2OutVolt2V725 = 0x21U, /* SW2 output voltage 2.725V. */
386     kPCA9420_Sw2OutVolt2V750 = 0x22U, /* SW2 output voltage 2.750V. */
387     kPCA9420_Sw2OutVolt2V775 = 0x23U, /* SW2 output voltage 2.775V. */
388     kPCA9420_Sw2OutVolt2V800 = 0x24U, /* SW2 output voltage 2.800V. */
389     kPCA9420_Sw2OutVolt2V825 = 0x25U, /* SW2 output voltage 2.825V. */
390     kPCA9420_Sw2OutVolt2V850 = 0x26U, /* SW2 output voltage 2.850V. */
391     kPCA9420_Sw2OutVolt2V875 = 0x27U, /* SW2 output voltage 2.875V. */
392     kPCA9420_Sw2OutVolt2V900 = 0x28U, /* SW2 output voltage 2.900V. */
393     kPCA9420_Sw2OutVolt2V925 = 0x29U, /* SW2 output voltage 2.925V. */
394     kPCA9420_Sw2OutVolt2V950 = 0x2AU, /* SW2 output voltage 2.950V. */
395     kPCA9420_Sw2OutVolt2V975 = 0x2BU, /* SW2 output voltage 2.975V. */
396     kPCA9420_Sw2OutVolt3V000 = 0x2CU, /* SW2 output voltage 3.000V. */
397     kPCA9420_Sw2OutVolt3V025 = 0x2DU, /* SW2 output voltage 3.025V. */
398     kPCA9420_Sw2OutVolt3V050 = 0x2EU, /* SW2 output voltage 3.050V. */
399     kPCA9420_Sw2OutVolt3V075 = 0x2FU, /* SW2 output voltage 3.075V. */
400     kPCA9420_Sw2OutVolt3V100 = 0x30U, /* SW2 output voltage 3.100V. */
401     kPCA9420_Sw2OutVolt3V125 = 0x31U, /* SW2 output voltage 3.125V. */
402     kPCA9420_Sw2OutVolt3V150 = 0x32U, /* SW2 output voltage 3.150V. */
403     kPCA9420_Sw2OutVolt3V175 = 0x33U, /* SW2 output voltage 3.175V. */
404     kPCA9420_Sw2OutVolt3V200 = 0x34U, /* SW2 output voltage 3.200V. */
405     kPCA9420_Sw2OutVolt3V225 = 0x35U, /* SW2 output voltage 3.225V. */
406     kPCA9420_Sw2OutVolt3V250 = 0x36U, /* SW2 output voltage 3.250V. */
407     kPCA9420_Sw2OutVolt3V275 = 0x37U, /* SW2 output voltage 3.275V. */
408     kPCA9420_Sw2OutVolt3V300 = 0x38U, /* SW2 output voltage 3.300V. */
409 } pca9420_sw2_out_t;
410 
411 /*! @brief PCA9420 LDO1 Output Voltage definition. */
412 typedef enum _pca9420_ldo1_out
413 {
414     kPCA9420_Ldo1OutVolt1V700 = 0x00U, /* LDO1 output voltage 1.700V. */
415     kPCA9420_Ldo1OutVolt1V725 = 0x10U, /* LDO1 output voltage 1.725V. */
416     kPCA9420_Ldo1OutVolt1V750 = 0x20U, /* LDO1 output voltage 1.750V. */
417     kPCA9420_Ldo1OutVolt1V775 = 0x30U, /* LDO1 output voltage 1.775V. */
418     kPCA9420_Ldo1OutVolt1V800 = 0x40U, /* LDO1 output voltage 1.800V. */
419     kPCA9420_Ldo1OutVolt1V825 = 0x50U, /* LDO1 output voltage 1.825V. */
420     kPCA9420_Ldo1OutVolt1V850 = 0x60U, /* LDO1 output voltage 1.850V. */
421     kPCA9420_Ldo1OutVolt1V875 = 0x70U, /* LDO1 output voltage 1.875V. */
422     kPCA9420_Ldo1OutVolt1V900 = 0x80U, /* LDO1 output voltage 1.900V. */
423 } pca9420_ldo1_out_t;
424 
425 /*! @brief PCA9420 Watchdog Timer Setting definition. */
426 typedef enum _pca9420_wd_timer
427 {
428     kPCA9420_WdTimerDisabled = 0x00U, /* Watch dog timer disabled. */
429     kPCA9420_WdTimer16s      = 0x40U, /* Watch dog timer timeout value is 16 sec. */
430     kPCA9420_WdTimer32s      = 0x80U, /* Watch dog timer timeout value is 32 sec. */
431     kPCA9420_WdTimer64s      = 0xC0U, /* Watch dog timer timeout value is 64 sec. */
432 } pca9420_wd_timer_t;
433 
434 /*! @brief PCA9420 LDO2 Output Voltage definition. */
435 typedef enum _pca9420_ldo2_out
436 {
437     kPCA9420_Ldo2OutVolt1V500 = 0x00U, /* LDO2 output voltage 1.500V. */
438     kPCA9420_Ldo2OutVolt1V525 = 0x01U, /* LDO2 output voltage 1.525V. */
439     kPCA9420_Ldo2OutVolt1V550 = 0x02U, /* LDO2 output voltage 1.550V. */
440     kPCA9420_Ldo2OutVolt1V575 = 0x03U, /* LDO2 output voltage 1.575V. */
441     kPCA9420_Ldo2OutVolt1V600 = 0x04U, /* LDO2 output voltage 1.600V. */
442     kPCA9420_Ldo2OutVolt1V625 = 0x05U, /* LDO2 output voltage 1.625V. */
443     kPCA9420_Ldo2OutVolt1V650 = 0x06U, /* LDO2 output voltage 1.650V. */
444     kPCA9420_Ldo2OutVolt1V675 = 0x07U, /* LDO2 output voltage 1.675V. */
445     kPCA9420_Ldo2OutVolt1V700 = 0x08U, /* LDO2 output voltage 1.700V. */
446     kPCA9420_Ldo2OutVolt1V725 = 0x09U, /* LDO2 output voltage 1.725V. */
447     kPCA9420_Ldo2OutVolt1V750 = 0x0AU, /* LDO2 output voltage 1.750V. */
448     kPCA9420_Ldo2OutVolt1V775 = 0x0BU, /* LDO2 output voltage 1.775V. */
449     kPCA9420_Ldo2OutVolt1V800 = 0x0CU, /* LDO2 output voltage 1.800V. */
450     kPCA9420_Ldo2OutVolt1V825 = 0x0DU, /* LDO2 output voltage 1.825V. */
451     kPCA9420_Ldo2OutVolt1V850 = 0x0EU, /* LDO2 output voltage 1.850V. */
452     kPCA9420_Ldo2OutVolt1V875 = 0x0FU, /* LDO2 output voltage 1.875V. */
453     kPCA9420_Ldo2OutVolt1V900 = 0x10U, /* LDO2 output voltage 1.900V. */
454     kPCA9420_Ldo2OutVolt1V925 = 0x11U, /* LDO2 output voltage 1.925V. */
455     kPCA9420_Ldo2OutVolt1V950 = 0x12U, /* LDO2 output voltage 1.950V. */
456     kPCA9420_Ldo2OutVolt1V975 = 0x13U, /* LDO2 output voltage 1.975V. */
457     kPCA9420_Ldo2OutVolt2V000 = 0x14U, /* LDO2 output voltage 2.000V. */
458     kPCA9420_Ldo2OutVolt2V025 = 0x15U, /* LDO2 output voltage 2.025V. */
459     kPCA9420_Ldo2OutVolt2V050 = 0x16U, /* LDO2 output voltage 2.050V. */
460     kPCA9420_Ldo2OutVolt2V075 = 0x17U, /* LDO2 output voltage 2.075V. */
461     kPCA9420_Ldo2OutVolt2V100 = 0x18U, /* LDO2 output voltage 2.100V. */
462 
463     kPCA9420_Ldo2OutVolt2V700 = 0x20U, /* LDO2 output voltage 2.700V. */
464     kPCA9420_Ldo2OutVolt2V725 = 0x21U, /* LDO2 output voltage 2.725V. */
465     kPCA9420_Ldo2OutVolt2V750 = 0x22U, /* LDO2 output voltage 2.750V. */
466     kPCA9420_Ldo2OutVolt2V775 = 0x23U, /* LDO2 output voltage 2.775V. */
467     kPCA9420_Ldo2OutVolt2V800 = 0x24U, /* LDO2 output voltage 2.800V. */
468     kPCA9420_Ldo2OutVolt2V825 = 0x25U, /* LDO2 output voltage 2.825V. */
469     kPCA9420_Ldo2OutVolt2V850 = 0x26U, /* LDO2 output voltage 2.850V. */
470     kPCA9420_Ldo2OutVolt2V875 = 0x27U, /* LDO2 output voltage 2.875V. */
471     kPCA9420_Ldo2OutVolt2V900 = 0x28U, /* LDO2 output voltage 2.900V. */
472     kPCA9420_Ldo2OutVolt2V925 = 0x29U, /* LDO2 output voltage 2.925V. */
473     kPCA9420_Ldo2OutVolt2V950 = 0x2AU, /* LDO2 output voltage 2.950V. */
474     kPCA9420_Ldo2OutVolt2V975 = 0x2BU, /* LDO2 output voltage 2.975V. */
475     kPCA9420_Ldo2OutVolt3V000 = 0x2CU, /* LDO2 output voltage 3.000V. */
476     kPCA9420_Ldo2OutVolt3V025 = 0x2DU, /* LDO2 output voltage 3.025V. */
477     kPCA9420_Ldo2OutVolt3V050 = 0x2EU, /* LDO2 output voltage 3.050V. */
478     kPCA9420_Ldo2OutVolt3V075 = 0x2FU, /* LDO2 output voltage 3.075V. */
479     kPCA9420_Ldo2OutVolt3V100 = 0x30U, /* LDO2 output voltage 3.100V. */
480     kPCA9420_Ldo2OutVolt3V125 = 0x31U, /* LDO2 output voltage 3.125V. */
481     kPCA9420_Ldo2OutVolt3V150 = 0x32U, /* LDO2 output voltage 3.150V. */
482     kPCA9420_Ldo2OutVolt3V175 = 0x33U, /* LDO2 output voltage 3.175V. */
483     kPCA9420_Ldo2OutVolt3V200 = 0x34U, /* LDO2 output voltage 3.200V. */
484     kPCA9420_Ldo2OutVolt3V225 = 0x35U, /* LDO2 output voltage 3.225V. */
485     kPCA9420_Ldo2OutVolt3V250 = 0x36U, /* LDO2 output voltage 3.250V. */
486     kPCA9420_Ldo2OutVolt3V275 = 0x37U, /* LDO2 output voltage 3.275V. */
487     kPCA9420_Ldo2OutVolt3V300 = 0x38U, /* LDO2 output voltage 3.300V. */
488 } pca9420_ldo2_out_t;
489 
490 /*! @brief PCA9420 Mode Configuration definition. */
491 typedef struct _pca9420_modecfg
492 {
493     pca9420_ship_en_t shipModeEnable;
494     pca9420_mode_sel_t modeSel;
495     pca9420_on_cfg_t onCfg;
496     pca9420_wd_timer_t wdogTimerCfg;
497     pca9420_sw1_out_t sw1OutVolt;
498     pca9420_sw2_out_t sw2OutVolt;
499     pca9420_ldo1_out_t ldo1OutVolt;
500     pca9420_ldo2_out_t ldo2OutVolt;
501     bool enableSw1Out;
502     bool enableSw2Out;
503     bool enableLdo1Out;
504     bool enableLdo2Out;
505 } pca9420_modecfg_t;
506 
507 /*! @brief PCA9420 regulators voltage definition. */
508 typedef struct _pca9420_regulator_mv
509 {
510     uint32_t mVoltSw1;  /* SW1 milli volt. */
511     uint32_t mVoltSw2;  /* SW2 milli volt. */
512     uint32_t mVoltLdo1; /* LDO1 milli volt. */
513     uint32_t mVoltLdo2; /* LDO2 milli volt. */
514 } pca9420_regulator_mv_t;
515 
516 /*! @brief PCA9420 Handle definition. */
517 typedef struct _pca9420_handle
518 {
519     /* Pointer to the user-defined I2C Send Data function. */
520     status_t (*I2C_SendFunc)(
521         uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize);
522     /* Pointer to the user-defined I2C Receive Data function. */
523     status_t (*I2C_ReceiveFunc)(
524         uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
525     /* The I2C Slave Address Read From OTP. */
526     uint8_t slaveAddress;
527 } pca9420_handle_t;
528 
529 /*! @brief PCA9420 Configuration Structure definition. */
530 typedef struct _pca9420_config
531 {
532     /* Pointer to the user-defined I2C Send Data function. */
533     status_t (*I2C_SendFunc)(
534         uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, const uint8_t *txBuff, uint8_t txBuffSize);
535     /* Pointer to the user-defined I2C Receive Data function. */
536     status_t (*I2C_ReceiveFunc)(
537         uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize);
538     /* Upon VIN plugs in, power up by ON key or not. */
539     pca9420_ship_wkup_cfg_t powerUpCfg;
540     /* Power down sequence enable */
541     pca9420_pwr_dn_en_t startPowerDown;
542     /* When the watch dog timer expires, disable charger or not */
543     pca9420_chg_in_watchdog_t wdogChargeCtrl;
544     /* Power Good Comparators Enable */
545     pca9420_pgood_en_t powerGoodEnable;
546     /* VIN input current limit. */
547     pca9420_vin_ilim_t vinCurrentLimit;
548     /* VIN over voltage protection threshold */
549     pca9420_vin_ovp_sel_t vinOvpThreshold;
550     /* VIN under voltage lockout threshold */
551     pca9420_vin_uvlo_sel_t vinUvloThreshold;
552     /* VSYS pre-warning threshold */
553     pca9420_asys_prewarning_t asysPreWarnThreshold;
554     /* VSYS input selection */
555     pca9420_asys_input_sel_t asysInputSource;
556     /* VSYS under voltage lockout threshold */
557     pca9420_asys_uvlo_sel_t asysUvloThreshold;
558     /* Charge termination control */
559     pca9420_charge_term_dis_t chargeTermDisable;
560     /* Thermal shutdown threshold */
561     pca9420_them_shdn_t thermalShutdownThreshold;
562     /* Die temperature warning threshold */
563     pca9420_die_temp_warning_t tempWarnThreshold;
564     /* ON pin long glitch timer */
565     pca9420_on_glt_long_t onPinTimer;
566     /* Disable SW1 active discharge */
567     bool disableSw1Bleed;
568     /* Disable SW2 active discharge */
569     bool disableSw2Bleed;
570     /* Disable LDO1 active discharge */
571     bool disableLdo1Bleed;
572     /* Disable LDO2 active discharge */
573     bool disableLdo2Bleed;
574     /* The PCA9420 I2C Slave Address. */
575     uint8_t slaveAddress;
576 } pca9420_config_t;
577 
578 /*!
579  * @addtogroup pca9420
580  * @{
581  */
582 
583 /*******************************************************************************
584  * API
585  ******************************************************************************/
586 #if defined(__cplusplus)
587 extern "C" {
588 #endif
589 
590 /*!
591  * @name Initialization and Control function
592  * @{
593  */
594 
595 /*!
596  * @brief Gets the default configuration structure.
597  *
598  * This function initializes the PCA9420 configuration structure to default values. The default
599  * values are as follows.
600  *   pca9420Config->I2C_SendFunc              = NULL;
601  *   pca9420Config->I2C_ReceiveFunc           = NULL;
602  *   pca9420Config->powerUpCfg                = kPCA9420_ShipWkup_PowerUp;
603  *   pca9420Config->startPowerDown            = kPCA9420_PwrDnDisabled;
604  *   pca9420Config->wdogChargeCtrl            = kPCA9420_ChgInWatchdogChargerContinue;
605  *   pca9420Config->powerGoodEnable           = kPCA9420_PGoodEnabled;
606  *   pca9420Config->vinCurrentLimit           = kPCA9420_VinIlim_74_85_98;
607  *   pca9420Config->vinOvpThreshold           = kPCA9420_VinOvpSel5V5;
608  *   pca9420Config->vinUvloThreshold          = kPCA9420_VinUvloSel3V1;
609  *   pca9420Config->asysPreWarnThreshold      = kPCA9420_AsysPreWarning3V5;
610  *   pca9420Config->asysInputSource           = kPCA9420_AsysInputSelVbatVin;
611  *   pca9420Config->asysUvloThreshold         = kPCA9420_AsysUvloSel2V7;
612  *   pca9420Config->chargeTermDisable         = kPCA9420_ChargeTermEnabled;
613  *   pca9420Config->thermalShutdownThreshold  = kPCA9420_ThemShdn110C;
614  *   pca9420Config->tempWarnThreshold         = kPCA9420_DieTempWarn85C;
615  *   pca9420Config->onPinTimer                = kPCA9420_OnGltLong8s;
616  *   pca9420Config->disableSw1Bleed           = false;
617  *   pca9420Config->disableSw2Bleed           = false;
618  *   pca9420Config->disableLdo1Bleed          = false;
619  *   pca9420Config->disableLdo2Bleed          = false;
620  *   pca9420Config->slaveAddress              = PCA9420_DEFAULT_I2C_ADDR;
621  *
622  * @param config Pointer to the PCA9420 configuration structure.
623  */
624 void PCA9420_GetDefaultConfig(pca9420_config_t *config);
625 
626 /*!
627  * @brief Initializes a PCA9420 instance.
628  *
629  * This function initializes the PCA9420 regulator with user-defined settings.
630  * This example shows how to set up the pca9420_config_t parameters and how
631  * to call the PCA9420_Init function by passing in these parameters.
632  * @code
633  *   pca9420_config_t pca9420Config;
634  *   PCA9420_GetDefaultConfig(&pca9420Config);
635  *   pca9420Config.I2C_SendFunc    = APP_I2C_SendFunc;
636  *   pca9420Config.I2C_ReceiveFunc = APP_I2C_ReceiveFunc;
637  *   PCA9420_Init(&pca9420Handle, &pca9420Config);
638  * @endcode
639  *
640  * @param handle PCA9420 Handle.
641  * @param config Pointer to the user-defined configuration structure.
642  */
643 void PCA9420_Init(pca9420_handle_t *handle, const pca9420_config_t *config);
644 
645 /*!
646  * @brief Gets the default mode config structure.
647  *
648  * This function initializes the PCA9420 mode config structure to default values. The default
649  * values are as follows.
650  *   pca9420ModeCfg->shipModeEnable     = kPCA9420_ShipModeDisabled;
651  *   pca9420ModeCfg->modeSel            = kPCA9420_ModeSelPin;
652  *   pca9420ModeCfg->onCfg              = kPCA9420_OnCfgDisableModeSwitch;
653  *   pca9420ModeCfg->wdogTimerCfg       = kPCA9420_WdTimerDisabled;
654  *   pca9420ModeCfg->sw1OutVolt         = kPCA9420_Sw1OutVolt1V000;
655  *   pca9420ModeCfg->sw2OutVolt         = kPCA9420_Sw2OutVolt1V800;
656  *   pca9420ModeCfg->ldo1OutVolt        = kPCA9420_Ldo1OutVolt1V800;
657  *   pca9420ModeCfg->ldo2OutVolt        = kPCA9420_Ldo2OutVolt3V300;
658  *   pca9420ModeCfg->enableSw1Out       = true;
659  *   pca9420ModeCfg->enableSw2Out       = true;
660  *   pca9420ModeCfg->enableLdo1Out      = true;
661  *   pca9420ModeCfg->enableLdo2Out      = true;
662  *
663  * @param config Pointer to the PCA9420 mode configuration structure.
664  */
665 void PCA9420_GetDefaultModeConfig(pca9420_modecfg_t *config);
666 
667 /*!
668  * @brief Gets voltage value in mV from mode configuration.
669  *
670  * @param config Pointer to the PCA9420 mode configuration structure.
671  * @param volt Pointer to the PCA9420 regulator voltage structure.
672  */
673 void PCA9420_GetRegulatorVolt(pca9420_modecfg_t *config, pca9420_regulator_mv_t *volt);
674 
675 /*!
676  * @brief Configure PCA9420 modes for specific modes.
677  *
678  * This function configures the PCA9420 modes for specific modes with
679  * user-defined settings.
680  * This example shows how to set up the pca9420_modecfg_t parameters and how
681  * to call the PCA9420_WriteModeConfigs function by passing in these parameters.
682  * @code
683  *   pca9420_modecfg_t pca9420ModeCfg[4];
684  *   uint32_t i;
685  *   for (i = 0; i < ARRAY_SIZE(pca9420ModeCfg); i++)
686  *   {
687  *       PCA9420_GetDefaultModeConfig(&pca9420ModeCfg[i]);
688  *   }
689  *   ...
690  *   PCA9420_WriteModeConfigs(&pca9420Handle, kPCA9420_Mode0, &pca9420ModeCfg[0],
691  * ARRAY_SIZE(pca9420ModeCfg));
692  *   ...
693  *   PCA9420_WriteModeConfigs(&pca9420Handle, kPCA9420_Mode2, &pca9420ModeCfg[2], 1);
694  * @endcode
695  *
696  * @param handle PCA9420 Handle.
697  * @param modeBase Target mode to start with.
698  * @param configs Pointer to the user-defined configuration array.
699  * @param num Number of modes to configure.
700  */
701 void PCA9420_WriteModeConfigs(pca9420_handle_t *handle,
702                               pca9420_mode_t modeBase,
703                               const pca9420_modecfg_t *configs,
704                               uint32_t num);
705 
706 /*!
707  * @brief Read PCA9420 mode configurations for specific modes.
708  *
709  * This function read the PCA9420 mode configurations for specific modes with
710  * user-defined settings.
711  *
712  * @param handle PCA9420 Handle.
713  * @param modeBase Target mode to start with.
714  * @param configs Pointer to the configuration to save read information.
715  * @param num Number of modes to read.
716  */
717 void PCA9420_ReadModeConfigs(pca9420_handle_t *handle,
718                              pca9420_mode_t modeBase,
719                              pca9420_modecfg_t *configs,
720                              uint32_t num);
721 
722 /*!
723  * @brief Switch PCA9420 mode.
724  *
725  * This function switch the PCA9420 regulators mode with I2C interface.
726  *
727  * @param handle PCA9420 Handle.
728  * @param mode Target mode to go into.
729  * @return true on success, false on failure.
730  */
731 bool PCA9420_SwitchMode(pca9420_handle_t *handle, pca9420_mode_t mode);
732 
733 /*!
734  * @brief Get PCA9420 current mode.
735  *
736  * This function returns the PCA9420 current mode with I2C interface.
737  *
738  * @param handle PCA9420 Handle.
739  * @param mode Current mode.
740  * @return true on success, false on failure.
741  */
742 bool PCA9420_GetCurrentMode(pca9420_handle_t *handle, pca9420_mode_t *mode);
743 
744 /*!
745  * @brief Get PCA9420 SW1, SW2, LDO1, LDO2 OK status.
746  *
747  * This function return the PCA9420 regulators status.
748  *
749  * @param handle PCA9420 Handle.
750  * @return ORed regulator status. see @ref pca9420_reg_status_t for regulator status definition.
751  */
752 uint8_t PCA9420_GetRegulatorStatus(pca9420_handle_t *handle);
753 
754 /*!
755  * @brief Feed PCA9420 watchdog.
756  *
757  * This function feed the PCA9420 watch dog.
758  *
759  * @param handle PCA9420 Handle.
760  */
761 void PCA9420_FeedWatchDog(pca9420_handle_t *handle);
762 
763 /* @} */
764 
765 /*!
766  * @name Basic register access functions
767  * @{
768  */
769 
770 /*!
771  * @brief Write the value to register array of PCA9420.
772  *
773  * @param handle Pointer to a valid PCA9420 instance structure.
774  * @param regBase variable store base address of register array.
775  * @param val variable array to be written to PCA9420.
776  * @param size array length in bytes to write.
777  * @return true if success or false if error.
778  */
779 bool PCA9420_WriteRegs(pca9420_handle_t *handle, uint8_t regBase, uint8_t *val, uint32_t size);
780 
781 /*!
782  * @brief Read the value of register array in PCA9420.
783  *
784  * @param handle Pointer to a valid PCA9420 instance structure.
785  * @param regBase variable store address of register array.
786  * @param val variable array to store return value.
787  * @param size array length in bytes to read.
788  * @return true if success or false if error.
789  */
790 bool PCA9420_ReadRegs(pca9420_handle_t *handle, uint8_t regBase, uint8_t *val, uint32_t size);
791 
792 /*!
793  * @brief Modify some bits in the register in PCA9420.
794  * @param handle Pointer to a valid PCA9420 instance structure.
795  * @param reg variable store address of register.
796  * @param mask The mask code for the bits want to write. The bit you want to write should be 1.
797  * @param val Value needs to write into the register.
798  * @return true if success or false if error.
799  */
800 bool PCA9420_ModifyReg(pca9420_handle_t *handle, uint8_t reg, uint8_t mask, uint8_t val);
801 
802 /* @} */
803 
804 /*!
805  * @name Interrupts
806  * @{
807  */
808 
809 /*!
810  * @brief Enables PCA9420 interrupts according to the provided interrupt source mask.
811  *
812  * This function enables the PCA9420 interrupts according to the provided interrupt source.
813  * The interrupt source mask is a logical OR of enumeration members:
814  * see @ref _pca9420_interrupt_source for interrupt sources definition;
815  *
816  * @param handle Pointer to a valid PCA9420 instance structure.
817  * @param source Logic ORed interrupt sources of selected interrupt category to enable.
818  */
819 void PCA9420_EnableInterrupts(pca9420_handle_t *handle, uint32_t source);
820 
821 /*!
822  * @brief Disable PCA9420 interrupts according to the provided interrupt source mask.
823  *
824  * This function disables the PCA9420 interrupts according to the provided interrupt source.
825  * The interrupt source mask is a logical OR of enumeration members:
826  * see @ref _pca9420_interrupt_source for interrupt sources definition;
827  *
828  * @param handle Pointer to a valid PCA9420 instance structure.
829  * @param source Logic ORed interrupt sources of selected interrupt category to disable.
830  */
831 void PCA9420_DisableInterrupts(pca9420_handle_t *handle, uint32_t source);
832 
833 /*!
834  * @brief Get interrupt flags.
835  *
836  * This function gets all interrupt flags.
837  * The flags are returned as the logical OR value of the corresponding interrupt source:
838  * see @ref _pca9420_interrupt_source for interrupt sources definition;
839  *
840  * @param handle Pointer to a valid PCA9420 instance structure.
841  * @return status flags which are ORed by the enumerators in the corresponding interrupt source.
842  */
843 uint32_t PCA9420_GetInterruptStatus(pca9420_handle_t *handle);
844 
845 /*!
846  * @brief Clear interrupt flags.
847  *
848  * This function clears interrupt flags of selected source.
849  * The interrupt source mask is a logical OR of enumeration members:
850  * see @ref _pca9420_interrupt_source for interrupt sources definition;
851  *
852  * @param handle Pointer to a valid PCA9420 instance structure.
853  * @param source Logic ORed interrupt sources of selected interrupt source to clear.
854  */
855 void PCA9420_ClearInterruptStatus(pca9420_handle_t *handle, uint32_t source);
856 /* @} */
857 
858 /*!
859  * @name mode control functions
860  * @{
861  */
862 
863 /* @} */
864 
865 #if defined(__cplusplus)
866 }
867 #endif
868 
869 /*! @} */
870 
871 #endif /* _FSL_PCA9420_H_ */
872 
873 /*******************************************************************************
874  * EOF
875  ******************************************************************************/
876