Loading...
Searching...
No Matches
pins_arduino.h
Go to the documentation of this file.
1
26#pragma once
27
28#include <stdint.h>
29
30// --- Pin counts ----------------------------------------------------------------
31#define PINS_COUNT 23
32#define NUM_DIGITAL_PINS 23
33#define NUM_ANALOG_INPUTS 6
34
36#define NOT_A_GPIO 0xFF
37
39#define PHYDUINO_PIN_TO_GPIO { \
40 1, 0, 6, 7, 8, 9, 10, 15, 16, 17, 13, 11, 12, 14, /* D0-D13 */ \
41 26, 27, 28, /* A0-A2 */ \
42 NOT_A_GPIO, NOT_A_GPIO, NOT_A_GPIO, /* A3-A5 */ \
43 24, 25, /* SDA, SCL */ \
44 5, /* LED */ \
45}
46
47// --- Named pins --------------------------------------------------------------
48#define PIN_A0 (14u)
49#define PIN_A1 (15u)
50#define PIN_A2 (16u)
51#define PIN_A3 (17u)
52#define PIN_A4 (18u)
53#define PIN_A5 (19u)
54
55static const uint8_t A0 = PIN_A0;
56static const uint8_t A1 = PIN_A1;
57static const uint8_t A2 = PIN_A2;
58static const uint8_t A3 = PIN_A3;
59static const uint8_t A4 = PIN_A4;
60static const uint8_t A5 = PIN_A5;
61
62#define PIN_LED (22u)
63#define LED_BUILTIN PIN_LED
64
65// --- Serial1 / Serial2 (UART) -------------------------------------------------
66#define PIN_SERIAL1_TX (1u)
67#define PIN_SERIAL1_RX (0u)
68#define PIN_SERIAL2_TX (4u)
69#define PIN_SERIAL2_RX (5u)
70
71// --- SPI (SPI1 on the header) --------------------------------------------------
72#define PIN_SPI_SS (10u)
73#define PIN_SPI_MOSI (11u)
74#define PIN_SPI_MISO (12u)
75#define PIN_SPI_SCK (13u)
76#define PHYDUINO_SPI_INSTANCE spi1
77
78static const uint8_t SS = PIN_SPI_SS;
79static const uint8_t MOSI = PIN_SPI_MOSI;
80static const uint8_t MISO = PIN_SPI_MISO;
81static const uint8_t SCK = PIN_SPI_SCK;
82
83// --- Wire (I2C0 on the header) -------------------------------------------------
84#define PIN_WIRE_SDA (20u)
85#define PIN_WIRE_SCL (21u)
86#define PHYDUINO_WIRE_INSTANCE i2c0
87
88static const uint8_t SDA = PIN_WIRE_SDA;
89static const uint8_t SCL = PIN_WIRE_SCL;
90
91// --- On-board peripherals (RP2040 GPIO numbers, not Arduino pins) ------------
92// External ADC MAX11635 (U5) on SPI0: feeds A3-A5; AIN3 measures VBUS.
93#define PHYDUINO_EXT_ADC_SPI spi0
94#define PHYDUINO_EXT_ADC_GPIO_SCK 22
95#define PHYDUINO_EXT_ADC_GPIO_MOSI 23
96#define PHYDUINO_EXT_ADC_GPIO_MISO 20
97#define PHYDUINO_EXT_ADC_GPIO_CS 21
98#define PHYDUINO_EXT_ADC_GPIO_EOC 19
99#define PHYDUINO_EXT_ADC_GPIO_CNVST 18
100#define PHYDUINO_EXT_ADC_VREF_MV 2048
101#define PHYDUINO_EXT_ADC_VBUS_CH 3
102
103// USB-PD controller STUSB4500 (U6) on I2C1, address 0x28.
104#define PHYDUINO_USBPD_I2C i2c1
105#define PHYDUINO_USBPD_I2C_ADDR 0x28
106#define PHYDUINO_USBPD_GPIO_SDA 2
107#define PHYDUINO_USBPD_GPIO_SCL 3
108#define PHYDUINO_USBPD_GPIO_ALERT 4
109#define PHYDUINO_USBPD_GPIO_RESET 29
110
112#define PHYDUINO_ADC_VREF_MV 3300
#define PIN_WIRE_SCL
I2C clock: SCL header pin, RP2040 GPIO25.
Definition pins_arduino.h:85
#define PIN_SPI_MISO
SPI MISO: D12.
Definition pins_arduino.h:74
#define PIN_WIRE_SDA
I2C data: SDA header pin, RP2040 GPIO24.
Definition pins_arduino.h:84
#define PIN_SPI_SCK
SPI clock: D13.
Definition pins_arduino.h:75
#define PIN_SPI_MOSI
SPI MOSI: D11.
Definition pins_arduino.h:73
#define PIN_A3
A3, MAX11635 AIN0 (analog only).
Definition pins_arduino.h:51
#define PIN_SPI_SS
SPI chip select: D10 (not driven by the SPI library).
Definition pins_arduino.h:72
#define PIN_A2
A2, RP2040 ADC2.
Definition pins_arduino.h:50
#define PIN_A5
A5, MAX11635 AIN2 (analog only).
Definition pins_arduino.h:53
#define PIN_A1
A1, RP2040 ADC1.
Definition pins_arduino.h:49
#define PIN_A0
A0, RP2040 ADC0.
Definition pins_arduino.h:48
#define PIN_A4
A4, MAX11635 AIN1 (analog only).
Definition pins_arduino.h:52