Pairs with stm32-hal-vcu PR #42. Adds a runtime "vcuchglim" param that the VCU broadcasts every 200 ms; on receipt, the param's Change() callback translates 20-100% to the charger's udcspnt (DC voltage setpoint) using a linear cell-voltage ramp. Without this, the teslacharger had no path for the user's app-set charge limit to actually limit charging — udcspnt was effectively a compile-time setpoint. What's added ------------ - Param::vcuchglim in include/param_prj.h: PARAM_ENTRY(CAT_CHARGER, vcuchglim, "%", 20, 100, 80, 23) - Range 20-100 (matches VCU validation) - Default 80% if VCU never connects - ID 23 (next free per the comment, bumped to 24) - Saveable so a flashed charger paired with a silent VCU still behaves predictably across reboots - can->AddRecv(Param::vcuchglim, 0x212, 0, 8, 1) registration in ChargerCAN::MapMessages() — libopeninv's CanMap dispatches to the Change() callback on each received frame. - Param::Change(vcuchglim) handler in src/main.cpp: cell_target = 3.30 + (4.15 - 3.30) * (pct - 20) / 80 udcspnt = cell_target * 96 Endpoints chosen to be safe across Tesla LDU / VW MEB / Volt2: 20% → 3.30 V/cell × 96 = 316.8 V (deep-cycle storage floor) 80% → 3.94 V/cell × 96 = 378.0 V (recommended daily ceiling) 100% → 4.15 V/cell × 96 = 398.4 V (matches existing udclim default) Tuneable here as constants if a particular pack needs a tighter range. - VER bump 1.19.R → 1.20.R. Combined with the pre-existing -S1 suffix the OI web UI shows "4=1.20.R-S1", visually distinct from upstream and from the previous Skudak build. Build ----- text=25288, links clean. The "RWX LOAD segment" linker warning is pre-existing on this template, unrelated. No new warnings from this change. Version string in the binary verified as "4=1.20.R-S1". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
stm32-template
This project can be a starting point to your own STM32 project. It contains facilities that make software development easier and ensures compatibility with the esp8266 web interface.
It provides
- Mostly object oriented syntax
- A simple, hardware based scheduler for recurring tasks
- Analog input management, fully independent with DMA
- Digital I/O management
- CAN library supporting up to 2 CAN interfaces
- hardware filter support
- No limitation on number of messages
- Automatic mapping from/to parameter module
- CAN Open SDO support
- Fully interrupt driven
- Error memory
- ligthweight fixed point arithmetic
- string functions to be independent of stdlib
- Parameter module that interfaces to esp8266 web GUI
- Saving parameters to flash
- Serial terminal with custom commands and DMA transfer
- Mathematical functions (sin/cos, arctan, square root)
- PI controller class
- Functions for field oriented control
OTA (over the air upgrade)
The firmware is linked to leave the 4 kb of flash unused. Those 4 kb are reserved for the bootloader that you can find here: https://github.com/jsphuebner/tumanako-inverter-fw-bootloader When flashing your device for the first time you must first flash that bootloader. After that you can use the ESP8266 module and its web interface to upload your actual application firmware. The web interface is here: https://github.com/jsphuebner/esp8266-web-interface
Compiling
You will need the arm-none-eabi toolchain: https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads On Ubuntu type
sudo apt-get install git gcc-arm-none-eabi
The only external depedencies are libopencm3 and libopeninv. You can download and build these dependencies by typing
make get-deps
Now you can compile stm32- by typing
make
And upload it to your board using a JTAG/SWD adapter, the updater.py script or the esp8266 web interface.
Editing
The repository provides a project file for Code::Blocks, a rather leightweight IDE for cpp code editing. For building though, it just executes the above command. Its build system is not actually used. Consequently you can use your favority IDE or editor for editing files.
Adding classes or modules
As your firmware grows you probably want to add classes. To do so, put the header file in include/ and the source file in src/ . Then add your module to the object list in Makefile that starts in line 43 with .o extension. So if your files are called "mymodule.cpp" and "mymodule.h" you add "mymodule.o" to the list.
When changing a header file the build system doesn't always detect this, so you have to "make clean" and then make. This is especially important when editing the "*_prj.h" files.