@@ -205,17 +205,44 @@ namespace m5
205205 , cap_set_charge_voltage = 1u << 2
206206 };
207207
208+ // / The power output paths a model provides. (see getPowerOutputCaps)
209+ // / @note This mask is deliberately separate from ext_port_mask_t, so that a
210+ // / port bit never gets tied to a capability bit.
211+ enum power_output_capability_t : std::uint8_t
212+ { cap_set_ext_output = 1u << 0
213+ , cap_set_usb_output = 1u << 1
214+ , cap_set_ext_port_bus = 1u << 2
215+ , cap_set_vibration = 1u << 3
216+ };
217+
208218 bool begin (void );
209219
210220 // / Set power output of the external ports.
211221 // / @param enable true=output / false=input
212- // / @param port_mask for M5Station. ext_port (bitmask).
222+ // / @param port_mask for M5Station / M5PowerHub / Tab5 family / CoreP4X / ChainCaptain. ext_port (bitmask).
223+ // / @return true if the requested state was reached on every selected port.
224+ // / @note A successful return means the writes were accepted; state is not read back
225+ // / (except when disabling the CoreS3 family output).
226+ // / @note false means a model without the path (see getPowerOutputCaps()),
227+ // / an I2C failure, or a protection check that cancelled the request
228+ // / (Core2 / Tough on a low battery, the CoreS3 family without a battery).
229+ // / Core2 / Tough with AXP2101: when the INA3221 did not respond at begin(),
230+ // / the current-direction part of that check is skipped.
231+ // / On the CoreS3 family it is also false when the request could not take the
232+ // / AW9523 lock or was superseded by a later request while it waited.
233+ // / Every selected port is still attempted; false says at least one
234+ // / did not take effect, not which one.
235+ // / @note port_mask is honoured only on models with individually switched ports
236+ // / (M5Station, PowerHub, Tab5 family, CoreP4X, ChainCaptain); there a mask
237+ // / that selects none of the model's ports returns false without touching
238+ // / anything. Models with a single output ignore the mask, except that
239+ // / ext_none returns false on every model.
213240 // / @note On the CoreS3 family (CoreS3 / CoreS3 SE / StackChan), disabling an enabled output blocks for
214241 // / about 200 ms (the boost converter is stopped first and the bus is left to discharge before the
215242 // / switch-over), and enabling without a battery may block for up to 1 s while the protection check
216243 // / waits for the TS reading to settle. The switch-over is serialized with setUsbOutput and the
217244 // / internal speaker enable, so those may wait for it as well.
218- void setExtOutput (bool enable, ext_port_mask_t port_mask = (ext_port_mask_t )0xFF);
245+ bool setExtOutput (bool enable, ext_port_mask_t port_mask = (ext_port_mask_t )0xFF);
219246
220247 // / deprecated : Change to "setExtOutput"
221248 [[deprecated("Change to setExtOutput")]]
@@ -227,9 +254,12 @@ namespace m5
227254
228255 // / Set power output of the main USB port.
229256 // / @param enable true=output / false=input
257+ // / @return true if the requested state was reached.
258+ // / @note false means a model without the path (see getPowerOutputCaps()), an I2C failure,
259+ // / or, on the CoreS3 family, failure to acquire the AW9523 lock.
230260 // / @attention for M5Stack CoreS3 main USB port.
231261 // / @attention ※ Not for M5Station/M5Tab external USB.
232- void setUsbOutput (bool enable);
262+ bool setUsbOutput (bool enable);
233263
234264 // / Get power output of the main USB port.
235265 // / @return true=output enabled / false=output disabled
@@ -439,12 +469,24 @@ namespace m5
439469
440470 // / Set the configuration of the external port bus.
441471 // / @param config Configuration of the external port bus.
472+ // / @return true if the configuration was written.
473+ // / @note false means a model without the path (see getPowerOutputCaps()) or an I2C failure.
442474 // / @attention for M5PowerHub.
443- void setExtPortBusConfig (const ext_port_bus_t & config);
475+ bool setExtPortBusConfig (const ext_port_bus_t & config);
444476
445477 // / Operate the vibration motor
446478 // / @param level Vibration strength of the motor. (0=stop)
447- void setVibration (uint8_t level);
479+ // / @return true if the requested level was applied.
480+ // / @note false means a model without a motor (see getPowerOutputCaps()) or an I2C failure.
481+ // / @note A nonzero level is clamped to the rail minimum: 1800 mV on AXP192
482+ // / LDO3 and 500 mV on AXP2101 DLDO1.
483+ bool setVibration (uint8_t level);
484+
485+ // / Get which power output paths this model provides.
486+ // / @return bitmask of power_output_capability_t. 0 = no output path, or M5.begin() has not completed yet.
487+ // / @note A set bit says the path exists, not that a call on it will succeed:
488+ // / the setters still return false on an I2C failure or a cancelled request.
489+ std::uint8_t getPowerOutputCaps (void );
448490
449491 pmic_t getType (void ) const { return _pmic; }
450492
0 commit comments