@typecad/mcu-esp32s3 0.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +43 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +296 -0
- package/dist/peripherals.d.ts +58 -0
- package/dist/peripherals.js +73 -0
- package/dist/pins.d.ts +62 -0
- package/dist/pins.js +76 -0
- package/package.json +60 -0
- package/src/index.ts +343 -0
- package/src/peripherals.ts +103 -0
- package/src/pins.ts +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 typecad0
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# @typecad/mcu-esp32s3
|
|
2
|
+
|
|
3
|
+
MCU definition package for the **ESP32-S3** (dual-core Xtensa LX7 @ 240 MHz, Wi-Fi 4 + BLE 5, native USB-OTG). Provides datasheet-level pin definitions, hardware peripheral descriptions, and HAL instances used by the TypeCAD transpiler and board packages.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
MCU packages are the silicon layer — they define what pins exist on the chip and what peripherals are built into the silicon, independent of any board or framework. Board packages (e.g. [`@typecad/board-esp32s3`](../board-esp32s3)) import from here and add board-specific aliases.
|
|
8
|
+
|
|
9
|
+
## What's inside
|
|
10
|
+
|
|
11
|
+
- **`src/pins.ts`** — One `Pin.fromPort()` export per GPIO: `GPIO0`–`GPIO48`
|
|
12
|
+
- **`src/peripherals.ts`** — Hardware peripheral descriptions (I2C, SPI, UART, ADC, timers, PWM) and auto-generated HAL instances (`I2C0`, `SPI0`, `UART0`, `ADC`)
|
|
13
|
+
- **`src/mcu.ts`** — `MCU_PERIPHERALS` manifest consumed by board packages
|
|
14
|
+
|
|
15
|
+
## ESP32-S3 peripheral summary
|
|
16
|
+
|
|
17
|
+
| Peripheral | Count | Notes |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| **UART** | 3 | USART0–2 |
|
|
20
|
+
| **I2C** | 2 | I2C0–1 (GPIO matrix) |
|
|
21
|
+
| **SPI** | 4 | SPI0–3 |
|
|
22
|
+
| **ADC** | 2 | ADC1 (10 channels), ADC2 (10 channels), 12-bit |
|
|
23
|
+
| **Timers** | 4 | 64-bit general-purpose timers |
|
|
24
|
+
| **PWM (LEDC)** | 8 channels | 4 high-speed + 4 low-speed |
|
|
25
|
+
| **USB-OTG** | 1 | Native USB 2.0 full-speed PHY |
|
|
26
|
+
|
|
27
|
+
## How board packages use this
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// In @typecad/board-esp32s3
|
|
31
|
+
export * from '@typecad/mcu-esp32s3'; // silicon pins + peripherals
|
|
32
|
+
export * from '@typecad/hal'; // HAL utilities (delay, Pin, etc.)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Related packages
|
|
36
|
+
|
|
37
|
+
- [`@typecad/board-esp32s3`](../board-esp32s3) — board package using this MCU
|
|
38
|
+
- [`@typecad/hal`](../hal) — hardware abstraction layer
|
|
39
|
+
- [`@typecad/mcu-atmega328p`](../mcu-atmega328p) — example of a fully-documented MCU package
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MCUDefinition } from '@typecad/cuttlefish/api/schema';
|
|
2
|
+
export declare const ESP32S3: MCUDefinition;
|
|
3
|
+
export default ESP32S3;
|
|
4
|
+
export * from './pins.js';
|
|
5
|
+
export * from './peripherals.js';
|
|
6
|
+
/**
|
|
7
|
+
* Structured manifest consumed by the TypeCAD CLI for contract-based
|
|
8
|
+
* board generation. Provides pin names and peripheral instance names
|
|
9
|
+
* without requiring the CLI to text-scrape compiled output.
|
|
10
|
+
*/
|
|
11
|
+
export declare const TypeCADManifest: {
|
|
12
|
+
/** All MCU port-level pin names (e.g. 'GPIO0', 'GPIO1'). */
|
|
13
|
+
readonly pinNames: readonly ["GPIO0", "GPIO1", "GPIO2", "GPIO3", "GPIO4", "GPIO5", "GPIO6", "GPIO7", "GPIO8", "GPIO9", "GPIO10", "GPIO11", "GPIO12", "GPIO13", "GPIO14", "GPIO15", "GPIO16", "GPIO17", "GPIO18", "GPIO19", "GPIO20", "GPIO21", "GPIO26", "GPIO27", "GPIO28", "GPIO29", "GPIO30", "GPIO31", "GPIO32", "GPIO33", "GPIO34", "GPIO35", "GPIO36", "GPIO37", "GPIO38", "GPIO39", "GPIO40", "GPIO41", "GPIO42", "GPIO43", "GPIO44", "GPIO45", "GPIO46", "GPIO47", "GPIO48"];
|
|
14
|
+
/** All HAL peripheral instance names exported from this package. */
|
|
15
|
+
readonly peripheralNames: readonly ["I2C0", "I2C1", "SPI0", "SPI1", "UART0", "UART1", "UART2"];
|
|
16
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// @typecad/mcu-esp32s3 — MCU definition manifest
|
|
3
|
+
//
|
|
4
|
+
// ESP32-S3 is dual-core Xtensa LX7 @ 240 MHz with Wi-Fi 4 + BLE 5 and native
|
|
5
|
+
// USB-OTG. It has 45 GPIO (0-21, 26-48); GPIO 22-25 and 32-37 do NOT exist on
|
|
6
|
+
// the S3 (different pad layout from classic ESP32). All GPIOs are bidirectional
|
|
7
|
+
// (no input-only pins). DAC was removed on the S3.
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
import { MCU_PERIPHERALS } from './peripherals.js';
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Default capability flags for ESP32-S3
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
const NO = false;
|
|
14
|
+
const YES = true;
|
|
15
|
+
/** Full GPIO: digital I/O + pull-up + pull-down + PWM + interrupt. */
|
|
16
|
+
const FULL_GPIO = {
|
|
17
|
+
digitalInput: YES, digitalOutput: YES,
|
|
18
|
+
analogInput: NO, analogOutput: NO,
|
|
19
|
+
pwm: YES, interrupt: YES,
|
|
20
|
+
pullUp: YES, pullDown: YES,
|
|
21
|
+
touch: NO, openDrain: NO,
|
|
22
|
+
};
|
|
23
|
+
/** Full GPIO + analog input (ADC). */
|
|
24
|
+
const FULL_GPIO_ANALOG = { ...FULL_GPIO, analogInput: YES };
|
|
25
|
+
/** Full GPIO + analog input + touch. */
|
|
26
|
+
const FULL_GPIO_ANALOG_TOUCH = { ...FULL_GPIO, analogInput: YES, touch: YES };
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Helper: build ADC/touch peripheral-function references.
|
|
29
|
+
//
|
|
30
|
+
// ADC1 channels: GPIO1..GPIO10 -> ch0..ch9 (always usable).
|
|
31
|
+
// ADC2 channels: GPIO11..GPIO20 -> ch0..ch9 (NOT usable while Wi-Fi is on).
|
|
32
|
+
// Touch channels: GPIO1..GPIO14 -> T1..T14.
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
function adc(n, ch) {
|
|
35
|
+
return { type: 'adc', instance: n, role: `ch${ch}` };
|
|
36
|
+
}
|
|
37
|
+
function touch(ch) {
|
|
38
|
+
return { type: 'touch', instance: 0, role: `touch${ch}` };
|
|
39
|
+
}
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// MCU definition
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
export const ESP32S3 = {
|
|
44
|
+
id: 'esp32-s3',
|
|
45
|
+
name: 'ESP32-S3',
|
|
46
|
+
architecture: 'esp32s3',
|
|
47
|
+
memory: {
|
|
48
|
+
flash: 384 * 1024, // usable app flash; remainder reserved by bootloader/OTADATA
|
|
49
|
+
sram: 512 * 1024, // 512 KB
|
|
50
|
+
eeprom: 0,
|
|
51
|
+
rtcMemory: 16 * 1024, // 16 KB RTC slow memory
|
|
52
|
+
},
|
|
53
|
+
pins: {
|
|
54
|
+
all: [
|
|
55
|
+
// ---- Boot strapping pins (unsafe) ------------------------------------
|
|
56
|
+
{ number: 0, gpio: 0, name: 'GPIO0', capabilities: FULL_GPIO_ANALOG,
|
|
57
|
+
functions: [adc(1, 0), touch(1)],
|
|
58
|
+
alternateFunctions: ['ADC1_CH0', 'Touch1'],
|
|
59
|
+
warnings: ['GPIO0 is a strapping pin — must be HIGH at boot for normal flash boot; LOW enters download mode'],
|
|
60
|
+
unsafe: true, notes: 'Boot strapping pin' },
|
|
61
|
+
{ number: 1, gpio: 1, name: 'GPIO1', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
62
|
+
functions: [adc(1, 1), touch(2)],
|
|
63
|
+
alternateFunctions: ['ADC1_CH1', 'Touch2'] },
|
|
64
|
+
{ number: 2, gpio: 2, name: 'GPIO2', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
65
|
+
functions: [adc(1, 2), touch(3)],
|
|
66
|
+
alternateFunctions: ['ADC1_CH2', 'Touch3'] },
|
|
67
|
+
{ number: 3, gpio: 3, name: 'GPIO3', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
68
|
+
functions: [adc(1, 3), touch(4)],
|
|
69
|
+
alternateFunctions: ['ADC1_CH3', 'Touch4'],
|
|
70
|
+
warnings: ['GPIO3 is a strapping pin — controls JTAG signal source at boot'],
|
|
71
|
+
unsafe: true, notes: 'Boot strapping pin' },
|
|
72
|
+
{ number: 4, gpio: 4, name: 'GPIO4', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
73
|
+
functions: [adc(1, 4), touch(5)],
|
|
74
|
+
alternateFunctions: ['ADC1_CH4', 'Touch5'] },
|
|
75
|
+
{ number: 5, gpio: 5, name: 'GPIO5', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
76
|
+
functions: [adc(1, 5), touch(6)],
|
|
77
|
+
alternateFunctions: ['ADC1_CH5', 'Touch6'] },
|
|
78
|
+
{ number: 6, gpio: 6, name: 'GPIO6', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
79
|
+
functions: [adc(1, 6), touch(7)],
|
|
80
|
+
alternateFunctions: ['ADC1_CH6', 'Touch7'] },
|
|
81
|
+
{ number: 7, gpio: 7, name: 'GPIO7', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
82
|
+
functions: [adc(1, 7), touch(8)],
|
|
83
|
+
alternateFunctions: ['ADC1_CH7', 'Touch8'] },
|
|
84
|
+
{ number: 8, gpio: 8, name: 'GPIO8', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
85
|
+
functions: [adc(1, 8), touch(9), { type: 'i2c', instance: 0, role: 'sda' }],
|
|
86
|
+
alternateFunctions: ['ADC1_CH8', 'Touch9', 'I2C0 SDA'],
|
|
87
|
+
warnings: ['Using GPIO8 as GPIO will interfere with I2C0 SDA'] },
|
|
88
|
+
{ number: 9, gpio: 9, name: 'GPIO9', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
89
|
+
functions: [adc(1, 9), touch(10), { type: 'i2c', instance: 0, role: 'scl' }],
|
|
90
|
+
alternateFunctions: ['ADC1_CH9', 'Touch10', 'I2C0 SCL'],
|
|
91
|
+
warnings: ['Using GPIO9 as GPIO will interfere with I2C0 SCL'] },
|
|
92
|
+
{ number: 10, gpio: 10, name: 'GPIO10', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
93
|
+
functions: [adc(1, 10), touch(11)],
|
|
94
|
+
alternateFunctions: ['ADC1_CH10', 'Touch11'] },
|
|
95
|
+
{ number: 11, gpio: 11, name: 'GPIO11', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
96
|
+
functions: [adc(2, 0), touch(12), { type: 'spi', instance: 0, role: 'sck' }],
|
|
97
|
+
alternateFunctions: ['ADC2_CH0', 'Touch12', 'FSPI SCK'],
|
|
98
|
+
warnings: ['GPIO11 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
99
|
+
{ number: 12, gpio: 12, name: 'GPIO12', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
100
|
+
functions: [adc(2, 1), touch(13), { type: 'spi', instance: 0, role: 'mosi' }],
|
|
101
|
+
alternateFunctions: ['ADC2_CH1', 'Touch13', 'FSPI MOSI'],
|
|
102
|
+
warnings: ['GPIO12 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
103
|
+
{ number: 13, gpio: 13, name: 'GPIO13', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
104
|
+
functions: [adc(2, 2), touch(14), { type: 'spi', instance: 0, role: 'miso' }],
|
|
105
|
+
alternateFunctions: ['ADC2_CH2', 'Touch14', 'FSPI MISO'],
|
|
106
|
+
warnings: ['GPIO13 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
107
|
+
{ number: 14, gpio: 14, name: 'GPIO14', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
108
|
+
functions: [adc(2, 3)],
|
|
109
|
+
alternateFunctions: ['ADC2_CH3'],
|
|
110
|
+
warnings: ['GPIO14 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
111
|
+
{ number: 15, gpio: 15, name: 'GPIO15', capabilities: FULL_GPIO_ANALOG,
|
|
112
|
+
functions: [adc(2, 4)],
|
|
113
|
+
alternateFunctions: ['ADC2_CH4'],
|
|
114
|
+
warnings: ['GPIO15 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
115
|
+
{ number: 16, gpio: 16, name: 'GPIO16', capabilities: FULL_GPIO_ANALOG,
|
|
116
|
+
functions: [adc(2, 5)],
|
|
117
|
+
alternateFunctions: ['ADC2_CH5'],
|
|
118
|
+
warnings: ['GPIO16 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
119
|
+
{ number: 17, gpio: 17, name: 'GPIO17', capabilities: FULL_GPIO_ANALOG,
|
|
120
|
+
functions: [adc(2, 6)],
|
|
121
|
+
alternateFunctions: ['ADC2_CH6'],
|
|
122
|
+
warnings: ['GPIO17 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
123
|
+
{ number: 18, gpio: 18, name: 'GPIO18', capabilities: FULL_GPIO_ANALOG,
|
|
124
|
+
functions: [adc(2, 7)],
|
|
125
|
+
alternateFunctions: ['ADC2_CH7'],
|
|
126
|
+
warnings: ['GPIO18 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
127
|
+
{ number: 19, gpio: 19, name: 'GPIO19', capabilities: FULL_GPIO_ANALOG,
|
|
128
|
+
functions: [adc(2, 8), { type: 'usb', instance: 0, role: 'dm' }],
|
|
129
|
+
alternateFunctions: ['ADC2_CH8', 'USB D-'],
|
|
130
|
+
warnings: ['GPIO19 is USB D- — using it as GPIO disables native USB', 'GPIO19 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'],
|
|
131
|
+
unsafe: true, notes: 'USB D- pin' },
|
|
132
|
+
{ number: 20, gpio: 20, name: 'GPIO20', capabilities: FULL_GPIO_ANALOG,
|
|
133
|
+
functions: [adc(2, 9), { type: 'usb', instance: 0, role: 'dp' }],
|
|
134
|
+
alternateFunctions: ['ADC2_CH9', 'USB D+'],
|
|
135
|
+
warnings: ['GPIO20 is USB D+ — using it as GPIO disables native USB', 'GPIO20 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'],
|
|
136
|
+
unsafe: true, notes: 'USB D+ pin' },
|
|
137
|
+
{ number: 21, gpio: 21, name: 'GPIO21', capabilities: FULL_GPIO,
|
|
138
|
+
alternateFunctions: [] },
|
|
139
|
+
// ---- GPIO 22-25 do NOT exist on the ESP32-S3 -------------------------
|
|
140
|
+
// ---- GPIO 26-32 connected to SPI flash / PSRAM (unsafe) ---------------
|
|
141
|
+
{ number: 26, gpio: 26, name: 'GPIO26', capabilities: FULL_GPIO,
|
|
142
|
+
alternateFunctions: ['SPICS1'],
|
|
143
|
+
warnings: ['GPIO26 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
144
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
145
|
+
{ number: 27, gpio: 27, name: 'GPIO27', capabilities: FULL_GPIO,
|
|
146
|
+
alternateFunctions: ['SPIHD'],
|
|
147
|
+
warnings: ['GPIO27 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
148
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
149
|
+
{ number: 28, gpio: 28, name: 'GPIO28', capabilities: FULL_GPIO,
|
|
150
|
+
alternateFunctions: ['SPIWP'],
|
|
151
|
+
warnings: ['GPIO28 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
152
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
153
|
+
{ number: 29, gpio: 29, name: 'GPIO29', capabilities: FULL_GPIO,
|
|
154
|
+
alternateFunctions: ['SPICS0'],
|
|
155
|
+
warnings: ['GPIO29 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
156
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
157
|
+
{ number: 30, gpio: 30, name: 'GPIO30', capabilities: FULL_GPIO,
|
|
158
|
+
alternateFunctions: ['SPICLK'],
|
|
159
|
+
warnings: ['GPIO30 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
160
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
161
|
+
{ number: 31, gpio: 31, name: 'GPIO31', capabilities: FULL_GPIO,
|
|
162
|
+
alternateFunctions: ['SPIQ'],
|
|
163
|
+
warnings: ['GPIO31 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
164
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
165
|
+
{ number: 32, gpio: 32, name: 'GPIO32', capabilities: FULL_GPIO,
|
|
166
|
+
alternateFunctions: ['SPID'],
|
|
167
|
+
warnings: ['GPIO32 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
168
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
169
|
+
// ---- GPIO 33-37 connected to octal PSRAM on PSRAM modules -----------
|
|
170
|
+
{ number: 33, gpio: 33, name: 'GPIO33', capabilities: FULL_GPIO,
|
|
171
|
+
alternateFunctions: ['SPIIO4'],
|
|
172
|
+
warnings: ['GPIO33 is connected to octal PSRAM on some modules — verify before use'],
|
|
173
|
+
unsafe: true, notes: 'Octal SPI/PSRAM pin on PSRAM modules' },
|
|
174
|
+
{ number: 34, gpio: 34, name: 'GPIO34', capabilities: FULL_GPIO,
|
|
175
|
+
alternateFunctions: ['SPIIO5'],
|
|
176
|
+
warnings: ['GPIO34 is connected to octal PSRAM on some modules — verify before use'],
|
|
177
|
+
unsafe: true, notes: 'Octal SPI/PSRAM pin on PSRAM modules' },
|
|
178
|
+
{ number: 35, gpio: 35, name: 'GPIO35', capabilities: FULL_GPIO,
|
|
179
|
+
alternateFunctions: ['SPIIO6'],
|
|
180
|
+
warnings: ['GPIO35 is connected to octal PSRAM on some modules — verify before use'],
|
|
181
|
+
unsafe: true, notes: 'Octal SPI/PSRAM pin on PSRAM modules' },
|
|
182
|
+
{ number: 36, gpio: 36, name: 'GPIO36', capabilities: FULL_GPIO,
|
|
183
|
+
alternateFunctions: ['SPIIO7'],
|
|
184
|
+
warnings: ['GPIO36 is connected to octal PSRAM on some modules — verify before use'],
|
|
185
|
+
unsafe: true, notes: 'Octal SPI/PSRAM pin on PSRAM modules' },
|
|
186
|
+
{ number: 37, gpio: 37, name: 'GPIO37', capabilities: FULL_GPIO,
|
|
187
|
+
alternateFunctions: ['SPIDQS'],
|
|
188
|
+
warnings: ['GPIO37 is connected to octal PSRAM on some modules — verify before use'],
|
|
189
|
+
unsafe: true, notes: 'Octal SPI/PSRAM pin on PSRAM modules' },
|
|
190
|
+
{ number: 38, gpio: 38, name: 'GPIO38', capabilities: FULL_GPIO,
|
|
191
|
+
alternateFunctions: [] },
|
|
192
|
+
{ number: 39, gpio: 39, name: 'GPIO39', capabilities: FULL_GPIO,
|
|
193
|
+
alternateFunctions: ['MTCK'] },
|
|
194
|
+
{ number: 40, gpio: 40, name: 'GPIO40', capabilities: FULL_GPIO,
|
|
195
|
+
alternateFunctions: ['MTDO'] },
|
|
196
|
+
{ number: 41, gpio: 41, name: 'GPIO41', capabilities: FULL_GPIO,
|
|
197
|
+
alternateFunctions: ['MTDI'] },
|
|
198
|
+
{ number: 42, gpio: 42, name: 'GPIO42', capabilities: FULL_GPIO,
|
|
199
|
+
alternateFunctions: ['MTMS'] },
|
|
200
|
+
// ---- UART0 default pins ----------------------------------------------
|
|
201
|
+
{ number: 43, gpio: 43, name: 'GPIO43', capabilities: FULL_GPIO,
|
|
202
|
+
functions: [{ type: 'uart', instance: 0, role: 'tx' }],
|
|
203
|
+
alternateFunctions: ['UART0 TX'],
|
|
204
|
+
warnings: ['Using GPIO43 as GPIO will interfere with UART0 transmit'] },
|
|
205
|
+
{ number: 44, gpio: 44, name: 'GPIO44', capabilities: FULL_GPIO,
|
|
206
|
+
functions: [{ type: 'uart', instance: 0, role: 'rx' }],
|
|
207
|
+
alternateFunctions: ['UART0 RX'],
|
|
208
|
+
warnings: ['Using GPIO44 as GPIO will interfere with UART0 receive'] },
|
|
209
|
+
{ number: 45, gpio: 45, name: 'GPIO45', capabilities: FULL_GPIO,
|
|
210
|
+
alternateFunctions: [],
|
|
211
|
+
warnings: ['GPIO45 is a strapping pin — sets VDD_SPI voltage at boot'],
|
|
212
|
+
unsafe: true, notes: 'Boot strapping pin' },
|
|
213
|
+
{ number: 46, gpio: 46, name: 'GPIO46', capabilities: FULL_GPIO,
|
|
214
|
+
alternateFunctions: [],
|
|
215
|
+
warnings: ['GPIO46 is a strapping pin — controls boot mode at boot'],
|
|
216
|
+
unsafe: true, notes: 'Boot strapping pin' },
|
|
217
|
+
{ number: 47, gpio: 47, name: 'GPIO47', capabilities: FULL_GPIO,
|
|
218
|
+
alternateFunctions: ['RGB_DATA'] },
|
|
219
|
+
{ number: 48, gpio: 48, name: 'GPIO48', capabilities: FULL_GPIO,
|
|
220
|
+
alternateFunctions: ['RGB_DATA', 'Onboard LED (DevKitC-1)'],
|
|
221
|
+
onboardLed: true },
|
|
222
|
+
],
|
|
223
|
+
digital: [
|
|
224
|
+
'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
|
|
225
|
+
'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
|
|
226
|
+
'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
|
|
227
|
+
'GPIO26', 'GPIO27', 'GPIO28', 'GPIO29', 'GPIO30', 'GPIO31', 'GPIO32',
|
|
228
|
+
'GPIO33', 'GPIO34', 'GPIO35', 'GPIO36', 'GPIO37', 'GPIO38', 'GPIO39',
|
|
229
|
+
'GPIO40', 'GPIO41', 'GPIO42', 'GPIO43', 'GPIO44', 'GPIO45', 'GPIO46',
|
|
230
|
+
'GPIO47', 'GPIO48',
|
|
231
|
+
],
|
|
232
|
+
analog: [
|
|
233
|
+
'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7', 'GPIO8',
|
|
234
|
+
'GPIO9', 'GPIO10', // ADC1
|
|
235
|
+
'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14', 'GPIO15',
|
|
236
|
+
'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', // ADC2
|
|
237
|
+
],
|
|
238
|
+
pwm: [
|
|
239
|
+
'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
|
|
240
|
+
'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
|
|
241
|
+
'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
|
|
242
|
+
'GPIO38', 'GPIO39', 'GPIO40', 'GPIO41', 'GPIO42', 'GPIO43', 'GPIO44',
|
|
243
|
+
'GPIO45', 'GPIO46', 'GPIO47', 'GPIO48',
|
|
244
|
+
],
|
|
245
|
+
unsafe: [
|
|
246
|
+
'GPIO0', 'GPIO3', 'GPIO19', 'GPIO20',
|
|
247
|
+
'GPIO26', 'GPIO27', 'GPIO28', 'GPIO29', 'GPIO30', 'GPIO31', 'GPIO32',
|
|
248
|
+
'GPIO33', 'GPIO34', 'GPIO35', 'GPIO36', 'GPIO37',
|
|
249
|
+
'GPIO45', 'GPIO46',
|
|
250
|
+
],
|
|
251
|
+
i2c: { 0: { sda: 'GPIO8', scl: 'GPIO9' } },
|
|
252
|
+
spi: {
|
|
253
|
+
0: { mosi: 'GPIO12', miso: 'GPIO13', sck: 'GPIO11', cs: 'GPIO10' }, // FSPI
|
|
254
|
+
},
|
|
255
|
+
uart: {
|
|
256
|
+
0: { tx: 'GPIO43', rx: 'GPIO44' },
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
// ----- Peripherals -------------------------------------------------------
|
|
260
|
+
peripherals: MCU_PERIPHERALS,
|
|
261
|
+
features: {
|
|
262
|
+
multicore: true,
|
|
263
|
+
coreCount: 2,
|
|
264
|
+
deepSleep: true,
|
|
265
|
+
watchdog: true,
|
|
266
|
+
externalInterrupts: true,
|
|
267
|
+
hardwareRng: true,
|
|
268
|
+
fpu: true,
|
|
269
|
+
},
|
|
270
|
+
build: {
|
|
271
|
+
extraFlags: [],
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
export default ESP32S3;
|
|
275
|
+
// Re-exports
|
|
276
|
+
export * from './pins.js';
|
|
277
|
+
export * from './peripherals.js';
|
|
278
|
+
/**
|
|
279
|
+
* Structured manifest consumed by the TypeCAD CLI for contract-based
|
|
280
|
+
* board generation. Provides pin names and peripheral instance names
|
|
281
|
+
* without requiring the CLI to text-scrape compiled output.
|
|
282
|
+
*/
|
|
283
|
+
export const TypeCADManifest = {
|
|
284
|
+
/** All MCU port-level pin names (e.g. 'GPIO0', 'GPIO1'). */
|
|
285
|
+
pinNames: [
|
|
286
|
+
'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
|
|
287
|
+
'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
|
|
288
|
+
'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
|
|
289
|
+
'GPIO26', 'GPIO27', 'GPIO28', 'GPIO29', 'GPIO30', 'GPIO31', 'GPIO32',
|
|
290
|
+
'GPIO33', 'GPIO34', 'GPIO35', 'GPIO36', 'GPIO37', 'GPIO38', 'GPIO39',
|
|
291
|
+
'GPIO40', 'GPIO41', 'GPIO42', 'GPIO43', 'GPIO44', 'GPIO45', 'GPIO46',
|
|
292
|
+
'GPIO47', 'GPIO48',
|
|
293
|
+
],
|
|
294
|
+
/** All HAL peripheral instance names exported from this package. */
|
|
295
|
+
peripheralNames: ['I2C0', 'I2C1', 'SPI0', 'SPI1', 'UART0', 'UART1', 'UART2'],
|
|
296
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { PeripheralInstance, ADCDefinition, PWMDefinition, TimerDefinition } from '@typecad/cuttlefish/api/schema';
|
|
2
|
+
import { I2CBus, SPIBus, SerialPort } from '@typecad/hal';
|
|
3
|
+
export declare const I2C_INSTANCES: readonly PeripheralInstance[];
|
|
4
|
+
export declare const SPI_INSTANCES: readonly PeripheralInstance[];
|
|
5
|
+
export declare const UART_INSTANCES: readonly PeripheralInstance[];
|
|
6
|
+
export declare const ADC_INSTANCES: readonly ADCDefinition[];
|
|
7
|
+
export declare const PWM_CAPABILITIES: PWMDefinition;
|
|
8
|
+
export declare const TOUCH_CAPABILITIES: {
|
|
9
|
+
channels: number;
|
|
10
|
+
pins: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare const TIMER_INSTANCES: readonly TimerDefinition[];
|
|
13
|
+
export declare const WIFI_CAPABILITIES: {
|
|
14
|
+
readonly type: "wifi";
|
|
15
|
+
readonly supportsStation: true;
|
|
16
|
+
readonly supportsAp: true;
|
|
17
|
+
};
|
|
18
|
+
export declare const BLUETOOTH_CAPABILITIES: {
|
|
19
|
+
readonly type: "ble";
|
|
20
|
+
readonly version: "5.0";
|
|
21
|
+
};
|
|
22
|
+
export declare const USB_CAPABILITIES: {
|
|
23
|
+
readonly type: "otg";
|
|
24
|
+
readonly vid: "0x303A";
|
|
25
|
+
readonly pid: "0x0001";
|
|
26
|
+
};
|
|
27
|
+
export declare const MCU_PERIPHERALS: {
|
|
28
|
+
readonly i2c: readonly PeripheralInstance[];
|
|
29
|
+
readonly spi: readonly PeripheralInstance[];
|
|
30
|
+
readonly uart: readonly PeripheralInstance[];
|
|
31
|
+
readonly adc: readonly ADCDefinition[];
|
|
32
|
+
readonly pwm: PWMDefinition;
|
|
33
|
+
readonly touch: {
|
|
34
|
+
channels: number;
|
|
35
|
+
pins: string[];
|
|
36
|
+
};
|
|
37
|
+
readonly timers: readonly TimerDefinition[];
|
|
38
|
+
readonly wifi: {
|
|
39
|
+
readonly type: "wifi";
|
|
40
|
+
readonly supportsStation: true;
|
|
41
|
+
readonly supportsAp: true;
|
|
42
|
+
};
|
|
43
|
+
readonly bluetooth: {
|
|
44
|
+
readonly type: "ble";
|
|
45
|
+
readonly version: "5.0";
|
|
46
|
+
};
|
|
47
|
+
readonly usb: {
|
|
48
|
+
readonly type: "otg";
|
|
49
|
+
readonly vid: "0x303A";
|
|
50
|
+
readonly pid: "0x0001";
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/** I2C bus instances */
|
|
54
|
+
export declare const I2C0: I2CBus, I2C1: I2CBus;
|
|
55
|
+
/** SPI bus instances */
|
|
56
|
+
export declare const SPI0: SPIBus, SPI1: SPIBus;
|
|
57
|
+
/** UART/Serial instances */
|
|
58
|
+
export declare const UART0: SerialPort, UART1: SerialPort, UART2: SerialPort;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// @typecad/mcu-esp32s3 — Hardware peripheral descriptions
|
|
3
|
+
//
|
|
4
|
+
// ESP32-S3 peripherals: 2× I2C, 2× SPI (FSPI/GPSI), 3× UART, 2× ADC (12-bit),
|
|
5
|
+
// 8× LEDC PWM, 14× capacitive-touch, 4× general-purpose timers, Wi-Fi 4,
|
|
6
|
+
// BLE 5, native USB-OTG. No DAC (removed on the S3).
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
import { I2CBus, SPIBus, SerialPort, i2cName, spiName, serialName, createHALInstances, } from '@typecad/hal';
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Peripheral definitions
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
export const I2C_INSTANCES = [
|
|
13
|
+
{ instance: 0, defaultPins: { sda: 'GPIO8', scl: 'GPIO9' } },
|
|
14
|
+
{ instance: 1, defaultPins: { sda: 'GPIO8', scl: 'GPIO9' } },
|
|
15
|
+
];
|
|
16
|
+
export const SPI_INSTANCES = [
|
|
17
|
+
{ instance: 0, defaultPins: { mosi: 'GPIO12', miso: 'GPIO13', sck: 'GPIO11', cs: 'GPIO10' } }, // FSPI
|
|
18
|
+
{ instance: 1, defaultPins: { mosi: 'GPIO12', miso: 'GPIO13', sck: 'GPIO11', cs: 'GPIO10' } }, // GPSI, remappable
|
|
19
|
+
];
|
|
20
|
+
export const UART_INSTANCES = [
|
|
21
|
+
{ instance: 0, defaultPins: { tx: 'GPIO43', rx: 'GPIO44' } },
|
|
22
|
+
{ instance: 1, defaultPins: { tx: 'GPIO43', rx: 'GPIO44' } },
|
|
23
|
+
{ instance: 2, defaultPins: { tx: 'GPIO43', rx: 'GPIO44' } },
|
|
24
|
+
];
|
|
25
|
+
export const ADC_INSTANCES = [
|
|
26
|
+
{ instance: 0, channels: 10, resolution: 12, referenceVoltage: 3.3, maxValue: 4095,
|
|
27
|
+
referenceVoltages: { DEFAULT: 3.3, INTERNAL: 1.1 } }, // ADC1 — usable with Wi-Fi active
|
|
28
|
+
{ instance: 1, channels: 10, resolution: 12, referenceVoltage: 3.3, maxValue: 4095,
|
|
29
|
+
referenceVoltages: { DEFAULT: 3.3, INTERNAL: 1.1 } }, // ADC2 — NOT usable with Wi-Fi active
|
|
30
|
+
];
|
|
31
|
+
export const PWM_CAPABILITIES = {
|
|
32
|
+
channels: 8,
|
|
33
|
+
resolution: 20,
|
|
34
|
+
maxFrequency: 40_000_000,
|
|
35
|
+
};
|
|
36
|
+
export const TOUCH_CAPABILITIES = {
|
|
37
|
+
channels: 14,
|
|
38
|
+
pins: ['GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
|
|
39
|
+
'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14'],
|
|
40
|
+
};
|
|
41
|
+
export const TIMER_INSTANCES = [
|
|
42
|
+
{ instance: 0, type: 'general', bits: 64, features: ['interrupt'] },
|
|
43
|
+
{ instance: 1, type: 'general', bits: 64, features: ['interrupt'] },
|
|
44
|
+
{ instance: 2, type: 'general', bits: 64, features: ['interrupt'] },
|
|
45
|
+
{ instance: 3, type: 'general', bits: 64, features: ['interrupt'] },
|
|
46
|
+
];
|
|
47
|
+
export const WIFI_CAPABILITIES = { type: 'wifi', supportsStation: true, supportsAp: true };
|
|
48
|
+
export const BLUETOOTH_CAPABILITIES = { type: 'ble', version: '5.0' };
|
|
49
|
+
export const USB_CAPABILITIES = { type: 'otg', vid: '0x303A', pid: '0x0001' };
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// Aggregate MCU peripheral description
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
export const MCU_PERIPHERALS = {
|
|
54
|
+
i2c: [...I2C_INSTANCES],
|
|
55
|
+
spi: [...SPI_INSTANCES],
|
|
56
|
+
uart: [...UART_INSTANCES],
|
|
57
|
+
adc: [...ADC_INSTANCES],
|
|
58
|
+
pwm: PWM_CAPABILITIES,
|
|
59
|
+
touch: TOUCH_CAPABILITIES,
|
|
60
|
+
timers: [...TIMER_INSTANCES],
|
|
61
|
+
wifi: WIFI_CAPABILITIES,
|
|
62
|
+
bluetooth: BLUETOOTH_CAPABILITIES,
|
|
63
|
+
usb: USB_CAPABILITIES,
|
|
64
|
+
};
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// HAL object instances — auto-generated from peripheral definitions
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
/** I2C bus instances */
|
|
69
|
+
export const [I2C0, I2C1] = createHALInstances(I2C_INSTANCES, i => new I2CBus(i2cName(i)));
|
|
70
|
+
/** SPI bus instances */
|
|
71
|
+
export const [SPI0, SPI1] = createHALInstances(SPI_INSTANCES, i => new SPIBus(spiName(i)));
|
|
72
|
+
/** UART/Serial instances */
|
|
73
|
+
export const [UART0, UART1, UART2] = createHALInstances(UART_INSTANCES, i => new SerialPort(serialName(i)));
|
package/dist/pins.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Pin } from '@typecad/hal';
|
|
2
|
+
export declare const GPIO0: Pin;
|
|
3
|
+
export declare const GPIO1: Pin;
|
|
4
|
+
export declare const GPIO2: Pin;
|
|
5
|
+
export declare const GPIO3: Pin;
|
|
6
|
+
export declare const GPIO4: Pin;
|
|
7
|
+
export declare const GPIO5: Pin;
|
|
8
|
+
export declare const GPIO6: Pin;
|
|
9
|
+
export declare const GPIO7: Pin;
|
|
10
|
+
export declare const GPIO8: Pin;
|
|
11
|
+
export declare const GPIO9: Pin;
|
|
12
|
+
export declare const GPIO10: Pin;
|
|
13
|
+
export declare const GPIO11: Pin;
|
|
14
|
+
export declare const GPIO12: Pin;
|
|
15
|
+
export declare const GPIO13: Pin;
|
|
16
|
+
export declare const GPIO14: Pin;
|
|
17
|
+
export declare const GPIO15: Pin;
|
|
18
|
+
export declare const GPIO16: Pin;
|
|
19
|
+
export declare const GPIO17: Pin;
|
|
20
|
+
export declare const GPIO18: Pin;
|
|
21
|
+
export declare const GPIO19: Pin;
|
|
22
|
+
export declare const GPIO20: Pin;
|
|
23
|
+
export declare const GPIO21: Pin;
|
|
24
|
+
export declare const GPIO26: Pin;
|
|
25
|
+
export declare const GPIO27: Pin;
|
|
26
|
+
export declare const GPIO28: Pin;
|
|
27
|
+
export declare const GPIO29: Pin;
|
|
28
|
+
export declare const GPIO30: Pin;
|
|
29
|
+
export declare const GPIO31: Pin;
|
|
30
|
+
export declare const GPIO32: Pin;
|
|
31
|
+
export declare const GPIO33: Pin;
|
|
32
|
+
export declare const GPIO34: Pin;
|
|
33
|
+
export declare const GPIO35: Pin;
|
|
34
|
+
export declare const GPIO36: Pin;
|
|
35
|
+
export declare const GPIO37: Pin;
|
|
36
|
+
export declare const GPIO38: Pin;
|
|
37
|
+
export declare const GPIO39: Pin;
|
|
38
|
+
export declare const GPIO40: Pin;
|
|
39
|
+
export declare const GPIO41: Pin;
|
|
40
|
+
export declare const GPIO42: Pin;
|
|
41
|
+
export declare const GPIO43: Pin;
|
|
42
|
+
export declare const GPIO44: Pin;
|
|
43
|
+
export declare const GPIO45: Pin;
|
|
44
|
+
export declare const GPIO46: Pin;
|
|
45
|
+
export declare const GPIO47: Pin;
|
|
46
|
+
export declare const GPIO48: Pin;
|
|
47
|
+
/** I2C0 data line (GPIO8). */
|
|
48
|
+
export declare const SDA: Pin;
|
|
49
|
+
/** I2C0 clock line (GPIO9). */
|
|
50
|
+
export declare const SCL: Pin;
|
|
51
|
+
/** SPI0 MOSI — FSPI (GPIO12). */
|
|
52
|
+
export declare const MOSI: Pin;
|
|
53
|
+
/** SPI0 MISO — FSPI (GPIO13). */
|
|
54
|
+
export declare const MISO: Pin;
|
|
55
|
+
/** SPI0 clock — FSPI (GPIO11). */
|
|
56
|
+
export declare const SCK: Pin;
|
|
57
|
+
/** SPI0 slave select — FSPI (GPIO10). */
|
|
58
|
+
export declare const SS: Pin;
|
|
59
|
+
/** UART0 transmit (GPIO43). */
|
|
60
|
+
export declare const TX: Pin;
|
|
61
|
+
/** UART0 receive (GPIO44). */
|
|
62
|
+
export declare const RX: Pin;
|
package/dist/pins.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// @typecad/mcu-esp32s3 — Datasheet pin definitions
|
|
3
|
+
//
|
|
4
|
+
// Each pin is a Pin instance from @typecad/hal.
|
|
5
|
+
// Pin names use GPIO numbers matching the ESP32-S3 datasheet. The S3 has 45
|
|
6
|
+
// GPIO (0-21, 26-48); GPIO 22-25 and 32-37 do NOT exist on the S3. All GPIOs
|
|
7
|
+
// are bidirectional (no input-only pins). DAC was removed on the S3.
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
import { Pin } from '@typecad/hal';
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Named GPIO constants (Pin instances)
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
export const GPIO0 = new Pin(0);
|
|
14
|
+
export const GPIO1 = new Pin(1);
|
|
15
|
+
export const GPIO2 = new Pin(2);
|
|
16
|
+
export const GPIO3 = new Pin(3);
|
|
17
|
+
export const GPIO4 = new Pin(4);
|
|
18
|
+
export const GPIO5 = new Pin(5);
|
|
19
|
+
export const GPIO6 = new Pin(6);
|
|
20
|
+
export const GPIO7 = new Pin(7);
|
|
21
|
+
export const GPIO8 = new Pin(8);
|
|
22
|
+
export const GPIO9 = new Pin(9);
|
|
23
|
+
export const GPIO10 = new Pin(10);
|
|
24
|
+
export const GPIO11 = new Pin(11);
|
|
25
|
+
export const GPIO12 = new Pin(12);
|
|
26
|
+
export const GPIO13 = new Pin(13);
|
|
27
|
+
export const GPIO14 = new Pin(14);
|
|
28
|
+
export const GPIO15 = new Pin(15);
|
|
29
|
+
export const GPIO16 = new Pin(16);
|
|
30
|
+
export const GPIO17 = new Pin(17);
|
|
31
|
+
export const GPIO18 = new Pin(18);
|
|
32
|
+
export const GPIO19 = new Pin(19);
|
|
33
|
+
export const GPIO20 = new Pin(20);
|
|
34
|
+
export const GPIO21 = new Pin(21);
|
|
35
|
+
export const GPIO26 = new Pin(26);
|
|
36
|
+
export const GPIO27 = new Pin(27);
|
|
37
|
+
export const GPIO28 = new Pin(28);
|
|
38
|
+
export const GPIO29 = new Pin(29);
|
|
39
|
+
export const GPIO30 = new Pin(30);
|
|
40
|
+
export const GPIO31 = new Pin(31);
|
|
41
|
+
export const GPIO32 = new Pin(32);
|
|
42
|
+
export const GPIO33 = new Pin(33);
|
|
43
|
+
export const GPIO34 = new Pin(34);
|
|
44
|
+
export const GPIO35 = new Pin(35);
|
|
45
|
+
export const GPIO36 = new Pin(36);
|
|
46
|
+
export const GPIO37 = new Pin(37);
|
|
47
|
+
export const GPIO38 = new Pin(38);
|
|
48
|
+
export const GPIO39 = new Pin(39);
|
|
49
|
+
export const GPIO40 = new Pin(40);
|
|
50
|
+
export const GPIO41 = new Pin(41);
|
|
51
|
+
export const GPIO42 = new Pin(42);
|
|
52
|
+
export const GPIO43 = new Pin(43);
|
|
53
|
+
export const GPIO44 = new Pin(44);
|
|
54
|
+
export const GPIO45 = new Pin(45);
|
|
55
|
+
export const GPIO46 = new Pin(46);
|
|
56
|
+
export const GPIO47 = new Pin(47);
|
|
57
|
+
export const GPIO48 = new Pin(48);
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Convenience aliases (Silicon-level defaults)
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
/** I2C0 data line (GPIO8). */
|
|
62
|
+
export const SDA = GPIO8;
|
|
63
|
+
/** I2C0 clock line (GPIO9). */
|
|
64
|
+
export const SCL = GPIO9;
|
|
65
|
+
/** SPI0 MOSI — FSPI (GPIO12). */
|
|
66
|
+
export const MOSI = GPIO12;
|
|
67
|
+
/** SPI0 MISO — FSPI (GPIO13). */
|
|
68
|
+
export const MISO = GPIO13;
|
|
69
|
+
/** SPI0 clock — FSPI (GPIO11). */
|
|
70
|
+
export const SCK = GPIO11;
|
|
71
|
+
/** SPI0 slave select — FSPI (GPIO10). */
|
|
72
|
+
export const SS = GPIO10;
|
|
73
|
+
/** UART0 transmit (GPIO43). */
|
|
74
|
+
export const TX = GPIO43;
|
|
75
|
+
/** UART0 receive (GPIO44). */
|
|
76
|
+
export const RX = GPIO44;
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@typecad/mcu-esp32s3",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "TypeCAD MCU definition for ESP32-S3 — datasheet pins, peripheral capabilities, and HAL instances",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@typecad/cuttlefish": "0.1.0-alpha.1",
|
|
18
|
+
"@typecad/hal": "0.1.0-alpha.1"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/justind000/typecode.git",
|
|
27
|
+
"directory": "packages/mcu-esp32s3"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://github.com/justind000/typecode/tree/main/packages/mcu-esp32s3",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/justind000/typecode/issues"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"arduino",
|
|
35
|
+
"cpp",
|
|
36
|
+
"cuttlefish",
|
|
37
|
+
"embedded",
|
|
38
|
+
"esp32s3",
|
|
39
|
+
"firmware",
|
|
40
|
+
"mcu",
|
|
41
|
+
"microcontroller",
|
|
42
|
+
"peripherals",
|
|
43
|
+
"pins",
|
|
44
|
+
"silicon",
|
|
45
|
+
"typecad",
|
|
46
|
+
"typescript"
|
|
47
|
+
],
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=18"
|
|
50
|
+
},
|
|
51
|
+
"author": "typecad0",
|
|
52
|
+
"sideEffects": false,
|
|
53
|
+
"exports": {
|
|
54
|
+
".": {
|
|
55
|
+
"types": "./dist/index.d.ts",
|
|
56
|
+
"default": "./dist/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./package.json": "./package.json"
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// @typecad/mcu-esp32s3 — MCU definition manifest
|
|
3
|
+
//
|
|
4
|
+
// ESP32-S3 is dual-core Xtensa LX7 @ 240 MHz with Wi-Fi 4 + BLE 5 and native
|
|
5
|
+
// USB-OTG. It has 45 GPIO (0-21, 26-48); GPIO 22-25 and 32-37 do NOT exist on
|
|
6
|
+
// the S3 (different pad layout from classic ESP32). All GPIOs are bidirectional
|
|
7
|
+
// (no input-only pins). DAC was removed on the S3.
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
import type { MCUDefinition } from '@typecad/cuttlefish/api/schema';
|
|
11
|
+
import { MCU_PERIPHERALS } from './peripherals.js';
|
|
12
|
+
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Default capability flags for ESP32-S3
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
const NO = false as const;
|
|
18
|
+
const YES = true as const;
|
|
19
|
+
|
|
20
|
+
/** Full GPIO: digital I/O + pull-up + pull-down + PWM + interrupt. */
|
|
21
|
+
const FULL_GPIO = {
|
|
22
|
+
digitalInput: YES, digitalOutput: YES,
|
|
23
|
+
analogInput: NO, analogOutput: NO,
|
|
24
|
+
pwm: YES, interrupt: YES,
|
|
25
|
+
pullUp: YES, pullDown: YES,
|
|
26
|
+
touch: NO, openDrain: NO,
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
/** Full GPIO + analog input (ADC). */
|
|
30
|
+
const FULL_GPIO_ANALOG = { ...FULL_GPIO, analogInput: YES } as const;
|
|
31
|
+
|
|
32
|
+
/** Full GPIO + analog input + touch. */
|
|
33
|
+
const FULL_GPIO_ANALOG_TOUCH = { ...FULL_GPIO, analogInput: YES, touch: YES } as const;
|
|
34
|
+
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
// Helper: build ADC/touch peripheral-function references.
|
|
37
|
+
//
|
|
38
|
+
// ADC1 channels: GPIO1..GPIO10 -> ch0..ch9 (always usable).
|
|
39
|
+
// ADC2 channels: GPIO11..GPIO20 -> ch0..ch9 (NOT usable while Wi-Fi is on).
|
|
40
|
+
// Touch channels: GPIO1..GPIO14 -> T1..T14.
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
function adc(n: number, ch: number) {
|
|
44
|
+
return { type: 'adc' as const, instance: n, role: `ch${ch}` };
|
|
45
|
+
}
|
|
46
|
+
function touch(ch: number) {
|
|
47
|
+
return { type: 'touch' as const, instance: 0, role: `touch${ch}` };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// MCU definition
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
export const ESP32S3: MCUDefinition = {
|
|
55
|
+
id: 'esp32-s3',
|
|
56
|
+
name: 'ESP32-S3',
|
|
57
|
+
architecture: 'esp32s3',
|
|
58
|
+
memory: {
|
|
59
|
+
flash: 384 * 1024, // usable app flash; remainder reserved by bootloader/OTADATA
|
|
60
|
+
sram: 512 * 1024, // 512 KB
|
|
61
|
+
eeprom: 0,
|
|
62
|
+
rtcMemory: 16 * 1024, // 16 KB RTC slow memory
|
|
63
|
+
},
|
|
64
|
+
pins: {
|
|
65
|
+
all: [
|
|
66
|
+
// ---- Boot strapping pins (unsafe) ------------------------------------
|
|
67
|
+
{ number: 0, gpio: 0, name: 'GPIO0', capabilities: FULL_GPIO_ANALOG,
|
|
68
|
+
functions: [adc(1, 0), touch(1)],
|
|
69
|
+
alternateFunctions: ['ADC1_CH0', 'Touch1'],
|
|
70
|
+
warnings: ['GPIO0 is a strapping pin — must be HIGH at boot for normal flash boot; LOW enters download mode'],
|
|
71
|
+
unsafe: true, notes: 'Boot strapping pin' },
|
|
72
|
+
|
|
73
|
+
{ number: 1, gpio: 1, name: 'GPIO1', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
74
|
+
functions: [adc(1, 1), touch(2)],
|
|
75
|
+
alternateFunctions: ['ADC1_CH1', 'Touch2'] },
|
|
76
|
+
|
|
77
|
+
{ number: 2, gpio: 2, name: 'GPIO2', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
78
|
+
functions: [adc(1, 2), touch(3)],
|
|
79
|
+
alternateFunctions: ['ADC1_CH2', 'Touch3'] },
|
|
80
|
+
|
|
81
|
+
{ number: 3, gpio: 3, name: 'GPIO3', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
82
|
+
functions: [adc(1, 3), touch(4)],
|
|
83
|
+
alternateFunctions: ['ADC1_CH3', 'Touch4'],
|
|
84
|
+
warnings: ['GPIO3 is a strapping pin — controls JTAG signal source at boot'],
|
|
85
|
+
unsafe: true, notes: 'Boot strapping pin' },
|
|
86
|
+
|
|
87
|
+
{ number: 4, gpio: 4, name: 'GPIO4', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
88
|
+
functions: [adc(1, 4), touch(5)],
|
|
89
|
+
alternateFunctions: ['ADC1_CH4', 'Touch5'] },
|
|
90
|
+
|
|
91
|
+
{ number: 5, gpio: 5, name: 'GPIO5', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
92
|
+
functions: [adc(1, 5), touch(6)],
|
|
93
|
+
alternateFunctions: ['ADC1_CH5', 'Touch6'] },
|
|
94
|
+
|
|
95
|
+
{ number: 6, gpio: 6, name: 'GPIO6', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
96
|
+
functions: [adc(1, 6), touch(7)],
|
|
97
|
+
alternateFunctions: ['ADC1_CH6', 'Touch7'] },
|
|
98
|
+
|
|
99
|
+
{ number: 7, gpio: 7, name: 'GPIO7', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
100
|
+
functions: [adc(1, 7), touch(8)],
|
|
101
|
+
alternateFunctions: ['ADC1_CH7', 'Touch8'] },
|
|
102
|
+
|
|
103
|
+
{ number: 8, gpio: 8, name: 'GPIO8', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
104
|
+
functions: [adc(1, 8), touch(9), { type: 'i2c', instance: 0, role: 'sda' }],
|
|
105
|
+
alternateFunctions: ['ADC1_CH8', 'Touch9', 'I2C0 SDA'],
|
|
106
|
+
warnings: ['Using GPIO8 as GPIO will interfere with I2C0 SDA'] },
|
|
107
|
+
|
|
108
|
+
{ number: 9, gpio: 9, name: 'GPIO9', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
109
|
+
functions: [adc(1, 9), touch(10), { type: 'i2c', instance: 0, role: 'scl' }],
|
|
110
|
+
alternateFunctions: ['ADC1_CH9', 'Touch10', 'I2C0 SCL'],
|
|
111
|
+
warnings: ['Using GPIO9 as GPIO will interfere with I2C0 SCL'] },
|
|
112
|
+
|
|
113
|
+
{ number: 10, gpio: 10, name: 'GPIO10', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
114
|
+
functions: [adc(1, 10), touch(11)],
|
|
115
|
+
alternateFunctions: ['ADC1_CH10', 'Touch11'] },
|
|
116
|
+
|
|
117
|
+
{ number: 11, gpio: 11, name: 'GPIO11', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
118
|
+
functions: [adc(2, 0), touch(12), { type: 'spi', instance: 0, role: 'sck' }],
|
|
119
|
+
alternateFunctions: ['ADC2_CH0', 'Touch12', 'FSPI SCK'],
|
|
120
|
+
warnings: ['GPIO11 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
121
|
+
|
|
122
|
+
{ number: 12, gpio: 12, name: 'GPIO12', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
123
|
+
functions: [adc(2, 1), touch(13), { type: 'spi', instance: 0, role: 'mosi' }],
|
|
124
|
+
alternateFunctions: ['ADC2_CH1', 'Touch13', 'FSPI MOSI'],
|
|
125
|
+
warnings: ['GPIO12 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
126
|
+
|
|
127
|
+
{ number: 13, gpio: 13, name: 'GPIO13', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
128
|
+
functions: [adc(2, 2), touch(14), { type: 'spi', instance: 0, role: 'miso' }],
|
|
129
|
+
alternateFunctions: ['ADC2_CH2', 'Touch14', 'FSPI MISO'],
|
|
130
|
+
warnings: ['GPIO13 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
131
|
+
|
|
132
|
+
{ number: 14, gpio: 14, name: 'GPIO14', capabilities: FULL_GPIO_ANALOG_TOUCH,
|
|
133
|
+
functions: [adc(2, 3)],
|
|
134
|
+
alternateFunctions: ['ADC2_CH3'],
|
|
135
|
+
warnings: ['GPIO14 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
136
|
+
|
|
137
|
+
{ number: 15, gpio: 15, name: 'GPIO15', capabilities: FULL_GPIO_ANALOG,
|
|
138
|
+
functions: [adc(2, 4)],
|
|
139
|
+
alternateFunctions: ['ADC2_CH4'],
|
|
140
|
+
warnings: ['GPIO15 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
141
|
+
|
|
142
|
+
{ number: 16, gpio: 16, name: 'GPIO16', capabilities: FULL_GPIO_ANALOG,
|
|
143
|
+
functions: [adc(2, 5)],
|
|
144
|
+
alternateFunctions: ['ADC2_CH5'],
|
|
145
|
+
warnings: ['GPIO16 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
146
|
+
|
|
147
|
+
{ number: 17, gpio: 17, name: 'GPIO17', capabilities: FULL_GPIO_ANALOG,
|
|
148
|
+
functions: [adc(2, 6)],
|
|
149
|
+
alternateFunctions: ['ADC2_CH6'],
|
|
150
|
+
warnings: ['GPIO17 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
151
|
+
|
|
152
|
+
{ number: 18, gpio: 18, name: 'GPIO18', capabilities: FULL_GPIO_ANALOG,
|
|
153
|
+
functions: [adc(2, 7)],
|
|
154
|
+
alternateFunctions: ['ADC2_CH7'],
|
|
155
|
+
warnings: ['GPIO18 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
|
|
156
|
+
|
|
157
|
+
{ number: 19, gpio: 19, name: 'GPIO19', capabilities: FULL_GPIO_ANALOG,
|
|
158
|
+
functions: [adc(2, 8), { type: 'usb', instance: 0, role: 'dm' }],
|
|
159
|
+
alternateFunctions: ['ADC2_CH8', 'USB D-'],
|
|
160
|
+
warnings: ['GPIO19 is USB D- — using it as GPIO disables native USB', 'GPIO19 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'],
|
|
161
|
+
unsafe: true, notes: 'USB D- pin' },
|
|
162
|
+
|
|
163
|
+
{ number: 20, gpio: 20, name: 'GPIO20', capabilities: FULL_GPIO_ANALOG,
|
|
164
|
+
functions: [adc(2, 9), { type: 'usb', instance: 0, role: 'dp' }],
|
|
165
|
+
alternateFunctions: ['ADC2_CH9', 'USB D+'],
|
|
166
|
+
warnings: ['GPIO20 is USB D+ — using it as GPIO disables native USB', 'GPIO20 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'],
|
|
167
|
+
unsafe: true, notes: 'USB D+ pin' },
|
|
168
|
+
|
|
169
|
+
{ number: 21, gpio: 21, name: 'GPIO21', capabilities: FULL_GPIO,
|
|
170
|
+
alternateFunctions: [] },
|
|
171
|
+
|
|
172
|
+
// ---- GPIO 22-25 do NOT exist on the ESP32-S3 -------------------------
|
|
173
|
+
|
|
174
|
+
// ---- GPIO 26-32 connected to SPI flash / PSRAM (unsafe) ---------------
|
|
175
|
+
{ number: 26, gpio: 26, name: 'GPIO26', capabilities: FULL_GPIO,
|
|
176
|
+
alternateFunctions: ['SPICS1'],
|
|
177
|
+
warnings: ['GPIO26 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
178
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
179
|
+
{ number: 27, gpio: 27, name: 'GPIO27', capabilities: FULL_GPIO,
|
|
180
|
+
alternateFunctions: ['SPIHD'],
|
|
181
|
+
warnings: ['GPIO27 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
182
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
183
|
+
{ number: 28, gpio: 28, name: 'GPIO28', capabilities: FULL_GPIO,
|
|
184
|
+
alternateFunctions: ['SPIWP'],
|
|
185
|
+
warnings: ['GPIO28 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
186
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
187
|
+
{ number: 29, gpio: 29, name: 'GPIO29', capabilities: FULL_GPIO,
|
|
188
|
+
alternateFunctions: ['SPICS0'],
|
|
189
|
+
warnings: ['GPIO29 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
190
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
191
|
+
{ number: 30, gpio: 30, name: 'GPIO30', capabilities: FULL_GPIO,
|
|
192
|
+
alternateFunctions: ['SPICLK'],
|
|
193
|
+
warnings: ['GPIO30 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
194
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
195
|
+
{ number: 31, gpio: 31, name: 'GPIO31', capabilities: FULL_GPIO,
|
|
196
|
+
alternateFunctions: ['SPIQ'],
|
|
197
|
+
warnings: ['GPIO31 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
198
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
199
|
+
{ number: 32, gpio: 32, name: 'GPIO32', capabilities: FULL_GPIO,
|
|
200
|
+
alternateFunctions: ['SPID'],
|
|
201
|
+
warnings: ['GPIO32 is connected to SPI flash/PSRAM — do not use as GPIO'],
|
|
202
|
+
unsafe: true, notes: 'SPI flash pin' },
|
|
203
|
+
|
|
204
|
+
// ---- GPIO 33-37 connected to octal PSRAM on PSRAM modules -----------
|
|
205
|
+
{ number: 33, gpio: 33, name: 'GPIO33', capabilities: FULL_GPIO,
|
|
206
|
+
alternateFunctions: ['SPIIO4'],
|
|
207
|
+
warnings: ['GPIO33 is connected to octal PSRAM on some modules — verify before use'],
|
|
208
|
+
unsafe: true, notes: 'Octal SPI/PSRAM pin on PSRAM modules' },
|
|
209
|
+
{ number: 34, gpio: 34, name: 'GPIO34', capabilities: FULL_GPIO,
|
|
210
|
+
alternateFunctions: ['SPIIO5'],
|
|
211
|
+
warnings: ['GPIO34 is connected to octal PSRAM on some modules — verify before use'],
|
|
212
|
+
unsafe: true, notes: 'Octal SPI/PSRAM pin on PSRAM modules' },
|
|
213
|
+
{ number: 35, gpio: 35, name: 'GPIO35', capabilities: FULL_GPIO,
|
|
214
|
+
alternateFunctions: ['SPIIO6'],
|
|
215
|
+
warnings: ['GPIO35 is connected to octal PSRAM on some modules — verify before use'],
|
|
216
|
+
unsafe: true, notes: 'Octal SPI/PSRAM pin on PSRAM modules' },
|
|
217
|
+
{ number: 36, gpio: 36, name: 'GPIO36', capabilities: FULL_GPIO,
|
|
218
|
+
alternateFunctions: ['SPIIO7'],
|
|
219
|
+
warnings: ['GPIO36 is connected to octal PSRAM on some modules — verify before use'],
|
|
220
|
+
unsafe: true, notes: 'Octal SPI/PSRAM pin on PSRAM modules' },
|
|
221
|
+
{ number: 37, gpio: 37, name: 'GPIO37', capabilities: FULL_GPIO,
|
|
222
|
+
alternateFunctions: ['SPIDQS'],
|
|
223
|
+
warnings: ['GPIO37 is connected to octal PSRAM on some modules — verify before use'],
|
|
224
|
+
unsafe: true, notes: 'Octal SPI/PSRAM pin on PSRAM modules' },
|
|
225
|
+
|
|
226
|
+
{ number: 38, gpio: 38, name: 'GPIO38', capabilities: FULL_GPIO,
|
|
227
|
+
alternateFunctions: [] },
|
|
228
|
+
{ number: 39, gpio: 39, name: 'GPIO39', capabilities: FULL_GPIO,
|
|
229
|
+
alternateFunctions: ['MTCK'] },
|
|
230
|
+
{ number: 40, gpio: 40, name: 'GPIO40', capabilities: FULL_GPIO,
|
|
231
|
+
alternateFunctions: ['MTDO'] },
|
|
232
|
+
{ number: 41, gpio: 41, name: 'GPIO41', capabilities: FULL_GPIO,
|
|
233
|
+
alternateFunctions: ['MTDI'] },
|
|
234
|
+
{ number: 42, gpio: 42, name: 'GPIO42', capabilities: FULL_GPIO,
|
|
235
|
+
alternateFunctions: ['MTMS'] },
|
|
236
|
+
|
|
237
|
+
// ---- UART0 default pins ----------------------------------------------
|
|
238
|
+
{ number: 43, gpio: 43, name: 'GPIO43', capabilities: FULL_GPIO,
|
|
239
|
+
functions: [{ type: 'uart', instance: 0, role: 'tx' }],
|
|
240
|
+
alternateFunctions: ['UART0 TX'],
|
|
241
|
+
warnings: ['Using GPIO43 as GPIO will interfere with UART0 transmit'] },
|
|
242
|
+
{ number: 44, gpio: 44, name: 'GPIO44', capabilities: FULL_GPIO,
|
|
243
|
+
functions: [{ type: 'uart', instance: 0, role: 'rx' }],
|
|
244
|
+
alternateFunctions: ['UART0 RX'],
|
|
245
|
+
warnings: ['Using GPIO44 as GPIO will interfere with UART0 receive'] },
|
|
246
|
+
|
|
247
|
+
{ number: 45, gpio: 45, name: 'GPIO45', capabilities: FULL_GPIO,
|
|
248
|
+
alternateFunctions: [],
|
|
249
|
+
warnings: ['GPIO45 is a strapping pin — sets VDD_SPI voltage at boot'],
|
|
250
|
+
unsafe: true, notes: 'Boot strapping pin' },
|
|
251
|
+
{ number: 46, gpio: 46, name: 'GPIO46', capabilities: FULL_GPIO,
|
|
252
|
+
alternateFunctions: [],
|
|
253
|
+
warnings: ['GPIO46 is a strapping pin — controls boot mode at boot'],
|
|
254
|
+
unsafe: true, notes: 'Boot strapping pin' },
|
|
255
|
+
|
|
256
|
+
{ number: 47, gpio: 47, name: 'GPIO47', capabilities: FULL_GPIO,
|
|
257
|
+
alternateFunctions: ['RGB_DATA'] },
|
|
258
|
+
{ number: 48, gpio: 48, name: 'GPIO48', capabilities: FULL_GPIO,
|
|
259
|
+
alternateFunctions: ['RGB_DATA', 'Onboard LED (DevKitC-1)'],
|
|
260
|
+
onboardLed: true },
|
|
261
|
+
],
|
|
262
|
+
|
|
263
|
+
digital: [
|
|
264
|
+
'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
|
|
265
|
+
'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
|
|
266
|
+
'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
|
|
267
|
+
'GPIO26', 'GPIO27', 'GPIO28', 'GPIO29', 'GPIO30', 'GPIO31', 'GPIO32',
|
|
268
|
+
'GPIO33', 'GPIO34', 'GPIO35', 'GPIO36', 'GPIO37', 'GPIO38', 'GPIO39',
|
|
269
|
+
'GPIO40', 'GPIO41', 'GPIO42', 'GPIO43', 'GPIO44', 'GPIO45', 'GPIO46',
|
|
270
|
+
'GPIO47', 'GPIO48',
|
|
271
|
+
],
|
|
272
|
+
analog: [
|
|
273
|
+
'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7', 'GPIO8',
|
|
274
|
+
'GPIO9', 'GPIO10', // ADC1
|
|
275
|
+
'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14', 'GPIO15',
|
|
276
|
+
'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', // ADC2
|
|
277
|
+
],
|
|
278
|
+
pwm: [
|
|
279
|
+
'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
|
|
280
|
+
'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
|
|
281
|
+
'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
|
|
282
|
+
'GPIO38', 'GPIO39', 'GPIO40', 'GPIO41', 'GPIO42', 'GPIO43', 'GPIO44',
|
|
283
|
+
'GPIO45', 'GPIO46', 'GPIO47', 'GPIO48',
|
|
284
|
+
],
|
|
285
|
+
unsafe: [
|
|
286
|
+
'GPIO0', 'GPIO3', 'GPIO19', 'GPIO20',
|
|
287
|
+
'GPIO26', 'GPIO27', 'GPIO28', 'GPIO29', 'GPIO30', 'GPIO31', 'GPIO32',
|
|
288
|
+
'GPIO33', 'GPIO34', 'GPIO35', 'GPIO36', 'GPIO37',
|
|
289
|
+
'GPIO45', 'GPIO46',
|
|
290
|
+
],
|
|
291
|
+
|
|
292
|
+
i2c: { 0: { sda: 'GPIO8', scl: 'GPIO9' } },
|
|
293
|
+
spi: {
|
|
294
|
+
0: { mosi: 'GPIO12', miso: 'GPIO13', sck: 'GPIO11', cs: 'GPIO10' }, // FSPI
|
|
295
|
+
},
|
|
296
|
+
uart: {
|
|
297
|
+
0: { tx: 'GPIO43', rx: 'GPIO44' },
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
// ----- Peripherals -------------------------------------------------------
|
|
302
|
+
peripherals: MCU_PERIPHERALS,
|
|
303
|
+
|
|
304
|
+
features: {
|
|
305
|
+
multicore: true,
|
|
306
|
+
coreCount: 2,
|
|
307
|
+
deepSleep: true,
|
|
308
|
+
watchdog: true,
|
|
309
|
+
externalInterrupts: true,
|
|
310
|
+
hardwareRng: true,
|
|
311
|
+
fpu: true,
|
|
312
|
+
},
|
|
313
|
+
build: {
|
|
314
|
+
extraFlags: [],
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
export default ESP32S3;
|
|
319
|
+
|
|
320
|
+
// Re-exports
|
|
321
|
+
export * from './pins.js';
|
|
322
|
+
export * from './peripherals.js';
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Structured manifest consumed by the TypeCAD CLI for contract-based
|
|
326
|
+
* board generation. Provides pin names and peripheral instance names
|
|
327
|
+
* without requiring the CLI to text-scrape compiled output.
|
|
328
|
+
*/
|
|
329
|
+
export const TypeCADManifest = {
|
|
330
|
+
/** All MCU port-level pin names (e.g. 'GPIO0', 'GPIO1'). */
|
|
331
|
+
pinNames: [
|
|
332
|
+
'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
|
|
333
|
+
'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
|
|
334
|
+
'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
|
|
335
|
+
'GPIO26', 'GPIO27', 'GPIO28', 'GPIO29', 'GPIO30', 'GPIO31', 'GPIO32',
|
|
336
|
+
'GPIO33', 'GPIO34', 'GPIO35', 'GPIO36', 'GPIO37', 'GPIO38', 'GPIO39',
|
|
337
|
+
'GPIO40', 'GPIO41', 'GPIO42', 'GPIO43', 'GPIO44', 'GPIO45', 'GPIO46',
|
|
338
|
+
'GPIO47', 'GPIO48',
|
|
339
|
+
] as const,
|
|
340
|
+
|
|
341
|
+
/** All HAL peripheral instance names exported from this package. */
|
|
342
|
+
peripheralNames: ['I2C0', 'I2C1', 'SPI0', 'SPI1', 'UART0', 'UART1', 'UART2'] as const,
|
|
343
|
+
} as const;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// @typecad/mcu-esp32s3 — Hardware peripheral descriptions
|
|
3
|
+
//
|
|
4
|
+
// ESP32-S3 peripherals: 2× I2C, 2× SPI (FSPI/GPSI), 3× UART, 2× ADC (12-bit),
|
|
5
|
+
// 8× LEDC PWM, 14× capacitive-touch, 4× general-purpose timers, Wi-Fi 4,
|
|
6
|
+
// BLE 5, native USB-OTG. No DAC (removed on the S3).
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
import type {
|
|
10
|
+
PeripheralInstance,
|
|
11
|
+
ADCDefinition,
|
|
12
|
+
PWMDefinition,
|
|
13
|
+
TimerDefinition,
|
|
14
|
+
} from '@typecad/cuttlefish/api/schema';
|
|
15
|
+
import {
|
|
16
|
+
I2CBus,
|
|
17
|
+
SPIBus,
|
|
18
|
+
SerialPort,
|
|
19
|
+
i2cName,
|
|
20
|
+
spiName,
|
|
21
|
+
serialName,
|
|
22
|
+
createHALInstances,
|
|
23
|
+
} from '@typecad/hal';
|
|
24
|
+
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// Peripheral definitions
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
export const I2C_INSTANCES: readonly PeripheralInstance[] = [
|
|
30
|
+
{ instance: 0, defaultPins: { sda: 'GPIO8', scl: 'GPIO9' } },
|
|
31
|
+
{ instance: 1, defaultPins: { sda: 'GPIO8', scl: 'GPIO9' } },
|
|
32
|
+
] as const;
|
|
33
|
+
|
|
34
|
+
export const SPI_INSTANCES: readonly PeripheralInstance[] = [
|
|
35
|
+
{ instance: 0, defaultPins: { mosi: 'GPIO12', miso: 'GPIO13', sck: 'GPIO11', cs: 'GPIO10' } }, // FSPI
|
|
36
|
+
{ instance: 1, defaultPins: { mosi: 'GPIO12', miso: 'GPIO13', sck: 'GPIO11', cs: 'GPIO10' } }, // GPSI, remappable
|
|
37
|
+
] as const;
|
|
38
|
+
|
|
39
|
+
export const UART_INSTANCES: readonly PeripheralInstance[] = [
|
|
40
|
+
{ instance: 0, defaultPins: { tx: 'GPIO43', rx: 'GPIO44' } },
|
|
41
|
+
{ instance: 1, defaultPins: { tx: 'GPIO43', rx: 'GPIO44' } },
|
|
42
|
+
{ instance: 2, defaultPins: { tx: 'GPIO43', rx: 'GPIO44' } },
|
|
43
|
+
] as const;
|
|
44
|
+
|
|
45
|
+
export const ADC_INSTANCES: readonly ADCDefinition[] = [
|
|
46
|
+
{ instance: 0, channels: 10, resolution: 12, referenceVoltage: 3.3, maxValue: 4095,
|
|
47
|
+
referenceVoltages: { DEFAULT: 3.3, INTERNAL: 1.1 } }, // ADC1 — usable with Wi-Fi active
|
|
48
|
+
{ instance: 1, channels: 10, resolution: 12, referenceVoltage: 3.3, maxValue: 4095,
|
|
49
|
+
referenceVoltages: { DEFAULT: 3.3, INTERNAL: 1.1 } }, // ADC2 — NOT usable with Wi-Fi active
|
|
50
|
+
] as const;
|
|
51
|
+
|
|
52
|
+
export const PWM_CAPABILITIES: PWMDefinition = {
|
|
53
|
+
channels: 8,
|
|
54
|
+
resolution: 20,
|
|
55
|
+
maxFrequency: 40_000_000,
|
|
56
|
+
} as const;
|
|
57
|
+
|
|
58
|
+
export const TOUCH_CAPABILITIES = {
|
|
59
|
+
channels: 14,
|
|
60
|
+
pins: ['GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
|
|
61
|
+
'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14'],
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const TIMER_INSTANCES: readonly TimerDefinition[] = [
|
|
65
|
+
{ instance: 0, type: 'general', bits: 64, features: ['interrupt'] },
|
|
66
|
+
{ instance: 1, type: 'general', bits: 64, features: ['interrupt'] },
|
|
67
|
+
{ instance: 2, type: 'general', bits: 64, features: ['interrupt'] },
|
|
68
|
+
{ instance: 3, type: 'general', bits: 64, features: ['interrupt'] },
|
|
69
|
+
] as const;
|
|
70
|
+
|
|
71
|
+
export const WIFI_CAPABILITIES = { type: 'wifi', supportsStation: true, supportsAp: true } as const;
|
|
72
|
+
export const BLUETOOTH_CAPABILITIES = { type: 'ble', version: '5.0' } as const;
|
|
73
|
+
export const USB_CAPABILITIES = { type: 'otg', vid: '0x303A', pid: '0x0001' } as const;
|
|
74
|
+
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Aggregate MCU peripheral description
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
export const MCU_PERIPHERALS = {
|
|
80
|
+
i2c: [...I2C_INSTANCES],
|
|
81
|
+
spi: [...SPI_INSTANCES],
|
|
82
|
+
uart: [...UART_INSTANCES],
|
|
83
|
+
adc: [...ADC_INSTANCES],
|
|
84
|
+
pwm: PWM_CAPABILITIES,
|
|
85
|
+
touch: TOUCH_CAPABILITIES,
|
|
86
|
+
timers: [...TIMER_INSTANCES],
|
|
87
|
+
wifi: WIFI_CAPABILITIES,
|
|
88
|
+
bluetooth: BLUETOOTH_CAPABILITIES,
|
|
89
|
+
usb: USB_CAPABILITIES,
|
|
90
|
+
} as const;
|
|
91
|
+
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
// HAL object instances — auto-generated from peripheral definitions
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
/** I2C bus instances */
|
|
97
|
+
export const [I2C0, I2C1] = createHALInstances(I2C_INSTANCES, i => new I2CBus(i2cName(i)));
|
|
98
|
+
|
|
99
|
+
/** SPI bus instances */
|
|
100
|
+
export const [SPI0, SPI1] = createHALInstances(SPI_INSTANCES, i => new SPIBus(spiName(i)));
|
|
101
|
+
|
|
102
|
+
/** UART/Serial instances */
|
|
103
|
+
export const [UART0, UART1, UART2] = createHALInstances(UART_INSTANCES, i => new SerialPort(serialName(i)));
|
package/src/pins.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// @typecad/mcu-esp32s3 — Datasheet pin definitions
|
|
3
|
+
//
|
|
4
|
+
// Each pin is a Pin instance from @typecad/hal.
|
|
5
|
+
// Pin names use GPIO numbers matching the ESP32-S3 datasheet. The S3 has 45
|
|
6
|
+
// GPIO (0-21, 26-48); GPIO 22-25 and 32-37 do NOT exist on the S3. All GPIOs
|
|
7
|
+
// are bidirectional (no input-only pins). DAC was removed on the S3.
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
import { Pin } from '@typecad/hal';
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Named GPIO constants (Pin instances)
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
export const GPIO0 = new Pin(0);
|
|
17
|
+
export const GPIO1 = new Pin(1);
|
|
18
|
+
export const GPIO2 = new Pin(2);
|
|
19
|
+
export const GPIO3 = new Pin(3);
|
|
20
|
+
export const GPIO4 = new Pin(4);
|
|
21
|
+
export const GPIO5 = new Pin(5);
|
|
22
|
+
export const GPIO6 = new Pin(6);
|
|
23
|
+
export const GPIO7 = new Pin(7);
|
|
24
|
+
export const GPIO8 = new Pin(8);
|
|
25
|
+
export const GPIO9 = new Pin(9);
|
|
26
|
+
export const GPIO10 = new Pin(10);
|
|
27
|
+
export const GPIO11 = new Pin(11);
|
|
28
|
+
export const GPIO12 = new Pin(12);
|
|
29
|
+
export const GPIO13 = new Pin(13);
|
|
30
|
+
export const GPIO14 = new Pin(14);
|
|
31
|
+
export const GPIO15 = new Pin(15);
|
|
32
|
+
export const GPIO16 = new Pin(16);
|
|
33
|
+
export const GPIO17 = new Pin(17);
|
|
34
|
+
export const GPIO18 = new Pin(18);
|
|
35
|
+
export const GPIO19 = new Pin(19);
|
|
36
|
+
export const GPIO20 = new Pin(20);
|
|
37
|
+
export const GPIO21 = new Pin(21);
|
|
38
|
+
export const GPIO26 = new Pin(26);
|
|
39
|
+
export const GPIO27 = new Pin(27);
|
|
40
|
+
export const GPIO28 = new Pin(28);
|
|
41
|
+
export const GPIO29 = new Pin(29);
|
|
42
|
+
export const GPIO30 = new Pin(30);
|
|
43
|
+
export const GPIO31 = new Pin(31);
|
|
44
|
+
export const GPIO32 = new Pin(32);
|
|
45
|
+
export const GPIO33 = new Pin(33);
|
|
46
|
+
export const GPIO34 = new Pin(34);
|
|
47
|
+
export const GPIO35 = new Pin(35);
|
|
48
|
+
export const GPIO36 = new Pin(36);
|
|
49
|
+
export const GPIO37 = new Pin(37);
|
|
50
|
+
export const GPIO38 = new Pin(38);
|
|
51
|
+
export const GPIO39 = new Pin(39);
|
|
52
|
+
export const GPIO40 = new Pin(40);
|
|
53
|
+
export const GPIO41 = new Pin(41);
|
|
54
|
+
export const GPIO42 = new Pin(42);
|
|
55
|
+
export const GPIO43 = new Pin(43);
|
|
56
|
+
export const GPIO44 = new Pin(44);
|
|
57
|
+
export const GPIO45 = new Pin(45);
|
|
58
|
+
export const GPIO46 = new Pin(46);
|
|
59
|
+
export const GPIO47 = new Pin(47);
|
|
60
|
+
export const GPIO48 = new Pin(48);
|
|
61
|
+
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
// Convenience aliases (Silicon-level defaults)
|
|
64
|
+
// ---------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
/** I2C0 data line (GPIO8). */
|
|
67
|
+
export const SDA = GPIO8;
|
|
68
|
+
/** I2C0 clock line (GPIO9). */
|
|
69
|
+
export const SCL = GPIO9;
|
|
70
|
+
|
|
71
|
+
/** SPI0 MOSI — FSPI (GPIO12). */
|
|
72
|
+
export const MOSI = GPIO12;
|
|
73
|
+
/** SPI0 MISO — FSPI (GPIO13). */
|
|
74
|
+
export const MISO = GPIO13;
|
|
75
|
+
/** SPI0 clock — FSPI (GPIO11). */
|
|
76
|
+
export const SCK = GPIO11;
|
|
77
|
+
/** SPI0 slave select — FSPI (GPIO10). */
|
|
78
|
+
export const SS = GPIO10;
|
|
79
|
+
|
|
80
|
+
/** UART0 transmit (GPIO43). */
|
|
81
|
+
export const TX = GPIO43;
|
|
82
|
+
/** UART0 receive (GPIO44). */
|
|
83
|
+
export const RX = GPIO44;
|