From 803f821e85fedca87c0baee0dd9cde0387225161 Mon Sep 17 00:00:00 2001 From: Cristian Paul Dragomir Date: Wed, 7 Aug 2024 15:25:23 +0300 Subject: [PATCH 1/4] basic functionality compiling for Nicla Vision --- src/Board.cpp | 8 ++++---- src/Board.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Board.cpp b/src/Board.cpp index dae153d..791c856 100644 --- a/src/Board.cpp +++ b/src/Board.cpp @@ -58,7 +58,7 @@ Board::~Board() { } bool Board::begin() { - #if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) + #if defined(ARDUINO_PORTENTA_H7_M7) if (CM7_CPUID == HAL_GetCurrentCPUID()){ if (LowPowerReturnCode::success != LowPower.checkOptionBytes()){ LowPower.prepareOptionBytes(); @@ -124,7 +124,7 @@ void Board::enableWakeupFromPin(uint8_t pin, PinStatus direction){ } #endif -#if defined(ARDUINO_PORTENTA_H7) || defined(ARDUINO_NICLA_VISION) +#if defined(ARDUINO_PORTENTA_H7) void Board::enableWakeupFromPin(){ standbyType |= StandbyType::untilPinActivity; } @@ -177,7 +177,7 @@ bool Board::enableWakeupFromRTC(uint32_t hours, uint32_t minutes, uint32_t secon #endif -#if defined(ARDUINO_PORTENTA_H7) || defined(ARDUINO_NICLA_VISION) +#if defined(ARDUINO_PORTENTA_H7) bool Board::enableWakeupFromRTC(uint32_t hours, uint32_t minutes, uint32_t seconds){ standbyType |= StandbyType::untilTimeElapsed; wakeupDelayHours = hours; @@ -198,7 +198,7 @@ void Board::standByUntilWakeupEvent(){ lowPower -> deepSleep(); #elif defined(ARDUINO_GENERIC_STM32H747_M4) LowPower.standbyM4(); - #elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) + #elif defined(ARDUINO_PORTENTA_H7_M7) RTCWakeupDelay rtcWakeupDelay = RTCWakeupDelay(wakeupDelayHours, wakeupDelayMinutes, wakeupDelaySeconds); if(standbyType == StandbyType::untilEither) LowPower.standbyM7(LowPowerStandbyType::untilPinActivity | LowPowerStandbyType::untilTimeElapsed, rtcWakeupDelay); diff --git a/src/Board.h b/src/Board.h index c0c9277..0209427 100644 --- a/src/Board.h +++ b/src/Board.h @@ -12,7 +12,7 @@ #if defined(ARDUINO_PORTENTA_C33) #include "Arduino_LowPowerPortentaC33.h" #include "RTC.h" -#elif defined(ARDUINO_PORTENTA_H7) || defined(ARDUINO_NICLA_VISION) +#elif defined(ARDUINO_PORTENTA_H7) // When used standalone the LowPowerPortentaH7 library will turn off the Ethernet interface to avoid issues with the line termination resistors, // but in this library we can turn of the Ethernet interface using the PMIC, so we set the NO_ETHERNET_TURN_OFF flag to avoid turning off the Ethernet interface from both sides. #define NO_ETHERNET_TURN_OFF From 61b42dead6af32e08a87d5e6acd0acdec5de5ece Mon Sep 17 00:00:00 2001 From: Cristian Paul Dragomir Date: Mon, 12 Aug 2024 22:15:30 +0300 Subject: [PATCH 2/4] refined the README.md document --- docs/README.md | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/docs/README.md b/docs/README.md index 07ddb62..3781398 100644 --- a/docs/README.md +++ b/docs/README.md @@ -78,32 +78,46 @@ It will return a value of *ChargeStatus* which can be one of the above: This library allows you to change the following charging parameters of the charging process. Please be careful with these and make sure they are supported by the battery you are using as the wrong values might damage your board or the battery. ##### Charge Voltage -Set the voltage that your battery is charged with: +Set the charging voltage in volts (V). +Before changing the default values please be aware that changing the charge voltage can damage your battery. ```cpp -charger.setChargeVoltage(ChargeVoltage::V_3_80); +charger.setChargeVoltage(3.80); ``` - -*ChargeVoltage* is an enum with values ranging from `ChargeVoltage::V_3_50` to `ChargeVoltage::V_4_44` in steps of 0.02V, (`V_3_50`, `V_3_52`, ..., `V_3_42`, `V_4_44`) +The current charging voltage is set to 4.2V by default. +This method accepts float values representing voltages from 3.50V to 4.44V in steps of 0.02V (3.50, 3.52, ...., 4.42, 4.44) ##### Charge Current -Set the current used in the constant charging phase. - +Set the current used in the constant charging phase. This method accepts integer values representing milli amperes (mA). ```cpp -charger.setChargeCurrent(ChargeCurrent::I_500_mA); +charger.setChargeCurrent(1000); ``` -*ChargeCurrent* is an enum with value ranging from `ChargeCurrent::I_100_mA` to `ChargeCurrent::I_100_mA` in steps of 50mA. (`I_100_mA`, `I_150_mA`, ... `I_950_mA`, `I_1000_mA`). +The default charging current is set to 100mA. +Supported values: 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000mA ##### End of Charge Current -This is the current used in the end-of-charge phase where the voltage is kept at 4.2V. +This is the current used in the end-of-charge phase where the voltage is kept at 4.2V. The charger IC determines when to terminate the charge cycle based on the current going into the battery dropping below the given threshold during the constant voltage phase. At this point, the battery is considered fully charged and charging is completed. If charge termination is disabled, the charge current will naturally decay to 0mA, but this is rarely done in practice. +This is because the amount of charge going into the battery exponentially decreases during CV charging, and it would take a significantly longer time to recharge the battery with a very little increase in capacity. + +```cpp +charger.setEndOfChargeCurrent(5); +``` + +The default end-of-charge current is set to 5 mA. +Supported values: 5, 10, 20, 30, 50mA. + + +###### Input Current Limit +The input current limit (ILIM) safeguards the device by preventing overcurrent, ensuring the charging current is within safe levels for the battery, and adapting to the maximum current the power source can provide, allowing you to charge and use the system at the same time. ```cpp -charger.setEndOfChargeCurrent(EndOfChargeCurrent::I_5_mA); +charger.setInputCurrentLimit(1500); ``` -*EndOfChargeCurrent* is an enum with the following values (`I_5_mA`, `I_10_mA`, `I_20_mA`, `I_30_mA`, `I_50_mA`). +The default input current limit is set to 1.5A. +Supported values: 10, 15, 20, 25, 30, 35, 40, 45, 50, 100, 150, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1500mA ## Board The PF1550 power management IC has three LDO regulators, and three DCDC converters, each of these have a configurable voltage range and can be turned on and off. @@ -242,7 +256,7 @@ When utilizing Mbed with STM32-based microcontrollers such as the Portenta H7 an However, initiating this command doesn't guarantee automatic entry into sleep mode due to the presence of Sleep Locks. These locks act as safeguards, preventing the system from sleeping under certain conditions to ensure ongoing operations remain uninterrupted. Common peripherals, such as the USB Stack, may engage a sleep lock, effectively keeping the board awake even during periods of apparent inactivity. This behavior underscores how the effectiveness of sleep mode is closely linked to the specific operations and configurations defined in your sketch. -For those looking to fine-tune their board's energy efficiency by leveraging automatic sleep functionality, a particularly useful resource is [Alrik's example sketch](https://github.com/alrvid/Arduino_LowPowerPortentaH7/blob/main/examples/DeepSleepLockDebug_Example/DeepSleepLockDebug_Example.ino). This sketch provides a comprehensive overview of the active sleep locks, offering insights into what may be preventing the board from entering sleep mode and how to address these obstacles. By incorporating Alrik's insights, developers can more effectively manage their board's power consumption, optimizing for both performance and energy efficiency. +For those looking to fine-tune their board's energy efficiency by leveraging automatic sleep functionality, a particularly useful resource is [the Sleep Lock Example Sketch](https://github.com/alrvid/Arduino_LowPowerPortentaH7/blob/main/examples/DeepSleepLockDebug_Example/DeepSleepLockDebug_Example.ino). This sketch provides a comprehensive overview of the active sleep locks, offering insights into what may be preventing the board from entering sleep mode and how to address these obstacles. #### Send the board to sleep `board.deepSleepUntilwakeupEvent()` - Sends the board into the deep sleep state, where it consumes around ~100uA and ~300uA without peripherals. From 6ec375e4c8ea91973467bbe19c21b5d1949516c8 Mon Sep 17 00:00:00 2001 From: Cristian Paul Dragomir Date: Mon, 12 Aug 2024 22:18:41 +0300 Subject: [PATCH 3/4] increased awake time in standby examples --- examples/Standby_WakeFromRTC_C33/Standby_WakeFromRTC_C33.ino | 2 +- examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Standby_WakeFromRTC_C33/Standby_WakeFromRTC_C33.ino b/examples/Standby_WakeFromRTC_C33/Standby_WakeFromRTC_C33.ino index d25ac85..6926365 100644 --- a/examples/Standby_WakeFromRTC_C33/Standby_WakeFromRTC_C33.ino +++ b/examples/Standby_WakeFromRTC_C33/Standby_WakeFromRTC_C33.ino @@ -62,7 +62,7 @@ void setup() { board.enableWakeupFromRTC(0, 0, 10); // Sleep for 10 seconds - delay(1000); // Keep the board awake for 1 second, so we can se it working + delay(10000); // Keep the board awake for 1 second, so we can se it working board.shutDownFuelGauge(); board.setAllPeripheralsPower(false); diff --git a/examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino b/examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino index b912897..0043259 100644 --- a/examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino +++ b/examples/Standby_WakeFromRTC_H7/Standby_WakeFromRTC_H7.ino @@ -55,7 +55,7 @@ void setup() { } } - delay(5000); // keep the board awake for 5 seconds, so we can se it working + delay(10000); // keep the board awake for 5 seconds, so we can se it working board.shutDownFuelGauge(); From f52022d6f3da0c19be2fe547e98fac3ba4db771c Mon Sep 17 00:00:00 2001 From: Cristian Paul Dragomir Date: Mon, 12 Aug 2024 22:31:04 +0300 Subject: [PATCH 4/4] small heading formatting fix in readme.md --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 3781398..5b00bee 100644 --- a/docs/README.md +++ b/docs/README.md @@ -109,7 +109,7 @@ The default end-of-charge current is set to 5 mA. Supported values: 5, 10, 20, 30, 50mA. -###### Input Current Limit +##### Input Current Limit The input current limit (ILIM) safeguards the device by preventing overcurrent, ensuring the charging current is within safe levels for the battery, and adapting to the maximum current the power source can provide, allowing you to charge and use the system at the same time. ```cpp