Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Namespaces | Classes | Functions | Variables
lampda::bsp::powergates Namespace Reference

Handle the two main power gates : Output and USB. More...

Namespaces

namespace  power
 specific power commands
 

Classes

struct  PowerGateLock
 Hold _powerGateMutex for the scope. More...
 

Functions

bool is_power_gate_switched ()
 
bool is_vbus_gate_switched ()
 
bool is_power_gate_enabled ()
 return true when the gate if enabled (after the delay).
 
bool __is_power_gate_enabled ()
 check if power gate is enabled
 
void enable_gate (bool isVbusGate)
 
void disable_vbus_gate ()
 
void disable_power_gate ()
 
void switch_delayed_vbus_gate (bool enable)
 
void switch_delayed_power_gate (bool enable)
 
void init ()
 Called once on system startup.
 
void loop ()
 Called often to refresh the status.
 
void enable_power_gate ()
 enable the power gate. This will first disable the vbus gate, then after a delay enable the power gate.
 
void enable_vbus_gate ()
 enable the vbus gate. This will first disable the power gate, then after a delay enable the vbus gate.
 
void enable_vbus_gate_DIRECT ()
 Fast swap only: directly close output gate and enable vbus gate.
 
bool is_vbus_gate_enabled ()
 return true when the gate if enabled (after the delay).
 
void disable_gates ()
 disable immediatly all gates, stop the unlocking processes.
 
bool are_gate_disabled ()
 return true if the gates are disabled.
 

Variables

bool _isInit = false
 
static constexpr uint32_t gateSwitchDelay_ms = 50
 
static constexpr uint32_t BLIP_MAX_TIME = 10000
 max off delay of the gate blip
 
static uint32_t _blipStartTime_ms = 0
 
static uint32_t _blipDuration_ms = 0
 
static bool _isPowerGateReallyEnabled = false
 
static hal::mutex::hal_mutex_t _powerGateMutex
 Guards the power gate pin, the blip state (_blipStartTime_ms, _blipDuration_ms) and _isPowerGateReallyEnabled: blip() and cancel_blip() run on the user thread, while loop() and the gate switches run on the power thread. A blip start, its timeout and its cancellation are then never interleaved with each other or with a gate switch. Not recursive.
 
static const bool _isPowerGateMutexInit = (hal::mutex::hal_mutex_init(&_powerGateMutex), true)
 Initialized at program start: blips can be requested before the power init.
 
static bool _isVbusGateEnabled = false
 
static bool _isVbusGateSwitching = false
 
static uint32_t _vbusGateStartSwitchingTime = 0
 
static bool _isPowerGateEnabled = false
 
static bool _isPowerGateSwitching = false
 
static uint32_t _powerGateStartSwitchingTime = 0
 

Detailed Description

Handle the two main power gates : Output and USB.