Skip to content

Commit 59a1372

Browse files
committed
Add power init function for NICLA_VISION
1 parent e4f769c commit 59a1372

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

app/power/power.cpp

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "board.h"
2121
#include "mbed.h"
2222

23+
#if defined TARGET_PORTENTA_H7_M7
2324
static void portenta_power_init() {
2425
I2C i2c(BOARD_I2C_SDA, BOARD_I2C_SCL);
2526

@@ -85,8 +86,46 @@ static void portenta_power_init() {
8586
data[1]=0xF;
8687
i2c.write(8 << 1, data, sizeof(data));
8788
}
89+
#endif
8890

91+
#if defined TARGET_NICLA_VISION
92+
static void nicla_vision_power_init() {
93+
I2C i2c(BOARD_I2C_SDA, BOARD_I2C_SCL);
94+
95+
char data[2];
96+
97+
data[0]=0x9C;
98+
data[1]=(1 << 7);
99+
i2c.write(8 << 1, data, sizeof(data));
100+
101+
// Disable charger led
102+
data[0]=0x9E;
103+
data[1]=(1 << 5);
104+
i2c.write(8 << 1, data, sizeof(data));
105+
106+
HAL_Delay(10);
107+
108+
// SW3: set 2A as current limit
109+
// Helps keeping the rail up at wifi startup
110+
data[0]=0x42;
111+
data[1]=(2);
112+
i2c.write(8 << 1, data, sizeof(data));
113+
114+
HAL_Delay(10);
115+
116+
// Change VBUS INPUT CURRENT LIMIT to 1.5A
117+
data[0]=0x94;
118+
data[1]=(20 << 3);
119+
i2c.write(8 << 1, data, sizeof(data));
120+
}
121+
#endif
89122

90123
void power_init() {
124+
#if defined TARGET_PORTENTA_H7_M7
91125
portenta_power_init();
92-
}
126+
#elif defined TARGET_NICLA_VISION
127+
nicla_vision_power_init();
128+
#else
129+
130+
#endif
131+
}

app/power/power.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121

2222
void power_init();
2323

24-
#endif //__POWER_H
24+
#endif //__POWER_H

0 commit comments

Comments
 (0)