Skip to content

Commit 203dfcc

Browse files
facchinmcmaglie
authored andcommitted
Rewrite PMIC initialization using Sercom (no error checking)
1 parent 70eff4b commit 203dfcc

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

variants/mkrgsm1400/linker_scripts/gcc/flash_with_bootloader.ld

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ SECTIONS
6969

7070
KEEP(*(.sketch_boot))
7171

72-
/* After the constructors, call PMIC handling stuff (precompiled) */
73-
KEEP(*(.init_pmic_variant))
74-
7572
. = ALIGN(0x2000);
7673
KEEP(*(.isr_vector))
7774
*(.text*)

variants/mkrgsm1400/variant.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,26 +168,28 @@ SERCOM sercom5(SERCOM5);
168168

169169
#if defined(USE_BQ24195L_PMIC)
170170

171-
#if 0
172-
/* generate .o out of this function and attach it to the linker */
171+
#include "wiring_private.h"
172+
173173
#define PMIC_ADDRESS 0x6B
174174
#define PMIC_REG02 0x02
175175

176176
static inline void set_pmic_safe_defaults() {
177-
Wire.begin();
178-
Wire.beginTransmission(PMIC_ADDRESS);
179-
Wire.write(PMIC_REG02);
180-
Wire.write(0);
181-
Wire.endTransmission();
182-
Wire.end();
177+
PERIPH_WIRE.initMasterWIRE(100000);
178+
PERIPH_WIRE.enableWIRE();
179+
pinPeripheral(PIN_WIRE_SDA, g_APinDescription[PIN_WIRE_SDA].ulPinType);
180+
pinPeripheral(PIN_WIRE_SCL, g_APinDescription[PIN_WIRE_SCL].ulPinType);
181+
182+
PERIPH_WIRE.startTransmissionWIRE( PMIC_ADDRESS, WIRE_WRITE_FLAG );
183+
PERIPH_WIRE.sendDataMasterWIRE(PMIC_REG02);
184+
PERIPH_WIRE.sendDataMasterWIRE(0);
185+
PERIPH_WIRE.prepareCommandBitsWire(WIRE_MASTER_ACT_STOP);
186+
PERIPH_WIRE.disableWIRE();
183187
}
184188

185-
#else
186-
__attribute__ ((section(".__init_pmic_variant")))
187-
unsigned char init_pmic[0x4000] = {
189+
void initVariant() {
190+
set_pmic_safe_defaults();
191+
}
188192

189-
};
190-
#endif
191193
#endif
192194

193195
// Serial1

0 commit comments

Comments
 (0)