Skip to content

Commit 628ee7d

Browse files
facchinmcmaglie
authored andcommitted
Fix PMIC behaviour by borrowing Electron library
PMIC initialization is now handled by the GSM init() if the selected board is suitable. The only hadcoded PMIC initialization is 500mA maximum charge current.
1 parent e944484 commit 628ee7d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

variants/mkrgsm1400/variant.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "variant.h"
20+
#include "Arduino.h"
2021

2122
const PinDescription g_APinDescription[] = {
2223

@@ -172,6 +173,12 @@ SERCOM sercom5(SERCOM5);
172173

173174
#define PMIC_ADDRESS 0x6B
174175
#define PMIC_REG02 0x02
176+
#define PMIC_REG00 0x00
177+
#define INPUT_CURRENT_LIMIT_0A1 (0x0)
178+
#define INPUT_CURRENT_LIMIT_0A9 (0x3)
179+
#define INPUT_CURRENT_LIMIT_1A5 (0x5)
180+
#define VOLTAGE_LIMIT_4V36 (0x6 << 3)
181+
#define VOLTAGE_LIMIT_4V04 (0x2 << 3)
175182

176183
static inline void set_pmic_safe_defaults() {
177184
PERIPH_WIRE.initMasterWIRE(100000);
@@ -183,15 +190,20 @@ static inline void set_pmic_safe_defaults() {
183190
PERIPH_WIRE.sendDataMasterWIRE(PMIC_REG02);
184191
PERIPH_WIRE.sendDataMasterWIRE(0);
185192
PERIPH_WIRE.prepareCommandBitsWire(WIRE_MASTER_ACT_STOP);
193+
186194
PERIPH_WIRE.disableWIRE();
187195
}
188196

197+
#else
198+
199+
static inline void set_pmic_safe_defaults() {}
200+
201+
#endif
202+
189203
void initVariant() {
190204
set_pmic_safe_defaults();
191205
}
192206

193-
#endif
194-
195207
// Serial1
196208
Uart Serial1(&sercom5, PIN_SERIAL1_RX, PIN_SERIAL1_TX, PAD_SERIAL1_RX, PAD_SERIAL1_TX);
197209

0 commit comments

Comments
 (0)