Firmware Development notes¶
Power supplies¶
The board contains many power supplies from two power sources.
The USB-C UFP connector provides 5V (100mA max, as it is designed to work when connected to bus-powered USB 2.0 hubs). From this, a 3.3V is derived with a buck converter, which powers most of the system (like the RP2040 and its IOs, and most of the other ICs). Additionally, a configurable voltage, VDUT, is derived through a LDO (1.1-3.5V), which is used to interact with the DUT (UART and buttons) through a I2C IO expander and a level shifter. Finally, the 5V is also used to power a level shifter to interact with the AP33772S and the RGB LED, which require 5V-signals.
The USB-C PD connector provides a configurable voltage with the PPS protocol, managed by the AP33772S and configured by the uC through I2C. This voltage emulates the smartphone’s battery, so it should probably be the voltage of a fully charged battery (e.g., 4.2V for 1-cell, 8.4 for 2-cells). Additionally, a 5V (2A max) is derived from this rail with a buck-boost converter to provide the VBUS of the USB-C DUT and USB-C AUX. The allowed voltage range is 3.3-16V (limited by the recommended input voltage range of the buck-boost converter). To ensure that enough current is available, especially on low voltages (e.g., with 1-cell smartphones), it is recommended to request 5A from the PD source, which however requires a 5A-capable PPS power supply and an e-marked cable.
+3V3¶
The 3.3V is derived from HOST_VBUS by a buck regulator. No action is required to enable this regulator.
VDUT¶
VDUT is a configurable voltage for the interactions with the DUT, derived from HOST_VBUS through a configurable LDO. The voltage is set through 6 signals (VDUT_1.6V, VDUT_800mV, …, VDUT_50mV) and enabled with VDUT_EN. The output voltage is the sum of the voltage of the lines driven low plus 0.5V, in the range 0.5V-3.5V, however the ICs using this rail (the UART level shifter TXS0202 and the I2C expander TCAL6408) require at least 1.1V, so the recommended range is 1.1V-3.5V. The voltage set signals (VDUT_*V) must be driven in a open-drain configuration, either low (to increase the output voltage by the corresponding amount) or left floating. They must not be driven high, as the RP2040’s 3.3V high level is above the absolute maximum ratings of the LDO, and will likely damage it.
VPD¶
VPD is the rail form the USB-C PD connector (after a shunt resistor). At startup, once connected, the AP33772S should request a 5V profile from the power source. To request a different power profile, the device must be configured through I2C, after enabling the host VBUS level shifter (HOST_VBUS_LS_EN). When VPD is up, the PD_UP signal is driven high.
+VBATT¶
VBATT is VPD after the LM73100 ICs (load switches and ideal diodes), routed then to the battery connector. To enable it, once VPD has been configured with the desired voltage and current, the +BATT_EN must be driven high. The current consumed by the DUT can be monitored by reading the voltages on the +BATT_IMON_1 and +BATT_IMON_2, which are proportional with the current flowing across each load switch (271.5 mV/A).
When the PD sink controller detects an anomaly (overvoltage, undervoltage, overcurrent or overtemperature), if enabled (which is the default at power on), it automatically disables the load switches, overriding the uC control. It is recommended to configure the interrupt of the sink controller to also report these conditions to the uC (disabled by default) through a high level on the PD_INT signal.
The LM73100 ICs have an integrated reverse current protection, to act as ideal diodes, immediately opening the switch if +VBATT is over VPD. This is needed to prevent the DUT to “charge” the +VBATT rail, potentially damaging the PPS charger. To ensure that +VBATT stays constant under many conditions (including the recovery time of the switch after the end of a “charge” from the DUT), a large capacitance is attached to the +VBATT rail. To avoid an excessively large discharge time when powered off, an active discharge circuit is attached to the +VBATT line, which should be turned off during normal operation by driving VBATT_DISCH_DIS low. Failure to do so will not damage the device, but will unnecessarily waste power, generate heat and slightly reduce the current available to the DUT.
+5V¶
+5V is the 5V rail derived from VPD. To enable it, once VPD is enabled, drive 5V_EN high. This rail drives the DUT and AUX USB VBUS load switches.
DUT_VBUS and AUX_VBUS¶
USB-C source ports must be able to control the VBUS line, turning it on only when the connected port is a sink one.
The DUT port’s handshake is controlled by a HD3SS3220 (enabled when DUT_EN is driven low), a SS MUX and CC controller. The role of the connected is reported through I2C (device address 0x67, field ATTACHED_STATE): when the state is Attached.SRC, the VBUS line should be turned on by driving DUT_VBUS_EN high, connected to a TPS2065 load switch. The controller is configured to advertise up to 900mA and, when the load switch detects an overcurrent condition, the DUT_VBUS_FAULT is driven low. In such condition, DUT_VBUS_EN must be driven low.
The AUX port’s handshake is instead controlled by a TPS25821, that integrates both a CC controller and a load switch. To enable it, the AUX_EN line must be driven high.
I2C devices¶
Address |
Device |
|---|---|
0x20 (1) |
I2C IO expander |
0x40 |
DUT VBUS voltage and current monitor |
0x47 |
USB UFP (towards the host) SS mux and CC controller |
0x48 |
VDUT and VBATT voltage and current monitor |
0x52 (2) |
USB PD sink controller |
0x67 |
USB DFP (towards the DUT) SS mux and CC controller |
(1) available only when VDUT is up (2) available only when PD_VBUS is up
LEDs¶
There are 8 on-board LEDs to provide visual feedback about the state of the board. From left to right:
PD LED, ON when the PD USB is connected (in particular, when the internal regulator of the AP33772S has brought up the 5V).
Host LED, ON when the host USB is connected (in particular, when the 3.3V buck regulator has brought up the 3.3V).
Battery LED, ON when the uC has commanded the load switches to turn on. To correctly represent the state of the battery connector, the uC should turn this off in case of protection events (overcurrent, overvoltage, …) from the AP33772S.
DUT USB LED, ON when the VBUS of the DUT USB connector is up.
Volume down, Volume up and Power button LEDs, ON when the corresponding button on the DUT has been triggered.
Info RGB LED, to provide generic informations.