3-phase PV router
Loading...
Searching...
No Matches
Initialization

Functions and classes responsible for system setup and configuration. More...

Functions

int freeRam ()
 Get the available RAM during setup.
 
constexpr uint16_t getInputPins ()
 Retrieves the input pins configuration.
 
constexpr uint16_t getLoadPins ()
 The pins the loads drive: the local TRIACs, plus the status LED of each remote load.
 
constexpr uint16_t getOutputPins ()
 Retrieves the output pins configuration.
 
template<typename T, size_t N>
constexpr void initializeArray (T(&array)[N], T value)
 Initializes all elements of a given array to a specified value.
 
void initializeProcessing ()
 Initializes the processing engine, including ports, load states, and ADC setup.
 
void printConfiguration ()
 Print the configuration during startup.
 
void printParamsForSelectedOutputMode ()
 Print the settings used for the selected output mode.
 
void printRotationGroups ()
 Prints the rotation groups, as load numbers counted from 0 as in LOAD(n): "\tgroups { 0 1 2 } { 3 4 5 }".
 
void setup ()
 Called once during startup.
 

Detailed Description

Functions and classes responsible for system setup and configuration.

This group includes functions and classes that handle the initialization of hardware components, system parameters, and other configurations required for the proper operation of the system.

Function Documentation

◆ freeRam()

int freeRam ( )
inline

Get the available RAM during setup.

This function calculates the amount of free RAM available in the system. It is useful for debugging and ensuring that the system has sufficient memory for proper operation.

Returns
int The amount of free RAM in bytes.

Definition at line 681 of file utils.h.

Here is the caller graph for this function:

◆ getInputPins()

uint16_t getInputPins ( )
constexpr

Retrieves the input pins configuration.

This function determines which pins are configured as input pins based on the current hardware setup. It ensures that no pin is configured multiple times and handles special cases like the dual tariff, diversion, rotation, and force pins.

Returns
A 16-bit value representing the configured input pins. Returns 0 if an invalid configuration is detected.
Note
This function is marked as constexpr and can be evaluated at compile time.

Definition at line 231 of file processing.cpp.

Here is the call graph for this function:

◆ getLoadPins()

uint16_t getLoadPins ( )
constexpr

The pins the loads drive: the local TRIACs, plus the status LED of each remote load.

Returns
A 16-bit mask of these pins, computed at compile time.

Definition at line 359 of file processing.cpp.

Here is the call graph for this function:

◆ getOutputPins()

uint16_t getOutputPins ( )
constexpr

Retrieves the output pins configuration.

This function determines which pins are configured as output pins based on the current hardware setup. It ensures that no pin is configured multiple times and handles special cases like the watchdog pin.

Returns
A 16-bit value representing the configured output pins. Returns 0 if an invalid configuration is detected.
Note
This function is marked as constexpr and can be evaluated at compile time.

Definition at line 174 of file processing.cpp.

Here is the call graph for this function:

◆ initializeArray()

template<typename T, size_t N>
void initializeArray ( T(&) array[N],
T value )
constexpr

Initializes all elements of a given array to a specified value.

This template function provides a type-safe and efficient way to initialize arrays of any type and size with a specific value. Being a constexpr function, it can be evaluated at compile time when all inputs are compile-time constants, or at runtime when needed.

This utility is particularly useful in embedded systems where:

  • Predictable and uniform initialization is required
  • Type safety is important to prevent initialization errors
  • The array size is automatically deduced, avoiding size mismatch errors
Template Parameters
TThe type of the array elements (automatically deduced from the array)
NThe number of elements in the array (automatically deduced)
Parameters
[in,out]arrayReference to the array to be initialized. All elements will be overwritten with the specified value.
[in]valueThe value to assign to each element of the array. The type must be compatible with the array element type.
Note
This function is marked constexpr, allowing compile-time evaluation when both the array and value are compile-time constants. When used with runtime values, it executes as a regular function.
Example Usage:
uint32_t offsets[NO_OF_PHASES];
initializeArray(offsets, static_cast<uint32_t>(0x8000UL << 16));
constexpr uint8_t NO_OF_PHASES
constexpr void initializeArray(T(&array)[N], T value)
Initializes all elements of a given array to a specified value.

Definition at line 152 of file processing.cpp.

Here is the caller graph for this function:

◆ initializeProcessing()

void initializeProcessing ( )

Initializes the processing engine, including ports, load states, and ADC setup.

This function performs the following tasks:

  • Initializes the DC offset array for voltage samples.
  • Configures the input and output pins based on the hardware setup.
  • Sets up the ADC in free-running mode with interrupts enabled.
  • Prepares the system for processing energy and load states.
Note
This function must be called during system initialization to ensure proper operation.

Definition at line 296 of file processing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printConfiguration()

void printConfiguration ( )
inline

Print the configuration during startup.

This function outputs the system configuration to the Serial output during startup. It includes details about the sketch, build information, electrical settings, and enabled features.

  • Prints the sketch ID, branch name, commit hash, and build date/time.
  • Outputs electrical settings such as power calibration, voltage calibration, and phase calibration.
  • Displays enabled features like temperature sensing, dual tariff, load rotation, relay diversion, and RF communication.
  • Logs the selected datalogging format (Human-readable, IoT, or JSON).

Definition at line 142 of file utils.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printParamsForSelectedOutputMode()

void printParamsForSelectedOutputMode ( )

Print the settings used for the selected output mode.

This function displays the relevant configuration parameters for the currently selected output mode. It provides details about the energy bucket capacity, thresholds, and mode-specific settings.

  • For the "normal" mode, it displays the energy bucket capacity and thresholds.
  • For the "anti-flicker" mode, it also displays the offset of energy thresholds.

Definition at line 1060 of file processing.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printRotationGroups()

void printRotationGroups ( )
inline

Prints the rotation groups, as load numbers counted from 0 as in LOAD(n): "\tgroups { 0 1 2 } { 3 4 5 }".

Definition at line 40 of file utils.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup()

void setup ( )

Called once during startup.

This function initializes the system, configures pins, and prints system configuration to the Serial Monitor. It also initializes optional features like temperature sensing and load priorities.

  • Delays startup to allow time to open the Serial Monitor.
  • Initializes the Serial interface.
  • Displays configuration information.
  • Initializes all loads to OFF at startup.
  • Logs load priorities and initializes temperature sensors if present.
  • Prints available free RAM for debugging purposes.

Definition at line 335 of file main.cpp.

Here is the call graph for this function: