Add latching pgood function to USB power output
This commit is contained in:
committed by
Martin Jäger
parent
3653b88d25
commit
bcf54f6698
+9
-3
@@ -23,14 +23,15 @@
|
||||
|
||||
extern DeviceStatus dev_stat;
|
||||
|
||||
LoadOutput::LoadOutput(DcBus *dc_bus, void (*drv_switch_fn)(bool), void (*drv_init_fn)()) :
|
||||
LoadOutput::LoadOutput(DcBus *dc_bus, void (*switch_fn)(bool), void (*init_fn)(), bool (*pgood_fn)()) :
|
||||
PowerPort(dc_bus),
|
||||
switch_set(drv_switch_fn)
|
||||
switch_set(switch_fn),
|
||||
pgood_check(pgood_fn)
|
||||
{
|
||||
state = LOAD_STATE_OFF;
|
||||
|
||||
// call driver initialization function
|
||||
drv_init_fn();
|
||||
init_fn();
|
||||
|
||||
switch_set(false);
|
||||
junction_temperature = 25; // starting point: 25°C
|
||||
@@ -61,6 +62,11 @@ void LoadOutput::control()
|
||||
oc_timestamp = uptime();
|
||||
}
|
||||
|
||||
if (pgood_check != NULL && !pgood_check()) {
|
||||
flags_set(&error_flags, ERR_LOAD_OVERCURRENT);
|
||||
oc_timestamp = uptime();
|
||||
}
|
||||
|
||||
// negative margin means sourcing current from bus is allowed
|
||||
if (bus->src_current_margin > -0.1F) {
|
||||
flags_set(&error_flags, ERR_LOAD_BUS_SRC_CURRENT);
|
||||
|
||||
Reference in New Issue
Block a user