5#ifndef BSP_PD_POWER_DELIVERY_H
6#define BSP_PD_POWER_DELIVERY_H
14namespace powerDelivery {
void allow_otg(const bool allow)
Call to allow or forbid OTG mode.
Definition: power_delivery.cpp:632
void shutdown()
call once at program end
Definition: power_delivery.cpp:613
void loop()
call often (update status)
Definition: power_delivery.cpp:546
bool is_source_hard_resetting()
return true when we are a source in a hard reset: VBUS must be cut until the end of the recovery time
Definition: power_delivery.cpp:644
void show_pd_status()
Debug power delivery status.
Definition: power_delivery.cpp:392
bool can_use_power()
Return true if we can use this source as power entry.
Definition: power_delivery.cpp:619
void suspend_pd_state_machine()
Suspend the execution of the power delivery state machine.
Definition: power_delivery.cpp:52
bool is_attached_as_sink()
return true when the PD state machine is attached to a partner, as a sink
Definition: power_delivery.cpp:636
uint16_t get_max_input_current()
return the max current available for this source
Definition: power_delivery.cpp:615
std::array< PDOTypes, 5 > get_available_pd()
If the charger is PD compatible, return it's capabilities.
Definition: power_delivery.cpp:646
bool setup()
call once at program start, attach interrupts and init
Definition: power_delivery.cpp:501
void allow_source_resets(const bool allow)
Allow the sink to reset the source, when the source capabilities were missed. A hard reset makes the ...
Definition: power_delivery.cpp:58
int get_vbus_voltage()
use the vbus measure from negociator (close to USBC, 0 to N volts)
Definition: power_delivery.cpp:79
bool is_source_contract_ready()
return true when we are a source, with a contract in place (PS_RDY sent): the sink can use the power
Definition: power_delivery.cpp:640
void retry_source_role_swap()
As a ready sink wanting the source role (want_source_role_by_swap), ask for the power role swap again...
Definition: power_delivery.cpp:638
OTGParameters get_otg_parameters()
Return the desired OTG parameters.
Definition: power_delivery.cpp:623
bool is_power_available()
Return true if some power is available on VBUS.
Definition: power_delivery.cpp:617
void want_source_role_by_swap(const bool wanted)
As a sink, ask the partner for the source role (power role swap), and do not use its power meanwhile.
Definition: power_delivery.cpp:634
bool is_switching_to_otg()
return true is the system is prepaping to switch to OTG mode
Definition: power_delivery.cpp:642
void start_threads()
Start polling threads.
Definition: power_delivery.cpp:521
void resume_pd_state_machine()
resume the execution of the power delivery state machine
Definition: power_delivery.cpp:65
bool is_standard_port()
return true if this voltage source is from a standard non pd port
Definition: power_delivery.cpp:130
void force_set_to_source_mode(const bool force)
force the system to source mode
Definition: power_delivery.cpp:621
Program scope.
Definition: control_fixed_modes.hpp:14
The requested OTG parameters.
Definition: power_delivery.h:115
uint16_t requestedCurrent_mA
Requested maximum current use for the OTG.
Definition: power_delivery.h:119
bool is_otg_requested() const
Return true if OTG is requested and should be turned on.
Definition: power_delivery.h:122
static OTGParameters get_default()
Return the default OTG targets.
Definition: power_delivery.h:127
uint16_t requestedVoltage_mV
Requested voltage for the OTG.
Definition: power_delivery.h:117
Define a USB PD PDO type.
Definition: power_delivery.h:92
uint32_t voltage_mv
Voltage of this PDO.
Definition: power_delivery.h:100
bool is_valid() const
Indicate if this object contains valid data.
Definition: power_delivery.h:94
uint32_t maxCurrent_mA
Maximum current of this PDO.
Definition: power_delivery.h:102