Misc
Data Storage
Handling of internal or external EEPROM to store device configuration.
Hardware
Hardware-specific functions like timers, watchdog, bootloader.
Functions
-
void system_control()
DC/DC or PWM control loop (implemented in main.cpp)
-
void start_stm32_bootloader()
Reset device and start STM32 internal bootloader
-
void reset_device()
Reset device
-
void task_wdt_callback(int channel_id, void *user_data)
Callback for task watchdogs used in multiple threads
Helper
General helper functions.
Functions
-
static inline uint32_t uptime()
Framework-independent system uptime
- Returns:
seconds since the system booted
-
inline void flags_set(uint32_t *field, uint32_t mask)
Sets one or more flags in given field
- Parameters:
field – pointer to the field that will be manipulated
mask – a single flag or bitwise OR-ed flags
-
inline void flags_clear(uint32_t *field, uint32_t mask)
Clears one or more flags in the bit field
- Parameters:
field – pointer to the field that will be manipulated
mask – a single flag or bitwise OR-ed flags
-
inline bool flags_check(uint32_t *field, uint32_t mask)
Queries one or more flags in the bit field
- Parameters:
field – pointer to the field that will be manipulated
mask – a single flag or bitwise OR-ed
- Returns:
true if any of the flags given in mask are set in the bit field
LEDs
Control of status LEDs with charlieplexing.
Provides higher-level access to different LEDs (e.g. blinking and flickering). Internally, charlieplexing is used for some boards to optimize power consumption and needed pin numbers.
Enums
Functions
-
void leds_init(bool enabled)
Initialize LEDs (called at the beginning of leds_update_thread)
-
void leds_update_thread()
Main thread for LED control. Performs pin initializations and charlieplexing at 60 Hz
-
void leds_set_charging(bool enabled)
Enables/disables dedicated charging LED if existing or blinks SOC LED when solar power is coming in.
-
void leds_set(unsigned int led, bool enabled, int timeout)
Enables/disables LED
- Parameters:
led – Number of LED in array defined in PCB configuration
enabled – LED is switched on if enabled is set to true
timeout – Defines for how long this state should be set (-1 for permanent setting)
-
void leds_on(unsigned int led, int timeout)
Enable LED
- Parameters:
led – Number of LED in array defined in PCB configuration
timeout – Defines for how long this state should be set (-1 for permanent setting)
-
void leds_off(unsigned int led)
Disable LED
- Parameters:
led – Number of LED in array defined in PCB configuration
-
void leds_blink(unsigned int led, int timeout)
Blink LED
- Parameters:
led – Number of LED in array defined in PCB configuration
timeout – Defines for how long this state should be set (-1 for permanent setting)
-
void leds_flicker(unsigned int led, int timeout)
Flicker LED
- Parameters:
led – Number of LED in array defined in PCB configuration
timeout – Defines for how long this state should be set (-1 for permanent setting)
-
void leds_update_1s()
Updates LED blink and timeout states, must be called every second
-
void leds_update_soc(int soc, bool load_off_low_soc)
Update SOC LED bar (if existing)
- Parameters:
soc – SOC in percent
load_off_low_soc – Prevents showing two SOC LEDs if load is switched off because of low SOC
-
void leds_toggle_error()
Toggle between even and uneven LEDs switched on/off to create annoying flashing in case of an error.
Setup
Functions
-
void setup()
Perform some device setup tasks (currently only used in Zephyr)
Variables
-
DeviceStatus dev_stat
-
LoadOutput load
-
LoadOutput usb_pwr
-
ThingSet ts
-
uint32_t timestamp