The structure has been changed to match the new ThingSet v0.5 spec which
is more suitable to be used in mobile phone apps because the data is
structured based on logical subsystems (Battery, Load) and not on data type
(conf, input, etc.) anymore.
This required some updates in the ThingSet library aswell. Especially the
update mechanism for configuration data had to be changed.
The data_objects_parser script is now able to extract the units itself,
reducing the commenting effort.
All IDs have been kept the same, so previously stored settings in charge
controllers NVM should be compatible.
The format tries to maintain the previously used Libre Solar firmware coding
style as much as possible.
Applying the format fixed some issues and re-ordered some parts of the code.
https://docs.zephyrproject.org/latest/guides/west/workspaces.html
Previously, west manifest and CMake entry point were in zephyr subfolder
as required for PlatformIO. As PlatformIO support was dropped, we can
follow the default Zephyr folder structure more closely.
The application is built and flashed from app subfolder, where as unit
tests are run from tests subfolder.
Rationale: Too much effort to maintain two different tool chains.
PlatformIO does not consider the west.yml files and thus, does not
support custom Zephyr modules. However, they are needed to include
ThingSet as a module.
In addition to that, PlatformIO versions always lag behind official
Zephyr releases and we want to avoid being dependent on PlatformIO.
- Float charging is the more correct and more commonly used term compared
to trickle charging
- Putting voltage at the end of some variable names for more consistency
This allows the serial thread to sleep and avoids polling for incoming
commands every 10 ms as it was done before.
Two semaphores are used, one to lock the receive buffer and the other
one to signal a received command.
Also improving some variable and function naming.
Removing PlatformIO dependency as Zephyr v2.6 is not properly and PlatformIO
updates always take quite a long time after official Zephyr releases.
Unit tests and static code check still have to be ported to Zephyr.
- Add data node ctrl/CtrlTarget_A for current-mode control
- Send out own value every 100 ms and apply received values
of CAN device with highest priority.
This state is enabled if the device receives a current target signal from
a device with higher priority via CAN. After not receiving the messages
for 1 second the state machine automatically goes back to normal operation.
The MPU must be disabled to allow writing the option bytes.
Also replacing flash_write_protection_set with direct register access
because it will be deprecated in Zephyr v2.6.
Reduce the recharge voltage threshold and consider it for transition
between trickle and bulk charging such that the trickle state is
maintained longer and batteries don't get recharged multiple times
per day.
This is also necessary for nanogrid interface control, which can try to
maintain a voltage between recharge and trickle voltage by exporting
excess solar energy towards the grid. If the battery voltage is maintained
at the trickle voltage, the solar input power might be reduced and not all
available power can be used.
If the device starts up with the battery voltage > bat_conf->voltage_recharge,
the charger state machine did not leave CHG_STATE_IDLE. However, the PWM solar
input still started charging the battery and stayed at bulk charging voltage
all the time.
Now we don't check the recharge limits if the CHG_STATE_IDLE was reached for
the first time, so that the state machine goes into CHG_STATE_BULK properly.
Also fixing some formatting and moving the state enum before Charger class.