@@ -58,7 +58,7 @@ Board::~Board() {
5858}
5959
6060bool Board::begin () {
61- #if defined(ARDUINO_PORTENTA_H7_M7)
61+ #if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION)
6262 if (CM7_CPUID == HAL_GetCurrentCPUID ()){
6363 if (LowPowerReturnCode::success != LowPower.checkOptionBytes ()){
6464 LowPower.prepareOptionBytes ();
@@ -146,7 +146,7 @@ bool Board::enableWakeupFromRTC(uint32_t hours, uint32_t minutes, uint32_t secon
146146
147147#endif
148148
149- #if defined(ARDUINO_PORTENTA_H7)
149+ #if defined(ARDUINO_PORTENTA_H7) || defined(ARDUINO_NICLA_VISION)
150150bool Board::enableWakeupFromRTC (uint32_t hours, uint32_t minutes, uint32_t seconds){
151151 standbyType |= StandbyType::untilTimeElapsed;
152152 wakeupDelayHours = hours;
@@ -165,16 +165,19 @@ void Board::sleepUntilWakeupEvent(){
165165void Board::standByUntilWakeupEvent (){
166166 #if defined(ARDUINO_PORTENTA_C33)
167167 lowPower -> deepSleep ();
168- #elif defined(ARDUINO_GENERIC_STM32H747_M4 )
168+ #elif defined(CORE_CM4 )
169169 LowPower.standbyM4 ();
170- #elif defined(ARDUINO_PORTENTA_H7_M7)
170+ #elif defined(ARDUINO_PORTENTA_H7_M7)
171171 RTCWakeupDelay rtcWakeupDelay = RTCWakeupDelay (wakeupDelayHours, wakeupDelayMinutes, wakeupDelaySeconds);
172172 if (standbyType == StandbyType::untilEither)
173173 LowPower.standbyM7 (LowPowerStandbyType::untilPinActivity | LowPowerStandbyType::untilTimeElapsed, rtcWakeupDelay);
174174 else if (standbyType == StandbyType::untilPinActivity)
175175 LowPower.standbyM7 (LowPowerStandbyType::untilPinActivity);
176176 else if (standbyType == StandbyType::untilTimeElapsed)
177177 LowPower.standbyM7 (LowPowerStandbyType::untilTimeElapsed, rtcWakeupDelay);
178+ #elif defined(ARDUINO_NICLA_VISION) && defined(CORE_CM7)
179+ RTCWakeupDelay rtcWakeupDelay = RTCWakeupDelay (wakeupDelayHours, wakeupDelayMinutes, wakeupDelaySeconds);
180+ LowPower.standbyM7 (rtcWakeupDelay);
178181 #endif
179182}
180183
@@ -185,7 +188,7 @@ void Board::setAllPeripheralsPower(bool on){
185188 this -> setCommunicationPeripheralsPower (on);
186189 this -> setExternalPowerEnabled (on);
187190 this -> setAnalogDigitalConverterPower (on);
188- #else if defined(ARDUINO_PORTENTA_H7)
191+ #elif defined(ARDUINO_PORTENTA_H7)
189192 // On the H7 several chips need different voltages, so we cannot turn the lanes that are dependent on each other separately.
190193 // This should only be used when going into standby mode, as turning off the USB-C PHY, Ethernet or Video bridge might cause undefined behaviour.
191194 if (on){
@@ -199,6 +202,23 @@ void Board::setAllPeripheralsPower(bool on){
199202 PMIC.getControl () -> turnLDO3Off (Ldo3Mode::Normal);
200203 PMIC.getControl () -> turnSw1Off (Sw1Mode::Normal);
201204 }
205+
206+ #elif defined(ARDUINO_NICLA_VISION)
207+ if (on){
208+ PMIC.getControl () -> turnLDO2On (Ldo2Mode::Normal); // Camera
209+ PMIC.getControl () -> turnLDO1On (Ldo1Mode::Normal); // ToF sensor / Camera
210+ PMIC.getControl () -> turnLDO3On (Ldo3Mode::Normal); // VDDA - Analog components, e.g. ADC
211+ PMIC.getControl () -> turnSw2On (Sw2Mode::Normal); // USB, 25 MHz crystal, 32 kHz crystal
212+ // TODO: Not supported yet by PMIC library
213+ // PMIC.getControl() -> turnSw3On(Sw3Mode::Normal); // External power VDDIO_EXT
214+ } else {
215+ PMIC.getControl () -> turnLDO2Off (Ldo2Mode::Normal); // Camera
216+ PMIC.getControl () -> turnLDO1Off (Ldo1Mode::Normal); // ToF sensor / Camera
217+ PMIC.getControl () -> turnLDO3Off (Ldo3Mode::Normal); // VDDA - Analog components, e.g. ADC
218+ PMIC.getControl () -> turnSw2Off (Sw2Mode::Normal); // USB, 25 MHz crystal, 32 kHz crystal
219+ // TODO: Not supported yet by PMIC library
220+ // PMIC.getControl() -> turnSw3Off(Sw3Mode::Normal); // External power VDDIO_EXT
221+ }
202222 #endif
203223}
204224//
@@ -270,7 +290,7 @@ bool Board::setReferenceVoltage(float voltage) {
270290void Board::shutDownFuelGauge () {
271291 #if defined(ARDUINO_PORTENTA_C33)
272292 MAX1726Driver fuelGauge (&Wire3);
273- #elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_GENERIC_STM32H747_M4 )
293+ #elif defined(ARDUINO_PORTENTA_H7 )
274294 MAX1726Driver fuelGauge (&Wire1);
275295 #elif defined(ARDUINO_NICLA_VISION)
276296 MAX1726Driver fuelGauge (&Wire1);
0 commit comments