The `PDO n:` and `type: blah` lines have now been combined into a single
`PDO n: blah` line. This saves one line per PDO, and still makes plenty
sense.
It prints the most recently advertised PDOs in a reasonable format. The
types it doesn't know about are printed as hex so that someone
knowledgeable can still get the information they need. For now, it only
knows about fixed PDOs, so variable and battery PDOs will be shown as
hex.
Since this means we remember the most recent Source_Capabilities, it's
now becoming possible to send a new Request without sending a
Get_Source_Cap message first. That's not actually done yet, but I'd
like to do it that way. I'd also at some point like to make a
lower-current Request when the PD Buddy Sink's output is disabled, but
again, that's still to come.
Just as specified last night. This represents the completion of a big
part of the new interactive Power Delivery features of the shell.
Next up: printing the source's advertised PDOs.
Update requested power after writing configuration
The PD Buddy Sink now requests new power after configuration is written.
This means that in Setup mode, the voltage and current can be
re-negotiated on the fly. Cool, huh?
It's still impossible to turn the output on and off from the shell. New
commands will allow that soon enough, though. Also, I'm seeing some
weird behavior when switching to/from 5 V (power shuts off entirely
sometimes), but I suspect that's a quirk of the source I'm using (Asus
USB 3.1 UPD Panel) and not the PD Buddy Sink itself. I plan to make or
buy a USB power/data splitter to verify this.
A good first step towards the upcoming 1.1 release, this commit runs the
Power Delivery threads in Setup mode. This required a slight change to
the shell to make it non-blocking, as otherwise the PD threads would
never get to run.
There's still a lot to do! The shell and the PD threads fight over
control of the LED in Setup mode. There's no way to make the PD threads
re-negotiate the required power. There's also no way to turn the output
on or off from the shell. None of these changes should be too major,
but together they'll be pretty cool when they're all done.
The shell main loop function and text input function were dreadfully
devoid of comments. This simply could not continue, so I added a
sprinkling of comments to each, as well as to important sections of the
file. Further, I changed the special character values to look like
characters rather than numbers, which should aid in understanding.
Now the error behavior for set_v and set_i is well-defined by the
documentation: they print nothing on success and an error message on
failure. The range of valid values is now [0, 20000] for set_v and
[0, 5000] for set_i, matching the voltages and currents that can be
provided by USB Power Delivery.
Bumped version number to 1.0.1, reflecting this bugfix.
As the name suggests, it clears all the flags in the configuration
buffer. This provides a way to easily set all the flags to a known
state, which is nice for implementing libraries that configure PD Buddy
Sink devices.
As the name says, it toggles the GiveBack flag in the configuration
buffer. The rest of the firmware doesn't use the flag for anything yet,
but it is correctly saved in flash.
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 configuration interface is done, so we shouldn't have any comments
that say otherwise. Also, since the shell never exits, it's silly to
put the code that runs it in a loop.
The GUI will have a button to identify a particular PD Buddy Sink, in
case several are connected to the computer at once. The button will
cause the LED to blink quickly for a couple seconds, then go back to
normal. To allow this, I added a new LED blink mode (FAST_BLINK_SLOW)
that causes 8 fast blinks, then returns to SLOW_BLINK mode. A new
"identify" command triggers this LED mode.
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.