File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ Board::Board() {
50
50
#endif
51
51
}
52
52
53
+ Board::~Board () {
54
+ #if defined(ARDUINO_PORTENTA_C33)
55
+ delete lowPower;
56
+ #endif
57
+ }
58
+
53
59
bool Board::begin () {
54
60
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION)
55
61
if (CM7_CPUID == HAL_GetCurrentCPUID ()){
@@ -64,13 +70,15 @@ bool Board::begin() {
64
70
65
71
bool Board::isUSBPowered () {
66
72
uint16_t registerValue = PMIC.readPMICreg (Register::CHARGER_VBUS_SNS);
67
- return bitRead (registerValue, 2 ) == 0 ;
73
+ // TODO: Check which one works
74
+ // return bitRead(registerValue, 2) == 0;
75
+ return bitRead (registerValue, 5 ) == 1 ; // — VBUS is valid -> USB powered
68
76
}
69
77
70
78
bool Board::isBatteryPowered () {
71
79
uint8_t registerValue = PMIC.readPMICreg (Register::CHARGER_BATT_SNS);
72
80
uint8_t batteryPower = extractBits (registerValue, 0 , 2 );
73
- return batteryPower == 0 ;
81
+ return batteryPower == 0 ; // No valid VBUS input -> battery powered
74
82
}
75
83
76
84
void Board::setExternalPowerEnabled (bool on) {
Original file line number Diff line number Diff line change @@ -49,6 +49,11 @@ class Board {
49
49
*/
50
50
Board ();
51
51
52
+ /* *
53
+ * @brief Destroy the Board object.
54
+ */
55
+ ~Board ();
56
+
52
57
/* *
53
58
* @brief Initializes the board by initiating the PMIC.
54
59
*
You can’t perform that action at this time.
0 commit comments