It's useful to know when only default USB power is available, as opposed
to when some mechanism for negotiating higher power is available but it
isn't possible to get high enough power. This can let users know e.g.
using a USB A to C cable can't provide high power, potentially reducing
confusion.
The blink code for this is 1 7/8 s on, 1/8 s off. I think this is
sufficiently unlike other blink patterns that it won't cause any
confusion.
I took an accurate reading of the current consumed by the PD Buddy Sink
in various states, and found that the lowest current I could safely set
as the amount it requests when the output is turned off was 30 mA.
I therefore changed it to request this lower current to avoid asking for
more than we need.
Another big ChibiOS update, this time to the first stable release in the
18.2.x series. This time a few pieces of API that the firmware and
library used were renamed, so there were some changes that had to be
made there. The build system is nicer now, as the included makefiles
add paths to the necessary variables so the main Makefile is much less
verbose in a few places.
Gavin had trouble with configuration because it isn't loaded on startup.
I realized that I've been caught with the same mistake myself before, so
since at least 2 out of ~65 people have done this, it's clearly a real
usability problem.
Now the configuration is automatically loaded from flash when setup mode
starts, so there's no need to type `load` to edit the configuration the
Sink already has. If you're changing all the settings, you'll have to
type them all anyway, so I don't think there will be any surprises
because of this change.
A new bit was added to the Source Fixed Supply PDO in PD 3.0, saying
whether the source supports unchunked extended messages. It's not
really relevant to the PD Buddy Sink since it itself doesn't support
them, but users might want to know and it's very little work to print
it, so now it does.
It needs to be if I want to be able to have several ports controlled by
one MCU. It's set as part of the FUSB configuration, not in the INT_N
struct, since the latter isn't user-initialized and may disappear
entirely in the future.
Technically I updated to a development version somewhere between 17.6.3
and 17.6.4, but I don't doubt its stability.
This is a good update because I'd like users of the library to be
confident that it works with the latest version of ChibiOS.
Interestingly, none of the changes I made were in the library code, so
it did before, but now I know for sure.
I'm unclear as to whether I can now get rid of the INT_N thread in favor
of a pin interrupt. I'll have to see if I can, or if that will have to
wait for still more ChibiOS updates.
After much poking around, I finally figured out how to make this work!
The problem was that the ChibiOS initialization code had disabled
interrupts before the __early_init function was run, making the
bootloader not work despite my best intentions. This was fixed by
enabling interrupts just before jumping to the bootloader. This in turn
required changing to GNU-flavored C11 to include an inline assembly
instruction.
Due to an error when adding the different current definition types, the
flags configuration field never said (none). Now it does once again,
and there's no trailing space when printing flags.
This commit adds support for configuring the current requested from the
power supply in the form of a resistance. This is useful for powering
resistive loads when a voltage range is configured.
Previously, we didn't make use of the voltage range when checking a
Type-C Current advertisement. That was bad, since if e.g. we want 6 V,
with the range 5-7 V, we could get the power we want from Type-C
Current.
This commit makes the firmware test if the configured voltage range
contains 5 V, and if it does, allows use of Type-C Current.
Now the DPM tests if the configuration holds a current or a power, and
if it's a power, it calculates current at the necessary voltage(s) based
on that power. This is used when making requests, when advertising our
Sink_Capabilities, and when checking Type-C Current advertisements.
Previously, the PDO attribute getter macros took a capabilities message
and the PDO index. This worked in a lot of cases, but not in some I
need now, and there was little advantage to them working they way they
did anyway. Now they take just the PDO itself, which is more intuitive
and more useful.
This commit adds the `set_p` command for setting power, and the `p`
configuration field for reading it back. There is no support for making
requests based on power yet (the field is still interpreted as a current
unconditionally).
Now when we make a request from a voltage range, if the HV_Preferred
flag is enabled, we iterate over the PDOs backwards, so we see
higher-voltage fixed supply PDOs before lower-voltage ones. This causes
the flag to do what it's supposed to.
The code to find a PDO from the range has been factored out into its own
function which will be used when building a Sink_Capabilities message.
Requests for fixed voltages are now made from the voltage range. This
isn't a terrible behavior, but I might want to be able to make requests
from programmable supplies from the range as well. 'Twould be more
complicated though, and provide comparitively little benefit. I'll
think about it, and maybe put out a request for comments.
This state requires that the DPM be informed of the receipt of a
Not_Supported message. Some DPMs may not need to do this, so the new
dpm.not_supported_received function is optional.
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.
Due to a typo, it would clear all bits except the HV_Preferred bit.
This commit fixes the bug, and refactors the clearing code to make typos
like this harder to make.
Firmware 1.2.0 will have more configuration flags than previous
versions. This commit adds macros for those flags. There's also a
field added to the flags halfword that says whether a current, power, or
resistance is configured, so this commit makes the clear_flags command
not modify that field.
The new tempate variable sets the data role, power role, and
specification revision in one fell swoop. It's used by the PE and DPM
alike for creating messages, and in the future it may have a part in
determining if we're doing PD 2.0 or 3.0.
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.
This commit splits the old messages.h file into two, one private
(messages.h) and one public (pdb_msg.h). This new arrangement keeps the
old model of one message pool for all the PD Buddy firmware library, but
moves the macro for the number of objects it contains into a new file,
pdb_conf.h, placed at the project root. The pool itself is kept in the
new pdb_msg.h file, since the DPM may need to access it.
The new configuration file also contains the stack sizes for the PD
Buddy threads (some will be moved back to secrecy in the future once the
needed sizes are known, but the PE's stack size should be kept in
pdb_conf.h since user code needs that stack).
To do this, a couple of the events had to have their definitions moved
to lib/include/pdb_pe.h. This isn't a problem in and of itself, but if
more internal-use events are added to policy_engine.h there could be
trouble. To mitigate this, I added a comment as a reminder to make sure
any new events don't overlap the public ones defined elsewhere.
Not the static globals yet, just the public ones. I suppose this change
isn't technically necessary since the PD Buddy Sink is a single-port
device, but I want its firmware to be a shining example of how to use
the library.