Skip to content

Commit 49e8fae

Browse files
committed
added support for new pmic
1 parent 5ae2f68 commit 49e8fae

File tree

6 files changed

+769
-41
lines changed

6 files changed

+769
-41
lines changed

Diff for: boards.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ mkrwifi1010.build.usb_product="Arduino MKR WiFi 1010"
208208
mkrwifi1010.build.usb_manufacturer="Arduino LLC"
209209
mkrwifi1010.build.board=SAMD_MKRWIFI1010
210210
mkrwifi1010.build.core=arduino
211-
mkrwifi1010.build.extra_flags=-DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ {build.usb_flags} -DUSE_BQ24195L_PMIC
211+
mkrwifi1010.build.extra_flags=-DUSE_ARDUINO_MKR_PIN_LAYOUT -D__SAMD21G18A__ {build.usb_flags} -DUSE_BQ24195L_PMIC -DUSE_MP2629_PMIC
212212
mkrwifi1010.build.ldscript=linker_scripts/gcc/flash_with_bootloader.ld
213213
mkrwifi1010.build.openocdscript=openocd_scripts/arduino_zero.cfg
214214
mkrwifi1010.build.variant=mkrwifi1010

Diff for: cores/arduino/PMIC/BQ24195.h

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*
2+
BQ24195.h - Register definitions for BQ24195/BQ24195L PMICs.
3+
Copyright (c) 2020 Kevin P. Fleming. All right reserved.
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
This library is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
See the GNU Lesser General Public License for more details.
12+
You should have received a copy of the GNU Lesser General Public
13+
License along with this library; if not, write to the Free Software
14+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
15+
*/
16+
17+
#pragma once
18+
19+
#include <stdint.h>
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif
24+
25+
typedef union {
26+
struct {
27+
uint8_t IINLIM:3;
28+
uint8_t VINDPM:4;
29+
uint8_t EN_HIZ:1;
30+
};
31+
uint8_t val;
32+
} BQ24195_REG00;
33+
34+
static_assert(sizeof(BQ24195_REG00) == 1, "BQ24195_REG00 union size is incorrect, should be 1 byte.");
35+
36+
typedef union {
37+
struct {
38+
uint8_t RSVD:1;
39+
uint8_t SYS_MIN:3;
40+
uint8_t CHG_CONFIG_ENABLE:1;
41+
uint8_t CHG_CONFIG_OTG:1;
42+
uint8_t WATCHDOG_TIMER_RESET:1;
43+
uint8_t REGISTER_RESET:1;
44+
};
45+
uint8_t val;
46+
} BQ24195_REG01;
47+
48+
static_assert(sizeof(BQ24195_REG01) == 1, "BQ24195_REG01 union size is incorrect, should be 1 byte.");
49+
50+
typedef union {
51+
struct {
52+
uint8_t FORCE_20PCT:1;
53+
uint8_t RSVD:1;
54+
uint8_t ICHG:6;
55+
};
56+
uint8_t val;
57+
} BQ24195_REG02;
58+
59+
static_assert(sizeof(BQ24195_REG02) == 1, "BQ24195_REG02 union size is incorrect, should be 1 byte.");
60+
61+
typedef union {
62+
struct {
63+
uint8_t ITERM:4;
64+
uint8_t IPRECHG:4;
65+
};
66+
uint8_t val;
67+
} BQ24195_REG03;
68+
69+
static_assert(sizeof(BQ24195_REG03) == 1, "BQ24195_REG03 union size is incorrect, should be 1 byte.");
70+
71+
typedef union {
72+
struct {
73+
uint8_t VRECHG:1;
74+
uint8_t BATLOWV:1;
75+
uint8_t VREG:6;
76+
};
77+
uint8_t val;
78+
} BQ24195_REG04;
79+
80+
static_assert(sizeof(BQ24195_REG04) == 1, "BQ24195_REG04 union size is incorrect, should be 1 byte.");
81+
82+
typedef union {
83+
struct {
84+
uint8_t RSVD:1;
85+
uint8_t CHG_TIMER:2;
86+
uint8_t EN_TIMER:1;
87+
uint8_t WATCHDOG:2;
88+
uint8_t TERM_STAT:1;
89+
uint8_t EN_TERM:1;
90+
};
91+
uint8_t val;
92+
} BQ24195_REG05;
93+
94+
static_assert(sizeof(BQ24195_REG05) == 1, "BQ24195_REG05 union size is incorrect, should be 1 byte.");
95+
96+
typedef union {
97+
struct {
98+
uint8_t VRECHG:1;
99+
uint8_t BATLOWV:1;
100+
uint8_t VREG:6;
101+
};
102+
uint8_t val;
103+
} BQ24195_REG06;
104+
105+
static_assert(sizeof(BQ24195_REG06) == 1, "BQ24195_REG06 union size is incorrect, should be 1 byte.");
106+
107+
typedef union {
108+
struct {
109+
uint8_t INT_MASK_BAT:1;
110+
uint8_t INT_MASK_CHG:1;
111+
uint8_t RSVD:3;
112+
uint8_t BATFET_DISABLE:1;
113+
uint8_t TMR2X_EN:1;
114+
uint8_t DPDM_EN:1;
115+
};
116+
uint8_t val;
117+
} BQ24195_REG07;
118+
119+
static_assert(sizeof(BQ24195_REG07) == 1, "BQ24195_REG07 union size is incorrect, should be 1 byte.");
120+
121+
typedef union {
122+
struct {
123+
uint8_t VSYS_STAT:1;
124+
uint8_t THERM_STAT:1;
125+
uint8_t PG_STAT:1;
126+
uint8_t DPM_STAT:1;
127+
uint8_t CHRG_STAT:2;
128+
uint8_t VBUS_STAT:2;
129+
};
130+
uint8_t val;
131+
} BQ24195_REG08;
132+
133+
static_assert(sizeof(BQ24195_REG08) == 1, "BQ24195_REG08 union size is incorrect, should be 1 byte.");
134+
135+
typedef union {
136+
struct {
137+
uint8_t NTC_FAULT:3;
138+
uint8_t BAT_FAULT:1;
139+
uint8_t CHRG_FAULT:2;
140+
uint8_t RSVD:1;
141+
uint8_t WATCHDOG_FAULT:1;
142+
};
143+
uint8_t val;
144+
} BQ24195_REG09;
145+
146+
static_assert(sizeof(BQ24195_REG09) == 1, "BQ24195_REG09 union size is incorrect, should be 1 byte.");
147+
148+
typedef union {
149+
struct {
150+
uint8_t DEV_REG:2;
151+
uint8_t TS_PROFILE:1;
152+
uint8_t PN:3;
153+
uint8_t RSVD:2;
154+
};
155+
uint8_t val;
156+
} BQ24195_REG0A;
157+
158+
static_assert(sizeof(BQ24195_REG0A) == 1, "BQ24195_REG0A union size is incorrect, should be 1 byte.");
159+
160+
#define BQ24195_ADDRESS 0x6B
161+
#define BQ24195_REG00_ADDRESS 0x00
162+
#define BQ24195_REG01_ADDRESS 0x01
163+
#define BQ24195_REG02_ADDRESS 0x02
164+
#define BQ24195_REG03_ADDRESS 0x03
165+
#define BQ24195_REG04_ADDRESS 0x04
166+
#define BQ24195_REG05_ADDRESS 0x05
167+
#define BQ24195_REG06_ADDRESS 0x06
168+
#define BQ24195_REG07_ADDRESS 0x07
169+
#define BQ24195_REG08_ADDRESS 0x08
170+
#define BQ24195_REG09_ADDRESS 0x09
171+
#define BQ24195_REG0A_ADDRESS 0x0A
172+
173+
#ifdef __cplusplus
174+
} // extern "C"
175+
#endif

0 commit comments

Comments
 (0)