Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
power_delivery.h File Reference

Interface for the abstraction layer of the USB-PD algorithm. More...

Go to the source code of this file.

Classes

struct  lampda::bsp::powerDelivery::PDOTypes
 Define a USB PD PDO type. More...
 
struct  lampda::bsp::powerDelivery::OTGParameters
 The requested OTG parameters. More...
 

Namespaces

namespace  lampda
 Program scope.
 
namespace  lampda::bsp
 Board Support Layer, handle the low level logic above the HAL.
 
namespace  lampda::bsp::powerDelivery
 Handles the power delivery capabilities (USB-PD).
 

Functions

bool lampda::bsp::powerDelivery::setup ()
 call once at program start, attach interrupts and init
 
void lampda::bsp::powerDelivery::start_threads ()
 Start polling threads.
 
void lampda::bsp::powerDelivery::loop ()
 call often (update status)
 
void lampda::bsp::powerDelivery::shutdown ()
 call once at program end
 
void lampda::bsp::powerDelivery::allow_source_resets (const bool allow)
 Allow the sink to reset the source, when the source capabilities were missed. A hard reset makes the source drop VBUS for up to ~2s. Forbid it when the battery cannot power the board (recovery mode), or this browns it out: the source is then used as a standard 5V port. Forbidden until allowed. Allowing it later starts the reset of a source waiting for its capabilities.
 
void lampda::bsp::powerDelivery::suspend_pd_state_machine ()
 Suspend the execution of the power delivery state machine.
 
void lampda::bsp::powerDelivery::resume_pd_state_machine ()
 resume the execution of the power delivery state machine
 
int lampda::bsp::powerDelivery::get_vbus_voltage ()
 use the vbus measure from negociator (close to USBC, 0 to N volts)
 
uint16_t lampda::bsp::powerDelivery::get_max_input_current ()
 return the max current available for this source
 
bool lampda::bsp::powerDelivery::is_standard_port ()
 return true if this voltage source is from a standard non pd port
 
bool lampda::bsp::powerDelivery::is_power_available ()
 Return true if some power is available on VBUS.
 
bool lampda::bsp::powerDelivery::can_use_power ()
 Return true if we can use this source as power entry.
 
void lampda::bsp::powerDelivery::force_set_to_source_mode (const bool force)
 force the system to source mode
 
void lampda::bsp::powerDelivery::allow_otg (const bool)
 Call to allow or forbid OTG mode.
 
void lampda::bsp::powerDelivery::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.
 
bool lampda::bsp::powerDelivery::is_attached_as_sink ()
 return true when the PD state machine is attached to a partner, as a sink
 
void lampda::bsp::powerDelivery::retry_source_role_swap ()
 As a ready sink wanting the source role (want_source_role_by_swap), ask for the power role swap again.
 
bool lampda::bsp::powerDelivery::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
 
bool lampda::bsp::powerDelivery::is_switching_to_otg ()
 return true is the system is prepaping to switch to OTG mode
 
bool lampda::bsp::powerDelivery::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
 
std::array< PDOTypes, 5 > lampda::bsp::powerDelivery::get_available_pd ()
 If the charger is PD compatible, return it's capabilities.
 
void lampda::bsp::powerDelivery::show_pd_status ()
 Debug power delivery status.
 
OTGParameters lampda::bsp::powerDelivery::get_otg_parameters ()
 Return the desired OTG parameters.
 

Detailed Description

Interface for the abstraction layer of the USB-PD algorithm.