Skip to content

Commit

Permalink
boards/schema: Expand scheme, add canonical functions to Pi 5.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Jun 16, 2024
1 parent 97aa0b0 commit 61c77c0
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 18 deletions.
39 changes: 21 additions & 18 deletions boards/raspberry-pi-5.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
"name": "j8",
"width": 2,
"height": 20,
"type": "dupont",
"polarity": "pin",
"pitch": 0.1,
"orientation": 0,
"direction": "alternating",
"pins": [
{"name": "3v3 Power", "type": "power", "subtype": "+3v3"},
{"name": "5v Power", "type": "power", "subtype": "+5v"},
{"name": "GPIO 2", "alt_modes": [
{"name": "GPIO 2", "canonical_mode": 3, "alt_modes": [
{"name": "SPI0_CE3", "type": "SPI"},
{"name": "DPI_VSYNC", "type": "DPI"},
{"name": "CTS1", "type": "UART"},
Expand All @@ -22,7 +25,7 @@
{"name": "SPI2_SIO0", "type": "SPI"}
]},
{"name": "5v Power", "type": "power", "subtype": "+5v"},
{"name": "GPIO 3", "alt_modes": [
{"name": "GPIO 3", "canonical_mode": 3, "alt_modes": [
{"name": "SPI0_CE2", "type": "SPI"},
{"name": "DPI_HSYNC", "type": "DPI"},
{"name": "RTS1", "type": "UART"},
Expand All @@ -34,7 +37,7 @@
{"name": "SPI2_SCLK", "type": "SPI"}
]},
{"name": "Ground", "type": "power", "subtype": "ground"},
{"name": "GPIO 4", "alt_modes": [
{"name": "GPIO 4", "canonical_mode": 0, "alt_modes": [
{"name": "GPCLK0", "type": "GPCLOCK"},
{"name": "DPI_D0", "type": "DPI"},
{"name": "TXD2", "type": "UART"},
Expand All @@ -45,7 +48,7 @@
{"name": "PIO4", "type": "PIO"},
{"name": "SPI3_CE0", "type": "SPI"}
]},
{"name": "GPIO 14", "alt_modes": [
{"name": "GPIO 14", "canonical_mode": 4, "alt_modes": [
{"name": "PWM0_CHAN2", "type": "PWM"},
{"name": "DPI_D10", "type": "DPI"},
{"name": "CTS4", "type": "UART"},
Expand All @@ -56,7 +59,7 @@
{"name": "PIO14", "type": "PIO"}
]},
{"name": "Ground", "type": "power", "subtype": "ground"},
{"name": "GPIO 15", "alt_modes": [
{"name": "GPIO 15", "canonical_mode": 4, "alt_modes": [
{"name": "PWM0_CHAN3", "type": "PWM"},
{"name": "DPI_D11", "type": "DPI"},
{"name": "RTS4", "type": "UART"},
Expand All @@ -78,7 +81,7 @@
{"name": "PIO17", "type": "PIO"},
{"name": "-", "used": false}
]},
{"name": "GPIO 18", "alt_modes": [
{"name": "GPIO 18", "canonical_mode": 2, "alt_modes": [
{"name": "SPI1_CE0", "type": "SPI"},
{"name": "DPI_D14", "type": "DPI"},
{"name": "I2S0_SCLK", "type": "I2S"},
Expand Down Expand Up @@ -135,7 +138,7 @@
{"name": "PIO24", "type": "PIO"},
{"name": "SPI2_CE1", "type": "SPI"}
]},
{"name": "GPIO 10", "alt_modes": [
{"name": "GPIO 10", "canonical_mode": 0, "alt_modes": [
{"name": "SPI0_MOSI", "type": "SPI"},
{"name": "DPI_D6", "type": "DPI"},
{"name": "CTS3", "type": "UART"},
Expand All @@ -147,7 +150,7 @@
{"name": "SPI4_SIO1", "type": "SPI"}
]},
{"name": "Ground", "type": "power", "subtype": "ground"},
{"name": "GPIO 9", "alt_modes": [
{"name": "GPIO 9", "canonical_mode": 0, "alt_modes": [
{"name": "SPI0_MISO", "type": "SPI"},
{"name": "DPI_D5", "type": "DPI"},
{"name": "RXD3", "type": "UART"},
Expand All @@ -169,7 +172,7 @@
{"name": "PIO25", "type": "PIO"},
{"name": "SPI3_CE1", "type": "SPI"}
]},
{"name": "GPIO 11", "alt_modes": [
{"name": "GPIO 11", "canonical_mode": 0, "alt_modes": [
{"name": "SPI0_SCLK", "type": "SPI"},
{"name": "DPI_D7", "type": "DPI"},
{"name": "RTS3", "type": "UART"},
Expand All @@ -180,7 +183,7 @@
{"name": "PIO11", "type": "PIO"},
{"name": "SPI4_SCLK", "type": "SPI"}
]},
{"name": "GPIO 8", "alt_modes": [
{"name": "GPIO 8", "canonical_mode": 0, "alt_modes": [
{"name": "SPI0_CE0", "type": "SPI"},
{"name": "DPI_D4", "type": "DPI"},
{"name": "TXD3", "type": "UART"},
Expand All @@ -192,7 +195,7 @@
{"name": "SPI4_CE0", "type": "SPI"}
]},
{"name": "Ground", "type": "power", "subtype": "ground"},
{"name": "GPIO 7", "alt_modes": [
{"name": "GPIO 7", "canonical_mode": 0, "alt_modes": [
{"name": "SPI0_CE1", "type": "SPI"},
{"name": "DPI_D3", "type": "DPI"},
{"name": "RTS2", "type": "UART"},
Expand All @@ -203,7 +206,7 @@
{"name": "PIO7", "type": "PIO"},
{"name": "SPI3_SCLK", "type": "SPI"}
]},
{"name": "GPIO 0", "alt_modes": [
{"name": "GPIO 0", "canonical_mode": 3, "alt_modes": [
{"name": "SPI0_SIO3", "type": "SPI"},
{"name": "DPI_PCLK", "type": "DPI"},
{"name": "TXD1", "type": "UART"},
Expand All @@ -214,7 +217,7 @@
{"name": "PIO0", "type": "PIO"},
{"name": "SPI2_CE0", "type": "SPI"}
]},
{"name": "GPIO 1", "alt_modes": [
{"name": "GPIO 1", "canonical_mode": 3, "alt_modes": [
{"name": "SPI0_SIO2", "type": "SPI"},
{"name": "DPI_DE", "type": "DPI"},
{"name": "RXD1", "type": "UART"},
Expand Down Expand Up @@ -248,7 +251,7 @@
{"name": "PIO6", "type": "PIO"},
{"name": "SPI3_SIO0", "type": "SPI"}
]},
{"name": "GPIO 12", "alt_modes": [
{"name": "GPIO 12", "canonical_mode": 0, "alt_modes": [
{"name": "PWM0_CHAN0", "type": "PWM"},
{"name": "DPI_D8", "type": "DPI"},
{"name": "TXD4", "type": "UART"},
Expand All @@ -259,7 +262,7 @@
{"name": "PIO12", "type": "PIO"},
{"name": "SPI5_CE0", "type": "SPI"}
]},
{"name": "GPIO 13", "alt_modes": [
{"name": "GPIO 13", "canonical_mode": 1, "alt_modes": [
{"name": "PWM0_CHAN1", "type": "PWM"},
{"name": "DPI_D9", "type": "DPI"},
{"name": "RXD4", "type": "UART"},
Expand All @@ -271,7 +274,7 @@
{"name": "SPI5_SIO1", "type": "SPI"}
]},
{"name": "Ground", "type": "power", "subtype": "ground"},
{"name": "GPIO 19", "alt_modes": [
{"name": "GPIO 19", "canonical_mode": 2, "alt_modes": [
{"name": "SPI1_MISO", "type": "SPI"},
{"name": "DPI_D15", "type": "DPI"},
{"name": "I2S0_WS", "type": "I2S"},
Expand All @@ -293,7 +296,7 @@
{"name": "PIO16", "type": "PIO"},
{"name": "-", "used": false}
]},
{"name": "GPIO 26", "alt_modes": [
{"name": "GPIO 26", "canonical_mode": 2, "alt_modes": [
{"name": "SD0_DAT2", "type": "SDIO"},
{"name": "DPI_D22", "type": "DPI"},
{"name": "I2S0_SDI3", "type": "I2S"},
Expand All @@ -304,7 +307,7 @@
{"name": "PIO26", "type": "PIO"},
{"name": "SPI5_CE1", "type": "SPI"}
]},
{"name": "GPIO 20", "alt_modes": [
{"name": "GPIO 20", "canonical_mode": 2, "alt_modes": [
{"name": "SPI1_MOSI", "type": "SPI"},
{"name": "DPI_D16", "type": "DPI"},
{"name": "I2S0_SDI0", "type": "I2S"},
Expand Down
41 changes: 41 additions & 0 deletions schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Pinout Board Schema

## Basic Requirements

Every board definition needs a `name` and one or more `headers`.

Headers entries are stored in an array and each describe a single, physical
header on a board. For example, the "J8" header (the main 40-pin header) on
a Raspberry Pi.

## Headers

Every header needs some basic info:

* `name` - The name of the header, eg: "J8"
* `width` - The physical width of the header (in pins), eg: 2
* `height` - The physical height of the header (in pins), eg: 20
* `direction` - The direction which pin numbers wrap around the header

Name is self explanatory, but should be the "unfriendly" name, eg: "J8" or
"J8" as written on the board silkscreen or otherwise.

Width and height are usually easy, we tend to describe pin headers as 2x20
or 1x5 and it's assumed you can picture what these are.

You can additionally specify some hints for rendering the header visually:

* `orientation` - The rotational orientation of the header
* `type` - The header type, normally "dupont"

Orientation is vague, but represents the orientation of the header (0, 90,
180 or 270 degrees) in relation to the up orientation of the board.

For example the Pi 5's 2x20 pin J8 header is considered to be orientated at
0 degrees. The original Pi 1's P2 header might be 90 or 270 degrees.

And further information about the specific type and size of the header:

* `type` - Eg: "dupont"
* `polarity` - Either "pin" or "socket"
* `pitch` - The connector pitch in inches
7 changes: 7 additions & 0 deletions schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
valid_pin_types = ["gpio", "power", "nc"]
valid_pin_subtypes = ["+5v", "+3v3", "ground"]

valid_header_types = ["dupont", "jst"]
valid_header_polarity = ["pin", "socket"]

board = {
"type": "object",
"properties": {
Expand All @@ -18,6 +21,9 @@
"height": {"type": "number"},
"orientation": {"type": "number", "enum": valid_orientations},
"direction": {"type": "string", "enum": valid_directions},
"type": {"type": "string", "enum": valid_header_types},
"polarity": {"type": "string", "enum": valid_header_polarity},
"pitch": {"type": "number"},
"pins": {
"type": "array",
"items": {
Expand All @@ -26,6 +32,7 @@
"name": {"type": "string"},
"type": {"type": "string", "enum": valid_pin_types},
"subtype": {"type": "string", "enum": valid_pin_subtypes},
"canonical_mode": {"type": "number"},
"alt_modes": {
"type": "array",
"items": {
Expand Down

0 comments on commit 61c77c0

Please sign in to comment.