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

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

Functions

constexpr uint16_t getInputPins ()
 Retrieves the input pins configuration.
 
constexpr uint16_t getOutputPins ()
 Retrieves the output pins configuration.
 
void initializeOldPCBPins ()
 Initializes optional pins for the old PCB configuration.
 
void initializeProcessing ()
 Initializes the processing engine, including ports, load states, and ADC setup.
 
void printConfiguration ()
 Print the configuration 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

◆ 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 177 of file processing.cpp.

References bit_read(), bit_set(), DIVERSION_PIN_PRESENT, diversionPin, DUAL_TARIFF, dualTariffPin, forcePin, OVERRIDE_PIN_PRESENT, PIN, and rotationPin.

Referenced by initializeProcessing().

Here is the call graph for this function:
Here is the caller 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 126 of file processing.cpp.

References bit_read(), bit_set(), physicalLoadPin, RELAY_DIVERSION, relays, WATCHDOG_PIN_PRESENT, and watchDogPin.

Referenced by initializeProcessing().

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

◆ initializeOldPCBPins()

void initializeOldPCBPins ( )

Initializes optional pins for the old PCB configuration.

This function configures various optional pins based on the hardware setup and feature flags. It ensures that the pins are properly initialized for their respective purposes, such as dual tariff, override, priority rotation, diversion, relay diversion, and watchdog functionality.

Warning
Ensure that the pin assignments are valid for the selected PCB configuration.
  • Configures the dual tariff pin as an input with an internal pull-up resistor.
  • Configures the override pin as an input with an internal pull-up resistor.
  • Configures the priority rotation pin as an input with an internal pull-up resistor.
  • Configures the diversion pin as an input with an internal pull-up resistor.
  • Initializes relay diversion pins if enabled.
  • Configures the watchdog pin as an output and sets it to OFF.

Definition at line 1277 of file processing.cpp.

References DIVERSION_PIN_PRESENT, diversionPin, DUAL_TARIFF, dualTariffPin, forcePin, i, loadPrioritiesAndState, loadPrioritiesAtStartup, loadStateMask, NO_OF_DUMPLOADS, OVERRIDE_PIN_PRESENT, physicalLoadPin, PIN, RELAY_DIVERSION, relays, rotationPin, setPinOFF(), updatePhysicalLoadStates(), updatePortsStates(), WATCHDOG_PIN_PRESENT, and watchDogPin.

Referenced by initializeProcessing().

Here is the call graph for this function:
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 229 of file processing.cpp.

References bit_clear(), bit_set(), getInputPins(), getOutputPins(), i, initializeOldPCBPins(), loadPrioritiesAndState, loadPrioritiesAtStartup, loadStateMask, NO_OF_DUMPLOADS, OLD_PCB, setPinsAsInputPullup(), and setPinsAsOutput().

Referenced by setup().

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 55 of file utils.h.

References ANTI_CREEP_LIMIT, BRANCH_NAME, COMMIT_HASH, CURRENT_TIME, DBUG, DBUGLN, HumanReadable, IoT, JSON, powerCal_diverted, powerCal_grid, printParamsForSelectedOutputMode(), PROJECT_PATH, REQUIRED_EXPORT_IN_WATTS, and SERIAL_OUTPUT_TYPE.

Referenced by setup().

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