The hardware CRC calculation fails hard if a non-aligned memory pointer
is passed to it. This was leading to random issues when changing
unrelated parts in the firmware so that the compiler shuffled memory
locations.
Telling GCC that it should word-align the buffer fixes the issue.
Also renaming _lock to eeprom_buf_lock.
For PWM charge controllers, the topping stage was sometimes very short
and the battery did not get fully charged.
This commit adds a voltage_filtered and current_filtered member variable
to DcBus and PowerPort classes which can hold measurements more heavily
filtered (initial time constant setting: 10 seconds). This should fix
above issues with the charging algorithm.
The previous approach to define the pinmux in the timer nodes didn't work
because the timers don't have a pinctrl-0 property. This commit adds a new
half-bridge binding similar to upstream Zephyr pwm binding, which is a child
node of the used timer.
It makes sense to define PWM frequency and dead-time also in this node, so
the dcdc devicetree binding is redundant and therefore removed.
The v2.5-branch is based on upstream master until Zephyr v2.5 is released.
hal_stm32 needs to be overwritten with forked version to support new pinctrl
introduced in Zephyr 2.5.
Also fixing some CAN issues because of API changes to make it compile.
This allows us to enable e.g debug output for the CAN module with
CONFIG_CAN_LOG_LEVEL=4 without enabling the global
CONFIG_LOG_DEFAULT_LEVEL=4 and being swamped with debug output from
all of Zephyr's subsytems.
In situations with full battery and sufficient solar panel power, the
battery could reach a high voltage directly after start of the PWM switch
and the control algorithm was not fast enough to limit the voltage (it
takes up to 18s to reach 5% duty cycle after starting at 95%).
This commit increases the step size in the direction of reduced power
and introduces an overvoltage flag that results in restart with 5% duty
cycle if the previous stop was caused by an overvoltage event.
newlib requires malloc if printf is used with %f. Since PR 28486, the heap
space in RAM is only reserved if explicitly used by the application
(independent of the value of CONFIG_HEAP_MEM_POOL_SIZE) in order to free
some stack memory. As printf calls malloc internally, this commit forces
Zephyr to build with heap support enabled.
This makes more sense because the DC/DC converter actually connects two
DcBuses and does not need separate PowerPorts. Also makes the code look
more clean as variable access like dcdc.hvs->bus->voltage is avoided.
The DcBus pointers in the Dcdc are now called hvb and lvb for high-
voltage side bus and low-voltage side bus.
These variables define the voltage at zero current, which is the y axis
intercept of the droop curve (voltage vs. current).
As they do not always specifiy minimum or maximum boundary depending on
the sign of the droop resistance, intercept is a more suitable name.
Previously, the interval was not exactly 1s, which could have a negative
impact on energy calculations.
This commit also moves the 1s interval tasks from control loop to the main
loop to avoid duplicated loops running at 1s interval.
When switching to edge-aligned PWM, the ADC measurement was accidentally
triggered at the beginning of the switching cycle.
Fixing this using TIM1 OC6, triggering at falling edge.