Skip to content

Commit

Permalink
Move most documentation to wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelbl committed Jan 6, 2023
1 parent 42d66fe commit ca5a34a
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 105 deletions.
60 changes: 14 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,18 @@

Open-source firmware for USB Power Delivery trigger board based on an FUSB302B power delivery controller and a STM32F030F4 MCU.

![ZY12PDN board](doc/board.jpg)
<img src="doc/board.png" alt="ZY12PDN board" width="600">


## Building
## Building and Uploading

- Clone the project from GitHub
- Open it with Visual Studio Code
- Install the PlatformIO extension
- Click the build icon in the status bar
The firmware is built using Visual Studio Code and the PlatformIO extension.

To upload it, a SWD capable debug probe like ST-Link, J-Link or Black Magic Probe is connected to the four SWD pads on the back side of the board.

## Upload
See [Build and upload](https://github.com/manuelbl/zy12pdn-oss/wiki/Build-and-upload) in the wiki for detailed instructions.

The ZY12PDN board has 4 pads for SWD at the bottom. Either solder wires to them, or use a 4-pin adapter with pogo pins to connect a debug adapter.

![SWD](doc/swd.jpg)

Connect the SWD pads with an ST-Link, J-Link or Black Magic Probe to your computer and click the upload icon in the status bar of Visual Studio Code.

As sold, the boards have flash protection enabled. It can be disabled using *openocd*. Note: This command erases the flash memory:

```
openocd -f interface/stlink.cfg -f target/stm32f0x.cfg -c "init; reset halt; stm32f0x unlock 0; stm32f0x mass_erase 0; reset halt; exit"
```


## Hardware

See [Hardware](doc/hardware.md) for a detailed description of the board and its components (incl. schematic).
<img src="doc/swd.png" alt="ZY12PDN board" width="400">


## Usage Instructions
Expand Down Expand Up @@ -65,36 +48,21 @@ The mode can be selected by pressing the button until the desired voltage or mod
*Note: Even if a fixed voltage above 5V has been selected and the selected voltage can be provided by the power supply, the supply will initially proivde 5V until the target voltage has been successfully negotiated. 5V is also provided at the output of the ZY12PDN board as it is passed through directly. There is no switch (or MOSFET) in between.*


## Supported PD Messages

- *Capabilities*: The source announces the supported voltages (called "capabilities"). The sink must immediately request one of them.
- *Request*: The sink requests a specific voltage and maximum current.
- *Accept*: The source confirms the requested voltage. The new voltage is not ready yet.
- *Reject*: The source rejects the requested voltage.
- *PS_RDY*: The source indicates that the requested voltage has been applied.


## Notes

- If the event type of the `pd_sink` callback is `callback_event::source_caps_changed`, `request_power()` must be called to request a voltage – even if it is 5V. Otherwise the source will reset.
- The firmware is currently limited to the fixed voltages, i.e. pressing the button switches between the fixed voltages. The class `pd_sink` also support *programmable power supply* (PPS) capabilities. But a different user interfaces / modified firmware is needed to actually use them.
- Using the build flag `-D PD_DEBUG`, debugging output can be enabled. In order to see it, you have to solder a wire to PA2 (USART2 TX pin) and connect it to a serial adapter. The baud rate is 115,200 bps (8 bits, 1 stop bit, no parity).
- Since the USB PD protocol is timing sensitive, debug output must not delay normal operation. For that reason, the debug output is written to a circular buffer and then transmitted using non-blocking DMA. Blocking UART operation would introduce delays and violate the timing causing the power supply to reset or even to cut power.
## Documentation

Additional documentation can be found in the [Wiki](https://github.com/manuelbl/zy12pdn-oss/wiki/Hardware-versions):

## Firmware Mode
- [Hardware analysis](https://github.com/manuelbl/zy12pdn-oss/wiki/Hardware-analysis)

The SWDIO line is shared with the interrupt line of the USB PD controller.
- [Hardware versions](https://github.com/manuelbl/zy12pdn-oss/wiki/Hardware-versions)

In order to enable firmware upload, the FUSB302B interrupt is not activated until USB PD activity has been detected. To implement this behavior, the code manually switches between measuring CC1 and CC2 even though the FUSB302B chip could do it automatically.
- [USB PD introduction](https://github.com/manuelbl/zy12pdn-oss/wiki/USB-PD-introduction)

To upload firmware, connect a debug adapter (such as ST-Link or J-Link) to the SWD pads on the bottom of the board and provide power from any source except a USB PD power supply:
- [Software implementation notes](https://github.com/manuelbl/zy12pdn-oss/wiki/Implementation-notes)

- Feed power to the USB connector from a non USB PD power supply
- Feed 3.3V to the VCC pad on the bottom side of the board (e.g. through an older ST-Link adapter)
- Feed 5V to the output terminal
- [Build and Uplaod](https://github.com/manuelbl/zy12pdn-oss/wiki/Build-and-upload)

SWD can be used to upload new firmware. But debugging is only possible until the interrupt pin is activated in code.
- [Debugging hints](https://github.com/manuelbl/zy12pdn-oss/wiki/Debugging-hints)


## Acknowledgements
Expand Down
Binary file removed doc/board.jpg
Binary file not shown.
Binary file added doc/board.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/components.jpg
Binary file not shown.
58 changes: 0 additions & 58 deletions doc/hardware.md

This file was deleted.

1 change: 0 additions & 1 deletion doc/schematic.svg

This file was deleted.

Binary file removed doc/swd.jpg
Binary file not shown.
Binary file added doc/swd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed doc/traces.jpg
Binary file not shown.

0 comments on commit ca5a34a

Please sign in to comment.