3-phase PV router
Loading...
Searching...
No Matches
processing.h
Go to the documentation of this file.
1
12
13#ifndef PROCESSING_H
14#define PROCESSING_H
15
16#include "config_derived.h"
17
19
20inline constexpr uint8_t PERSISTENCE_FOR_POLARITY_CHANGE{ 1 };
21
22inline constexpr uint16_t initialDelay{ 3000 };
23inline constexpr uint16_t startUpPeriod{ 3000 };
24
25// one temperature per sensor, only with temperature sensing (TEMP_SENSOR_PRESENT is a constexpr, not a macro)
27
29
30#if defined(__DOXYGEN__)
32inline void processStartUp(uint8_t phase);
33inline void processStartNewCycle();
34inline void processVoltageRawSample(const uint8_t phase, const uint16_t rawSample);
35inline void processCurrentRawSample(const uint8_t phase, const uint16_t rawSample);
36inline void processPlusHalfCycle(uint8_t phase);
37inline void processMinusHalfCycle(uint8_t phase);
38inline void processRawSamples(const uint8_t phase);
39inline void processVoltage(uint8_t phase);
40inline void processPolarity(uint8_t phase, uint16_t rawSample);
41inline void confirmPolarity(uint8_t phase);
42inline void processLatestContribution(uint8_t phase);
43inline void processDataLogging();
44inline void updatePortsStates();
46#else
47// -O3 on a function that is a call of its own: here 50 bytes smaller than with -Os
48void initializeProcessing() __attribute__((optimize("-O3")));
49inline void processStartUp(uint8_t phase) __attribute__((always_inline));
50inline void processStartNewCycle() __attribute__((always_inline));
51inline void processVoltageRawSample(const uint8_t phase, const uint16_t rawSample) __attribute__((always_inline));
52inline void processCurrentRawSample(const uint8_t phase, const uint16_t rawSample) __attribute__((always_inline));
53inline void processPlusHalfCycle(uint8_t phase) __attribute__((always_inline));
54inline void processMinusHalfCycle(uint8_t phase) __attribute__((always_inline));
55inline void processRawSamples(const uint8_t phase) __attribute__((always_inline));
56inline void processVoltage(uint8_t phase) __attribute__((always_inline));
57inline void processPolarity(uint8_t phase, uint16_t rawSample) __attribute__((always_inline));
58inline void confirmPolarity(uint8_t phase) __attribute__((always_inline));
59inline void processLatestContribution(uint8_t phase) __attribute__((always_inline));
60inline void processDataLogging() __attribute__((always_inline));
61// An inlined function is compiled with the options of the function it lands in: an optimize()
62// attribute on it changes nothing. updatePortsStates() is a call: -O3 unrolls its load loop into
63// constant masks (grid simulator: 38 cycles less on average, 88 less at most).
64inline void updatePortsStates() __attribute__((optimize("-O3")));
65// not inlined on purpose: inlined, it takes registers that the rest of the ISR then spills to a
66// stack frame on every call (grid simulator: 30 cycles more on average, 65 more at most)
67void updatePhysicalLoadStates() __attribute__((noinline));
68#endif
69
70#endif /* PROCESSING_H */
container for datalogging
Definition types.h:53
constexpr uint8_t NO_OF_DUMPLOADS
Definition config.h:40
constexpr bool TEMP_SENSOR_PRESENT
Definition config.h:65
The configuration as the firmware uses it: the settings, and what is built from them.
constexpr TempSensors tempSensors
constexpr uint8_t NO_OF_PHASES
void printParamsForSelectedOutputMode()
Print the settings used for the selected output mode.
void initializeProcessing()
Initializes the processing engine, including ports, load states, and ADC setup.
void updatePhysicalLoadStates()
Updates the physical load states based on logical load priorities and states.
void processLatestContribution(uint8_t phase)
Process the latest contribution after each phase-specific new cycle.
void updatePortsStates()
Updates the control ports for each of the physical loads.
void processStartUp(uint8_t phase)
Processes the startup period for the router.
void processStartNewCycle()
Processes the start of a new mains cycle on phase 0.
void processMinusHalfCycle(uint8_t phase)
Processes the start of a new negative half cycle for the specified phase.
void processRawSamples(const uint8_t phase)
Processes raw voltage and current samples for the specified phase.
void processPolarity(uint8_t phase, uint16_t rawSample)
Processes the polarity of the current voltage sample for a specific phase.
void processPlusHalfCycle(uint8_t phase)
Process the start of a new positive half cycle for the specified phase.
void processDataLogging()
Process data logging at the end of each logging period.
void processCurrentRawSample(const uint8_t phase, const uint16_t rawSample)
Processes the current raw sample for the specified phase.
void processVoltageRawSample(const uint8_t phase, const uint16_t rawSample)
Processes the current voltage raw sample for the specified phase.
void confirmPolarity(uint8_t phase)
Confirms the polarity of the current voltage sample for a specific phase.
void processVoltage(uint8_t phase)
Processes the current voltage sample for the specified phase.
constexpr uint16_t startUpPeriod
Definition processing.h:23
constexpr uint8_t PERSISTENCE_FOR_POLARITY_CHANGE
Definition processing.h:20
uint8_t loadPrioritiesAndState[NO_OF_DUMPLOADS]
Definition processing.h:18
PayloadTx_struct< NO_OF_PHASES, TEMP_SENSOR_PRESENT ? tempSensors.size() :0 > tx_data
Definition processing.h:26
constexpr uint16_t initialDelay
Definition processing.h:22