pmic  2.1.0.0
pmic.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef PMIC_H
29 #define PMIC_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 #include "drv_i2c_master.h"
52 
73 #define PMIC_REG_MAIN_TASKSWRESET 0x0001
74 #define PMIC_REG_MAIN_EVENTSADCSET 0x0002
75 #define PMIC_REG_MAIN_EVENTSADCCLR 0x0003
76 #define PMIC_REG_MAIN_INTENEVENTSADCSET 0x0004
77 #define PMIC_REG_MAIN_INTENEVENTSADCCLR 0x0005
78 #define PMIC_REG_MAIN_EVENTSBCHARGER0SET 0x0006
79 #define PMIC_REG_MAIN_EVENTSBCHARGER0CLR 0x0007
80 #define PMIC_REG_MAIN_INTENEVENTSBCHARGER0SET 0x0008
81 #define PMIC_REG_MAIN_INTENEVENTSBCHARGER0CLR 0x0009
82 #define PMIC_REG_MAIN_EVENTSBCHARGER1SET 0x000A
83 #define PMIC_REG_MAIN_EVENTSBCHARGER1CLR 0x000B
84 #define PMIC_REG_MAIN_INTENEVENTSBCHARGER1SET 0x000C
85 #define PMIC_REG_MAIN_INTENEVENTSBCHARGER1CLR 0x000D
86 #define PMIC_REG_MAIN_EVENTSBCHARGER2SET 0x000E
87 #define PMIC_REG_MAIN_EVENTSBCHARGER2CLR 0x000F
88 #define PMIC_REG_MAIN_INTENEVENTSBCHARGER2SET 0x0010
89 #define PMIC_REG_MAIN_INTENEVENTSBCHARGER2CLR 0x0011
90 #define PMIC_REG_MAIN_EVENTSSHPHLDSET 0x0012
91 #define PMIC_REG_MAIN_EVENTSSHPHLDCLR 0x0013
92 #define PMIC_REG_MAIN_INTENEVENTSSHPHLDSET 0x0014
93 #define PMIC_REG_MAIN_INTENEVENTSSHPHLDCLR 0x0015
94 #define PMIC_REG_MAIN_EVENTSVBUSIN0SET 0x0016
95 #define PMIC_REG_MAIN_EVENTSVBUSIN0CLR 0x0017
96 #define PMIC_REG_MAIN_INTENEVENTSVBUSIN0SET 0x0018
97 #define PMIC_REG_MAIN_INTENEVENTSVBUSIN0CLR 0x0019
98 #define PMIC_REG_MAIN_EVENTSVBUSIN1SET 0x001A
99 #define PMIC_REG_MAIN_EVENTSVBUSIN1CLR 0x001B
100 #define PMIC_REG_MAIN_INTENEVENTSVBUSIN1SET 0x001C
101 #define PMIC_REG_MAIN_INTENEVENTSVBUSIN1CLR 0x001D
102 #define PMIC_REG_MAIN_EVENTSGPIOSET 0x0022
103 #define PMIC_REG_MAIN_EVENTSGPIOCLR 0x0023
104 #define PMIC_REG_MAIN_INTENEVENTSGPIOSET 0x0024
105 #define PMIC_REG_MAIN_INTENEVENTSGPIOCLR 0x0025
106 
111 #define PMIC_REG_VBUSIN_TASKUPDATEILIMSW 0x0200
112 #define PMIC_REG_VBUSIN_VBUSINILIM0 0x0201
113 #define PMIC_REG_VBUSIN_VBUSSUSPEND 0x0203
114 #define PMIC_REG_VBUSIN_USBCDETECTSTATUS 0x0205
115 #define PMIC_REG_VBUSIN_VBUSINSTATUS 0x0207
116 
121 #define PMIC_REG_BCHARGER_TASKRELEASEERR 0x0300
122 #define PMIC_REG_BCHARGER_TASKCLEARCHGERR 0x0301
123 #define PMIC_REG_BCHARGER_TASKCLEARSAFETYTIMER 0x0302
124 #define PMIC_REG_BCHARGER_BCHGENABLESET 0x0304
125 #define PMIC_REG_BCHARGER_BCHGENABLECLR 0x0305
126 #define PMIC_REG_BCHARGER_BCHGDISABLESET 0x0306
127 #define PMIC_REG_BCHARGER_BCHGDISABLECLR 0x0307
128 #define PMIC_REG_BCHARGER_BCHGISETMSB 0x0308
129 #define PMIC_REG_BCHARGER_BCHGISETLSB 0x0309
130 #define PMIC_REG_BCHARGER_BCHGISETDISCHARGEMSB 0x030A
131 #define PMIC_REG_BCHARGER_BCHGISETDISCHARGELSB 0x030B
132 #define PMIC_REG_BCHARGER_BCHGVTERM 0x030C
133 #define PMIC_REG_BCHARGER_BCHGVTERMR 0x030D
134 #define PMIC_REG_BCHARGER_BCHGVTRICKLESEL 0x030E
135 #define PMIC_REG_BCHARGER_BCHGITERMSEL 0x030F
136 #define PMIC_REG_BCHARGER_NTCCOLD 0x0310
137 #define PMIC_REG_BCHARGER_NTCCOLDLSB 0x0311
138 #define PMIC_REG_BCHARGER_NTCCOOL 0x0312
139 #define PMIC_REG_BCHARGER_NTCCOOLLSB 0x0313
140 #define PMIC_REG_BCHARGER_NTCWARM 0x0314
141 #define PMIC_REG_BCHARGER_NTCWARMLSB 0x0315
142 #define PMIC_REG_BCHARGER_NTCHOT 0x0316
143 #define PMIC_REG_BCHARGER_NTCHOTLSB 0x0317
144 #define PMIC_REG_BCHARGER_DIETEMPSTOP 0x0318
145 #define PMIC_REG_BCHARGER_DIETEMPSTOPLSB 0x0319
146 #define PMIC_REG_BCHARGER_DIETEMPRESUME 0x031A
147 #define PMIC_REG_BCHARGER_DIETEMPRESUMELSB 0x031B
148 #define PMIC_REG_BCHARGER_BCHGILIMSTATUS 0x032D
149 #define PMIC_REG_BCHARGER_NTCSTATUS 0x0332
150 #define PMIC_REG_BCHARGER_DIETEMPSTATUS 0x0333
151 #define PMIC_REG_BCHARGER_BCHGCHARGESTATUS 0x0334
152 #define PMIC_REG_BCHARGER_BCHGERRREASON 0x0336
153 #define PMIC_REG_BCHARGER_BCHGERRSENSOR 0x0337
154 #define PMIC_REG_BCHARGER_BCHGCONFIG 0x033C
155 
160 #define PMIC_REG_BUCK_BUCK1ENASET 0x0400
161 #define PMIC_REG_BUCK_BUCK1ENACLR 0x0401
162 #define PMIC_REG_BUCK_BUCK2ENASET 0x0402
163 #define PMIC_REG_BUCK_BUCK2ENACLR 0x0403
164 #define PMIC_REG_BUCK_BUCK1PWMSET 0x0404
165 #define PMIC_REG_BUCK_BUCK1PWMCLR 0x0405
166 #define PMIC_REG_BUCK_BUCK2PWMSET 0x0406
167 #define PMIC_REG_BUCK_BUCK2PWMCLR 0x0407
168 #define PMIC_REG_BUCK_BUCK1NORMVOUT 0x0408
169 #define PMIC_REG_BUCK_BUCK1RETVOUT 0x0409
170 #define PMIC_REG_BUCK_BUCK2NORMVOUT 0x040A
171 #define PMIC_REG_BUCK_BUCK2RETVOUT 0x040B
172 #define PMIC_REG_BUCK_BUCKENCTRL 0x040C
173 #define PMIC_REG_BUCK_BUCKVRETCTRL 0x040D
174 #define PMIC_REG_BUCK_BUCKPWMCTRL 0x040E
175 #define PMIC_REG_BUCK_BUCKSWCTRLSEL 0x040F
176 #define PMIC_REG_BUCK_BUCK1VOUTSTATUS 0x0410
177 #define PMIC_REG_BUCK_BUCK2VOUTSTATUS 0x0411
178 #define PMIC_REG_BUCK_BUCKCTRL0 0x0415
179 #define PMIC_REG_BUCK_BUCKSTATUS 0x0434
180 
185 #define PMIC_REG_ADC_TASKVBATMEASURE 0x0500
186 #define PMIC_REG_ADC_TASKNTCMEASURE 0x0501
187 #define PMIC_REG_ADC_TASKTEMPMEASURE 0x0502
188 #define PMIC_REG_ADC_TASKVSYSMEASURE 0x0503
189 #define PMIC_REG_ADC_TASKIBATMEASURE 0x0506
190 #define PMIC_REG_ADC_TASKVBUS7MEASURE 0x0507
191 #define PMIC_REG_ADC_TASKDELAYEDVBATMEASURE 0x0508
192 #define PMIC_REG_ADC_ADCCONFIG 0x0509
193 #define PMIC_REG_ADC_ADCNTCRSEL 0x050A
194 #define PMIC_REG_ADC_ADCAUTOTIMCONF 0x050B
195 #define PMIC_REG_ADC_TASKAUTOTIMUPDATE 0x050C
196 #define PMIC_REG_ADC_ADCDELTIMCONF 0x050D
197 #define PMIC_REG_ADC_ADCIBATMEASSTATUS 0x0510
198 #define PMIC_REG_ADC_ADCVBATRESULTMSB 0x0511
199 #define PMIC_REG_ADC_ADCNTCRESULTMSB 0x0512
200 #define PMIC_REG_ADC_ADCTEMPRESULTMSB 0x0513
201 #define PMIC_REG_ADC_ADCVSYSRESULTMSB 0x0514
202 #define PMIC_REG_ADC_ADCGP0RESULTLSBS 0x0515
203 #define PMIC_REG_ADC_ADCVBAT0RESULTMSB 0x0516
204 #define PMIC_REG_ADC_ADCVBAT1RESULTMSB 0x0517
205 #define PMIC_REG_ADC_ADCVBAT2RESULTMSB 0x0518
206 #define PMIC_REG_ADC_ADCVBAT3RESULTMSB 0x0519
207 #define PMIC_REG_ADC_ADCGP1RESULTLSBS 0x051A
208 #define PMIC_REG_ADC_ADCIBATMEASEN 0x0524
209 
214 #define PMIC_REG_GPIOS_GPIOMODE_0 0x0600
215 #define PMIC_REG_GPIOS_GPIOMODE_1 0x0601
216 #define PMIC_REG_GPIOS_GPIOMODE_2 0x0602
217 #define PMIC_REG_GPIOS_GPIOMODE_3 0x0603
218 #define PMIC_REG_GPIOS_GPIOMODE_4 0x0604
219 #define PMIC_REG_GPIOS_GPIODRIVE_0 0x0605
220 #define PMIC_REG_GPIOS_GPIODRIVE_1 0x0606
221 #define PMIC_REG_GPIOS_GPIODRIVE_2 0x0607
222 #define PMIC_REG_GPIOS_GPIODRIVE_3 0x0608
223 #define PMIC_REG_GPIOS_GPIODRIVE_4 0x0609
224 #define PMIC_REG_GPIOS_GPIOPUEN_0 0x060A
225 #define PMIC_REG_GPIOS_GPIOPUEN_1 0x060B
226 #define PMIC_REG_GPIOS_GPIOPUEN_2 0x060C
227 #define PMIC_REG_GPIOS_GPIOPUEN_3 0x060D
228 #define PMIC_REG_GPIOS_GPIOPUEN_4 0x060E
229 #define PMIC_REG_GPIOS_GPIOPDEN_0 0x060F
230 #define PMIC_REG_GPIOS_GPIOPDEN_1 0x0610
231 #define PMIC_REG_GPIOS_GPIOPDEN_2 0x0611
232 #define PMIC_REG_GPIOS_GPIOPDEN_3 0x0612
233 #define PMIC_REG_GPIOS_GPIOPDEN_4 0x0613
234 #define PMIC_REG_GPIOS_GPIOOPENDRAIN_0 0x0614
235 #define PMIC_REG_GPIOS_GPIOOPENDRAIN_1 0x0615
236 #define PMIC_REG_GPIOS_GPIOOPENDRAIN_2 0x0616
237 #define PMIC_REG_GPIOS_GPIOOPENDRAIN_3 0x0617
238 #define PMIC_REG_GPIOS_GPIOOPENDRAIN_4 0x0618
239 #define PMIC_REG_GPIOS_GPIODEBOUNCE_0 0x0619
240 #define PMIC_REG_GPIOS_GPIODEBOUNCE_1 0x061A
241 #define PMIC_REG_GPIOS_GPIODEBOUNCE_2 0x061B
242 #define PMIC_REG_GPIOS_GPIODEBOUNCE_3 0x061C
243 #define PMIC_REG_GPIOS_GPIODEBOUNCE_4 0x061D
244 #define PMIC_REG_GPIOS_GPIOSTATUS 0x061E
245 
250 #define PMIC_REG_TIMER_TIMERSET 0x0700
251 #define PMIC_REG_TIMER_TIMERCLR 0x0701
252 #define PMIC_REG_TIMER_TIMERTARGETSTROBE 0x0703
253 #define PMIC_REG_TIMER_WATCHDOGKICK 0x0704
254 #define PMIC_REG_TIMER_TIMERCONFIG 0x0705
255 #define PMIC_REG_TIMER_TIMERSTATUS 0x0706
256 #define PMIC_REG_TIMER_TIMERHIBYTE 0x0708
257 #define PMIC_REG_TIMER_TIMERMIDBYTE 0x0709
258 #define PMIC_REG_TIMER_TIMERLOBYTE 0x070A
259 
264 #define PMIC_REG_LDSW_TASKLDSW1SET 0x0800
265 #define PMIC_REG_LDSW_TASKLDSW1CLR 0x0801
266 #define PMIC_REG_LDSW_TASKLDSW2SET 0x0802
267 #define PMIC_REG_LDSW_TASKLDSW2CLR 0x0803
268 #define PMIC_REG_LDSW_LDSWSTATUS 0x0804
269 #define PMIC_REG_LDSW_LDSW1GPISEL 0x0805
270 #define PMIC_REG_LDSW_LDSW2GPISEL 0x0806
271 #define PMIC_REG_LDSW_LDSWCONFIG 0x0807
272 #define PMIC_REG_LDSW_LDSW1LDOSEL 0x0808
273 #define PMIC_REG_LDSW_LDSW2LDOSEL 0x0809
274 #define PMIC_REG_LDSW_LDSW1VOUTSEL 0x080C
275 #define PMIC_REG_LDSW_LDSW2VOUTSEL 0x080D
276 
281 #define PMIC_REG_POF_POFCONFIG 0x0900
282 
287 #define PMIC_REG_LEDDRV_LEDDRV0MODESEL 0x0A00
288 #define PMIC_REG_LEDDRV_LEDDRV1MODESEL 0x0A01
289 #define PMIC_REG_LEDDRV_LEDDRV2MODESEL 0x0A02
290 #define PMIC_REG_LEDDRV_LEDDRV0SET 0x0A03
291 #define PMIC_REG_LEDDRV_LEDDRV0CLR 0x0A04
292 #define PMIC_REG_LEDDRV_LEDDRV1SET 0x0A05
293 #define PMIC_REG_LEDDRV_LEDDRV1CLR 0x0A06
294 #define PMIC_REG_LEDDRV_LEDDRV2SET 0x0A07
295 #define PMIC_REG_LEDDRV_LEDDRV2CLR 0x0A08
296 
301 #define PMIC_REG_SHIP_TASKENTERHIBERNATE 0x0B00
302 #define PMIC_REG_SHIP_TASKSHPHLDCFGSTROBE 0x0B01
303 #define PMIC_REG_SHIP_TASKENTERSHIPMODE 0x0B02
304 #define PMIC_REG_SHIP_TASKRESETCFG 0x0B03
305 #define PMIC_REG_SHIP_SHPHLDCONFIG 0x0B04
306 #define PMIC_REG_SHIP_SHPHLDSTATUS 0x0B05
307 #define PMIC_REG_SHIP_LPRESETCONFIG 0x0B06
308 
313 #define PMIC_REG_ERRLOG_TASKCLRERRLOG 0x0E00
314 #define PMIC_REG_ERRLOG_SCRATCH0 0x0E01
315 #define PMIC_REG_ERRLOG_SCRATCH1 0x0E02
316 #define PMIC_REG_ERRLOG_RSTCAUSE 0x0E03
317 #define PMIC_REG_ERRLOG_CHARGERERRREASON 0x0E04
318 #define PMIC_REG_ERRLOG_CHARGERERRSENSOR 0x0E05
319  // pmic_reg
321 
336 #define PMIC_GPIO_MODE_GPIINPUT 0x00
337 #define PMIC_GPIO_MODE_GPILOGIC1 0x01
338 #define PMIC_GPIO_MODE_GPILOGIC0 0x02
339 #define PMIC_GPIO_MODE_GPIEVENTRISE 0x03
340 #define PMIC_GPIO_MODE_GPIEVENTFALL 0x04
341 #define PMIC_GPIO_MODE_GPOIRQ 0x05
342 #define PMIC_GPIO_MODE_GPORESET 0x06
343 #define PMIC_GPIO_MODE_GPOPLW 0x07
344 #define PMIC_GPIO_MODE_GPOLOGIC1 0x08
345 #define PMIC_GPIO_MODE_GPOLOGIC0 0x09
346 
351 #define PMIC_BCHGDISABLESET_DISABLERCHG 0x01
352 #define PMIC_BCHGDISABLESET_IGNORENTC 0x02
353 
358 #define PMIC_BCHGDISABLECLR_ENABLERCHG 0x01
359 #define PMIC_BCHGDISABLECLR_USENTC 0x02
360 
365 #define PMIC_BCHGENABLESET_ENABLECHG 0x01
366 #define PMIC_BCHGENABLESET_ENABLECOOL 0x02
367 
372 #define PMIC_BCHGENABLECLR_DISABLECHG 0x01
373 #define PMIC_BCHGENABLECLR_DISABLECOOL 0x02
374 
379 #define PMIC_ADCCONFIG_AUTOENABLE 0x01
380 #define PMIC_ADCCONFIG_BURSTMODE 0x02
381 
386 #define PMIC_BCHGVTERMNORM_3V50 0x00
387 #define PMIC_BCHGVTERMNORM_3V55 0x01
388 #define PMIC_BCHGVTERMNORM_3V60 0x02
389 #define PMIC_BCHGVTERMNORM_3V65 0x03
390 #define PMIC_BCHGVTERMNORM_4V00 0x04
391 #define PMIC_BCHGVTERMNORM_4V05 0x05
392 #define PMIC_BCHGVTERMNORM_4V10 0x06
393 #define PMIC_BCHGVTERMNORM_4V15 0x07
394 #define PMIC_BCHGVTERMNORM_4V20 0x08
395 #define PMIC_BCHGVTERMNORM_4V25 0x09
396 #define PMIC_BCHGVTERMNORM_4V30 0x0A
397 #define PMIC_BCHGVTERMNORM_4V35 0x0B
398 #define PMIC_BCHGVTERMNORM_4V40 0x0C
399 #define PMIC_BCHGVTERMNORM_4V45 0x0D
400 
405 #define PMIC_CHARGING_CURRENT_MIN 32
406 #define PMIC_CHARGING_CURRENT_DEFAULT 200
407 #define PMIC_CHARGING_CURRENT_MAX 800
408 
413 #define PMIC_TRIGGER_MEASUREMENT 0x01
414 #define PMIC_VBAT_FULL_SCALE_MILLIVOLTS 5000.0f
415 #define PMIC_VBAT_DATA_RESOLUTION 0x03FF
416 #define PMIC_VSYS_FULL_SCALE_MILLIVOLTS 6375.0f
417 #define PMIC_VSYS_DATA_RESOLUTION 0x03FF
418 #define PMIC_VBUS_FULL_SCALE_MILLIVOLTS 7500.0f
419 #define PMIC_VBUS_DATA_RESOLUTION 0x03FF
420 
425 #define PMIC_CHARGE_STATUS_BATTERYDETECTED 0x01
426 #define PMIC_CHARGE_STATUS_COMPLETED 0x02
427 #define PMIC_CHARGE_STATUS_TRICKLECHARGE 0x04
428 #define PMIC_CHARGE_STATUS_CONSTANTCURRENT 0x08
429 #define PMIC_CHARGE_STATUS_CONSTANTVOLTAGE 0x10
430 #define PMIC_CHARGE_STATUS_RECHARGE 0x20
431 #define PMIC_CHARGE_STATUS_DIETEMPHIGHCHGPAUSED 0x40
432 #define PMIC_CHARGE_STATUS_SUPPLEMENTACTIVE 0x80
433 
438 #define PMIC_EVENTADCVBATRDY 0x01
439 #define PMIC_EVENTADCNTCRDY 0x02
440 #define PMIC_EVENTADCTEMPRDY 0x04
441 #define PMIC_EVENTADCVSYSRDY 0x08
442 #define PMIC_EVENTADCVSET1RDY 0x10
443 #define PMIC_EVENTADCVSET2RDY 0x20
444 #define PMIC_EVENTADCIBATRDY 0x40
445 #define PMIC_EVENTADCVBUS7V0RDY 0x80
446 #define PMIC_EVENTS_ALL_FLAGS 0xFF
447 #define PMIC_WAIT_EVENT_TIMEOUT_MS 2000
448 
454 #define PMIC_DEVICE_ADDRESS 0x6B
455  // pmic_set
457 
472 #define PMIC_MAP_MIKROBUS( cfg, mikrobus ) \
473  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
474  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
475  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
476  // pmic_map // pmic
479 
484 typedef struct
485 {
486  // Input pins
487  digital_in_t int_pin;
489  // Modules
490  i2c_master_t i2c;
492  // I2C slave address
493  uint8_t slave_address;
495 } pmic_t;
496 
501 typedef struct
502 {
503  pin_name_t scl;
504  pin_name_t sda;
506  pin_name_t int_pin;
508  uint32_t i2c_speed;
509  uint8_t i2c_address;
511 } pmic_cfg_t;
512 
517 typedef enum
518 {
519  PMIC_OK = 0,
520  PMIC_ERROR = -1
521 
523 
540 
554 err_t pmic_init ( pmic_t *ctx, pmic_cfg_t *cfg );
555 
568 err_t pmic_default_cfg ( pmic_t *ctx );
569 
584 err_t pmic_reg_write ( pmic_t *ctx, uint16_t reg, uint8_t *data_in, uint8_t len );
585 
600 err_t pmic_reg_read ( pmic_t *ctx, uint16_t reg, uint8_t *data_out, uint8_t len );
601 
614 err_t pmic_reg_write_byte ( pmic_t *ctx, uint16_t reg, uint8_t data_in );
615 
628 err_t pmic_reg_read_byte ( pmic_t *ctx, uint16_t reg, uint8_t *data_out );
629 
638 uint8_t pmic_get_int_pin ( pmic_t *ctx );
639 
652 err_t pmic_wait_for_event ( pmic_t *ctx, uint16_t evt_set_reg, uint8_t bit_mask );
653 
665 err_t pmic_get_vbat ( pmic_t *ctx, uint16_t *vbat );
666 
678 err_t pmic_get_vbus ( pmic_t *ctx, uint16_t *vbus );
679 
691 err_t pmic_get_vsys ( pmic_t *ctx, uint16_t *vsys );
692 
704 err_t pmic_set_charging_current ( pmic_t *ctx, uint16_t current );
705 
706 #ifdef __cplusplus
707 }
708 #endif
709 #endif // PMIC_H
710  // pmic
712 
713 // ------------------------------------------------------------------------ END
pmic_get_vbus
err_t pmic_get_vbus(pmic_t *ctx, uint16_t *vbus)
PMIC get vbus function.
pmic_cfg_t::int_pin
pin_name_t int_pin
Definition: pmic.h:506
pmic_cfg_t
PMIC Click configuration object.
Definition: pmic.h:502
pmic_set_charging_current
err_t pmic_set_charging_current(pmic_t *ctx, uint16_t current)
PMIC set charging current function.
pmic_return_value_t
pmic_return_value_t
PMIC Click return value data.
Definition: pmic.h:518
pmic_reg_write_byte
err_t pmic_reg_write_byte(pmic_t *ctx, uint16_t reg, uint8_t data_in)
PMIC reg write byte function.
pmic_reg_read
err_t pmic_reg_read(pmic_t *ctx, uint16_t reg, uint8_t *data_out, uint8_t len)
PMIC reg read function.
pmic_get_int_pin
uint8_t pmic_get_int_pin(pmic_t *ctx)
PMIC get int pin function.
pmic_wait_for_event
err_t pmic_wait_for_event(pmic_t *ctx, uint16_t evt_set_reg, uint8_t bit_mask)
PMIC wait for event function.
PMIC_OK
@ PMIC_OK
Definition: pmic.h:519
pmic_get_vsys
err_t pmic_get_vsys(pmic_t *ctx, uint16_t *vsys)
PMIC get vsys function.
pmic_reg_read_byte
err_t pmic_reg_read_byte(pmic_t *ctx, uint16_t reg, uint8_t *data_out)
PMIC reg read byte function.
pmic_reg_write
err_t pmic_reg_write(pmic_t *ctx, uint16_t reg, uint8_t *data_in, uint8_t len)
PMIC reg write function.
PMIC_ERROR
@ PMIC_ERROR
Definition: pmic.h:520
pmic_t::int_pin
digital_in_t int_pin
Definition: pmic.h:487
pmic_default_cfg
err_t pmic_default_cfg(pmic_t *ctx)
PMIC default configuration function.
pmic_init
err_t pmic_init(pmic_t *ctx, pmic_cfg_t *cfg)
PMIC initialization function.
pmic_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: pmic.h:508
pmic_get_vbat
err_t pmic_get_vbat(pmic_t *ctx, uint16_t *vbat)
PMIC get vbat function.
pmic_cfg_setup
void pmic_cfg_setup(pmic_cfg_t *cfg)
PMIC configuration object setup function.
pmic_t
PMIC Click context object.
Definition: pmic.h:485
pmic_cfg_t::sda
pin_name_t sda
Definition: pmic.h:504
pmic_t::slave_address
uint8_t slave_address
Definition: pmic.h:493
pmic_cfg_t::scl
pin_name_t scl
Definition: pmic.h:503
pmic_t::i2c
i2c_master_t i2c
Definition: pmic.h:490
pmic_cfg_t::i2c_address
uint8_t i2c_address
Definition: pmic.h:509