This commit breaks old configuration by interpreting stored voltages as
millivolts, rather than 50 mV. This will allow the finer voltage
increments used by programmable power supplies to be specified.
Now the CURRENT_DEFN field of the flags halfword in the pdbs_config
object is actually used, both when printing configuration objects and
when setting a current. It never takes any value other than 0 (_I) yet,
but this easily extends to power and resistance.
This commit adds the toggle_hv_preferred command, and makes printed
configuration objects show the state of the HV_Preferred flag. The
flag still isn't used by anything else yet though.
All the internal functions and definitions have been moved out of
lib/include/. Includes are made with the semantically correct brackets
("" or <>) throughout the firmware and library. That is to say, the
library is essentially done at this point, with only documentation
changes left to be made.
The code compiles again, and it seems to work as it did before. There's
still a lot to do (we still have a mess of globals), but the PE
correctly calls the new DPM functions via the list of callbacks in the
configuration object.
The "storage" source code files contained lots of stuff with "config" in
the name, but nothing named "storage". This was unlike every other part
of the firmware, so I renamed the files to "config".
Until now, the valid configuration object's location was not stored, so
it had to be looked up every time pdb_config_flash_read was called. Now
the valid object's location is stored in config_cur, which is updated
every time the configuration's location changes. This means that
pdb_config_flash_read only has to do the full routine the first time
it's called, or after pdb_config_flash_erase is run. Now other parts of
the configuration won't have to cache the location themselves anymore.
PD uses odd units for voltages and currents. Power too, but we don't
work with power (yet). In the shell, we have to convert to and from
these odd units. We had been doing this in-place every time, which was
a bit crumby. Now it's done with macros in pd.h, making prettier and
more maintainable code.
The command shell is based on the ChibiOS-provided one, but modified to
not run in a new thread and generally be a bit simpler, while also
having PD Buddy branding. The storage functions work with the STM32
flash registers directly, taking over the last page of flash. A new
linker script is used to ensure that program code can't end up using
that page. The DPM has been updated to use the saved settings rather
than hardcoded ones. Now what's needed is real commands for editing the
configuration.
Added commands to edit configuration
We now have commands to load the current settings into RAM, edit the
settings in RAM, and write them back to flash. The only settings
currently supported are current and fixed voltage, because the rest of
the code doesn't support GiveBack or variable/battery PDOs yet.
Short help messages were added for each command. Nothing too exciting,
but it should be a great help for someone poking around in the PD Buddy
Sink configuration shell for the first time.
Wrote new usage information for the firmware
Now that we have a command shell, the README should indicate how to use
it.