@typecad/mcu-esp32c6 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 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-esp32c6
2
+
3
+ MCU definition package for the **ESP32-C6** (single-core 32-bit RISC-V @ 160 MHz, Wi-Fi 6 + BLE 5.3 + Thread/Zigbee 802.15.4). 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-esp32c6`](../board-esp32c6)) 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`–`GPIO27`
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-C6 peripheral summary
16
+
17
+ | Peripheral | Count | Notes |
18
+ |---|---|---|
19
+ | **UART** | 2 | USART0–1 |
20
+ | **I2C** | 2 | I2C0–1 (GPIO matrix) |
21
+ | **SPI** | 3 | SPI0–2 (SPI0/1 for flash, SPI2 general-purpose) |
22
+ | **ADC** | 2 | ADC1 (7 channels), ADC2 (7 channels), 12-bit |
23
+ | **Timers** | 4 | 52-bit general-purpose timers |
24
+ | **PWM (LEDC)** | 6 channels | All low-speed group |
25
+ | **802.15.4** | 1 | Thread/Zigbee radio (in addition to Wi-Fi 6 + BLE) |
26
+
27
+ ## How board packages use this
28
+
29
+ ```typescript
30
+ // In @typecad/board-esp32c6
31
+ export * from '@typecad/mcu-esp32c6'; // silicon pins + peripherals
32
+ export * from '@typecad/hal'; // HAL utilities (delay, Pin, etc.)
33
+ ```
34
+
35
+ ## Related packages
36
+
37
+ - [`@typecad/board-esp32c6`](../board-esp32c6) — 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
@@ -0,0 +1,14 @@
1
+ import type { MCUDefinition } from '@typecad/cuttlefish/api/schema';
2
+ export declare const ESP32C6: MCUDefinition;
3
+ export default ESP32C6;
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
+ 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", "GPIO22", "GPIO23", "GPIO24", "GPIO25", "GPIO26", "GPIO27", "GPIO28", "GPIO29", "GPIO30"];
13
+ readonly peripheralNames: readonly ["I2C0", "SPI0", "UART0", "UART1"];
14
+ };
package/dist/index.js ADDED
@@ -0,0 +1,176 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/mcu-esp32c6 — MCU definition manifest
3
+ //
4
+ // ESP32-C6 is a single-core RISC-V (RV32IMAC) @ 160 MHz with Wi-Fi 6
5
+ // (802.11ax) + BLE 5.3 and native USB Serial/JTAG + USB-OTG. It has 30 GPIO
6
+ // (0-7, 8-14, 15-30). All GPIOs are bidirectional. No DAC. No PSRAM.
7
+ // ---------------------------------------------------------------------------
8
+ import { MCU_PERIPHERALS } from './peripherals.js';
9
+ const NO = false;
10
+ const YES = true;
11
+ const FULL_GPIO = {
12
+ digitalInput: YES, digitalOutput: YES,
13
+ analogInput: NO, analogOutput: NO,
14
+ pwm: YES, interrupt: YES,
15
+ pullUp: YES, pullDown: YES,
16
+ touch: NO, openDrain: NO,
17
+ };
18
+ const FULL_GPIO_ANALOG = { ...FULL_GPIO, analogInput: YES };
19
+ // No FULL_GPIO_ANALOG_TOUCH — the C6 has no exposed touch peripheral.
20
+ function adc(n, ch) {
21
+ return { type: 'adc', instance: n, role: `ch${ch}` };
22
+ }
23
+ export const ESP32C6 = {
24
+ id: 'esp32-c6',
25
+ name: 'ESP32-C6',
26
+ architecture: 'esp32c6',
27
+ memory: {
28
+ flash: 384 * 1024,
29
+ sram: 512 * 1024,
30
+ eeprom: 0,
31
+ rtcMemory: 16 * 1024,
32
+ },
33
+ pins: {
34
+ all: [
35
+ // ---- ADC1 pins (GPIO0-GPIO6) — no touch on the C6 --------------------
36
+ { number: 0, gpio: 0, name: 'GPIO0', capabilities: FULL_GPIO_ANALOG,
37
+ functions: [adc(1, 0)], alternateFunctions: ['ADC1_CH0'] },
38
+ { number: 1, gpio: 1, name: 'GPIO1', capabilities: FULL_GPIO_ANALOG,
39
+ functions: [adc(1, 1)], alternateFunctions: ['ADC1_CH1'] },
40
+ { number: 2, gpio: 2, name: 'GPIO2', capabilities: FULL_GPIO_ANALOG,
41
+ functions: [adc(1, 2)], alternateFunctions: ['ADC1_CH2'] },
42
+ { number: 3, gpio: 3, name: 'GPIO3', capabilities: FULL_GPIO_ANALOG,
43
+ functions: [adc(1, 3)], alternateFunctions: ['ADC1_CH3'] },
44
+ { number: 4, gpio: 4, name: 'GPIO4', capabilities: FULL_GPIO_ANALOG,
45
+ functions: [adc(1, 4)], alternateFunctions: ['ADC1_CH4'] },
46
+ { number: 5, gpio: 5, name: 'GPIO5', capabilities: FULL_GPIO_ANALOG,
47
+ functions: [adc(1, 5)], alternateFunctions: ['ADC1_CH5'] },
48
+ { number: 6, gpio: 6, name: 'GPIO6', capabilities: FULL_GPIO_ANALOG,
49
+ functions: [adc(1, 6)], alternateFunctions: ['ADC1_CH6'] },
50
+ // ---- ADC2 pin (GPIO7) — Wi-Fi conflicted ------------------------------
51
+ { number: 7, gpio: 7, name: 'GPIO7', capabilities: FULL_GPIO_ANALOG,
52
+ functions: [adc(2, 0)],
53
+ alternateFunctions: ['ADC2_CH0'],
54
+ warnings: ['GPIO7 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
55
+ { number: 8, gpio: 8, name: 'GPIO8', capabilities: FULL_GPIO,
56
+ alternateFunctions: [] },
57
+ // ---- Strapping pins (unsafe) -----------------------------------------
58
+ { number: 9, gpio: 9, name: 'GPIO9', capabilities: FULL_GPIO,
59
+ alternateFunctions: [],
60
+ warnings: ['GPIO9 is a strapping pin — boot mode select at boot'],
61
+ unsafe: true, notes: 'Boot strapping pin' },
62
+ { number: 10, gpio: 10, name: 'GPIO10', capabilities: FULL_GPIO, alternateFunctions: [] },
63
+ { number: 11, gpio: 11, name: 'GPIO11', capabilities: FULL_GPIO, alternateFunctions: [] },
64
+ { number: 12, gpio: 12, name: 'GPIO12', capabilities: FULL_GPIO, alternateFunctions: [] },
65
+ { number: 13, gpio: 13, name: 'GPIO13', capabilities: FULL_GPIO,
66
+ alternateFunctions: [],
67
+ warnings: ['GPIO13 is a strapping pin — controls VDD_SPI voltage at boot'],
68
+ unsafe: true, notes: 'Boot strapping pin' },
69
+ { number: 14, gpio: 14, name: 'GPIO14', capabilities: FULL_GPIO, alternateFunctions: [] },
70
+ // ---- GPIO 15-25 — general purpose (incl. bus defaults) ---------------
71
+ { number: 15, gpio: 15, name: 'GPIO15', capabilities: FULL_GPIO, alternateFunctions: [] },
72
+ { number: 16, gpio: 16, name: 'GPIO16', capabilities: FULL_GPIO,
73
+ functions: [{ type: 'uart', instance: 0, role: 'tx' }],
74
+ alternateFunctions: ['UART0 TX'],
75
+ warnings: ['Using GPIO16 as GPIO will interfere with UART0 transmit'] },
76
+ { number: 17, gpio: 17, name: 'GPIO17', capabilities: FULL_GPIO,
77
+ functions: [{ type: 'uart', instance: 0, role: 'rx' }],
78
+ alternateFunctions: ['UART0 RX'],
79
+ warnings: ['Using GPIO17 as GPIO will interfere with UART0 receive'] },
80
+ { number: 18, gpio: 18, name: 'GPIO18', capabilities: FULL_GPIO,
81
+ functions: [{ type: 'spi', instance: 0, role: 'cs' }],
82
+ alternateFunctions: ['SPI0 CS'] },
83
+ { number: 19, gpio: 19, name: 'GPIO19', capabilities: FULL_GPIO,
84
+ functions: [{ type: 'spi', instance: 0, role: 'mosi' }],
85
+ alternateFunctions: ['SPI0 MOSI'] },
86
+ { number: 20, gpio: 20, name: 'GPIO20', capabilities: FULL_GPIO,
87
+ functions: [{ type: 'spi', instance: 0, role: 'miso' }],
88
+ alternateFunctions: ['SPI0 MISO'] },
89
+ { number: 21, gpio: 21, name: 'GPIO21', capabilities: FULL_GPIO,
90
+ functions: [{ type: 'spi', instance: 0, role: 'sck' }],
91
+ alternateFunctions: ['SPI0 SCK'] },
92
+ { number: 22, gpio: 22, name: 'GPIO22', capabilities: FULL_GPIO,
93
+ functions: [{ type: 'i2c', instance: 0, role: 'scl' }],
94
+ alternateFunctions: ['I2C0 SCL'] },
95
+ { number: 23, gpio: 23, name: 'GPIO23', capabilities: FULL_GPIO,
96
+ functions: [{ type: 'i2c', instance: 0, role: 'sda' }],
97
+ alternateFunctions: ['I2C0 SDA'] },
98
+ { number: 24, gpio: 24, name: 'GPIO24', capabilities: FULL_GPIO, alternateFunctions: [] },
99
+ { number: 25, gpio: 25, name: 'GPIO25', capabilities: FULL_GPIO, alternateFunctions: [] },
100
+ // ---- USB Serial/JTAG + USB-OTG pins (unsafe) -------------------------
101
+ { number: 26, gpio: 26, name: 'GPIO26', capabilities: FULL_GPIO,
102
+ functions: [{ type: 'usb', instance: 0, role: 'dm' }],
103
+ alternateFunctions: ['USB D-'],
104
+ warnings: ['GPIO26 is USB D- — using it as GPIO disables native USB'],
105
+ unsafe: true, notes: 'USB D- pin' },
106
+ { number: 27, gpio: 27, name: 'GPIO27', capabilities: FULL_GPIO,
107
+ functions: [{ type: 'usb', instance: 0, role: 'dp' }],
108
+ alternateFunctions: ['USB D+'],
109
+ warnings: ['GPIO27 is USB D+ — using it as GPIO disables native USB'],
110
+ unsafe: true, notes: 'USB D+ pin' },
111
+ // ---- SPI flash / PSRAM pins (unsafe) ---------------------------------
112
+ { number: 28, gpio: 28, name: 'GPIO28', capabilities: FULL_GPIO,
113
+ alternateFunctions: ['SPICS0'],
114
+ warnings: ['GPIO28 is connected to SPI flash — do not use as GPIO'],
115
+ unsafe: true, notes: 'SPI flash pin' },
116
+ { number: 29, gpio: 29, name: 'GPIO29', capabilities: FULL_GPIO,
117
+ alternateFunctions: ['SPICLK'],
118
+ warnings: ['GPIO29 is connected to SPI flash — do not use as GPIO'],
119
+ unsafe: true, notes: 'SPI flash pin' },
120
+ { number: 30, gpio: 30, name: 'GPIO30', capabilities: FULL_GPIO,
121
+ alternateFunctions: ['SPIQ'],
122
+ warnings: ['GPIO30 is connected to SPI flash — do not use as GPIO'],
123
+ unsafe: true, notes: 'SPI flash pin' },
124
+ ],
125
+ digital: [
126
+ 'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
127
+ 'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
128
+ 'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
129
+ 'GPIO22', 'GPIO23', 'GPIO24', 'GPIO25', 'GPIO26', 'GPIO27', 'GPIO28',
130
+ 'GPIO29', 'GPIO30',
131
+ ],
132
+ analog: [
133
+ 'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', // ADC1
134
+ 'GPIO7', // ADC2
135
+ ],
136
+ pwm: [
137
+ 'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
138
+ 'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
139
+ 'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
140
+ 'GPIO22', 'GPIO23', 'GPIO24', 'GPIO25',
141
+ ],
142
+ unsafe: ['GPIO9', 'GPIO13', 'GPIO26', 'GPIO27', 'GPIO28', 'GPIO29', 'GPIO30'],
143
+ i2c: { 0: { sda: 'GPIO23', scl: 'GPIO22' } },
144
+ spi: { 0: { mosi: 'GPIO19', miso: 'GPIO20', sck: 'GPIO21', cs: 'GPIO18' } },
145
+ uart: { 0: { tx: 'GPIO16', rx: 'GPIO17' } },
146
+ },
147
+ peripherals: MCU_PERIPHERALS,
148
+ features: {
149
+ multicore: false,
150
+ coreCount: 1,
151
+ deepSleep: true,
152
+ watchdog: true,
153
+ externalInterrupts: true,
154
+ hardwareRng: true,
155
+ fpu: false,
156
+ },
157
+ build: { extraFlags: [] },
158
+ };
159
+ export default ESP32C6;
160
+ export * from './pins.js';
161
+ export * from './peripherals.js';
162
+ /**
163
+ * Structured manifest consumed by the TypeCAD CLI for contract-based
164
+ * board generation. Provides pin names and peripheral instance names
165
+ * without requiring the CLI to text-scrape compiled output.
166
+ */
167
+ export const TypeCADManifest = {
168
+ pinNames: [
169
+ 'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
170
+ 'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
171
+ 'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
172
+ 'GPIO22', 'GPIO23', 'GPIO24', 'GPIO25', 'GPIO26', 'GPIO27', 'GPIO28',
173
+ 'GPIO29', 'GPIO30',
174
+ ],
175
+ peripheralNames: ['I2C0', 'SPI0', 'UART0', 'UART1'],
176
+ };
@@ -0,0 +1,47 @@
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 TIMER_INSTANCES: readonly TimerDefinition[];
9
+ export declare const WIFI_CAPABILITIES: {
10
+ readonly type: "wifi6";
11
+ readonly supportsStation: true;
12
+ readonly supportsAp: true;
13
+ };
14
+ export declare const BLUETOOTH_CAPABILITIES: {
15
+ readonly type: "ble";
16
+ readonly version: "5.3";
17
+ };
18
+ export declare const USB_CAPABILITIES: {
19
+ readonly type: "otg";
20
+ readonly vid: "0x303A";
21
+ readonly pid: "0x0001";
22
+ };
23
+ export declare const MCU_PERIPHERALS: {
24
+ readonly i2c: readonly PeripheralInstance[];
25
+ readonly spi: readonly PeripheralInstance[];
26
+ readonly uart: readonly PeripheralInstance[];
27
+ readonly adc: readonly ADCDefinition[];
28
+ readonly pwm: PWMDefinition;
29
+ readonly timers: readonly TimerDefinition[];
30
+ readonly wifi: {
31
+ readonly type: "wifi6";
32
+ readonly supportsStation: true;
33
+ readonly supportsAp: true;
34
+ };
35
+ readonly bluetooth: {
36
+ readonly type: "ble";
37
+ readonly version: "5.3";
38
+ };
39
+ readonly usb: {
40
+ readonly type: "otg";
41
+ readonly vid: "0x303A";
42
+ readonly pid: "0x0001";
43
+ };
44
+ };
45
+ export declare const I2C0: I2CBus;
46
+ export declare const SPI0: SPIBus;
47
+ export declare const UART0: SerialPort, UART1: SerialPort;
@@ -0,0 +1,53 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/mcu-esp32c6 — Hardware peripheral descriptions
3
+ //
4
+ // ESP32-C6 peripherals: 1× I2C, 1× SPI, 2× UART, 2× ADC (12-bit),
5
+ // 4× general-purpose timers, Wi-Fi 6 (802.11ax), BLE 5.3, USB Serial/JTAG +
6
+ // USB-OTG. No DAC. No touch (the C6's touch peripheral is non-standard and
7
+ // not exposed by the Arduino core).
8
+ // ---------------------------------------------------------------------------
9
+ import { I2CBus, SPIBus, SerialPort, i2cName, spiName, serialName, createHALInstances, } from '@typecad/hal';
10
+ export const I2C_INSTANCES = [
11
+ { instance: 0, defaultPins: { sda: 'GPIO23', scl: 'GPIO22' } },
12
+ ];
13
+ export const SPI_INSTANCES = [
14
+ { instance: 0, defaultPins: { mosi: 'GPIO19', miso: 'GPIO20', sck: 'GPIO21', cs: 'GPIO18' } },
15
+ ];
16
+ export const UART_INSTANCES = [
17
+ { instance: 0, defaultPins: { tx: 'GPIO16', rx: 'GPIO17' } },
18
+ { instance: 1, defaultPins: { tx: 'GPIO16', rx: 'GPIO17' } },
19
+ ];
20
+ export const ADC_INSTANCES = [
21
+ { instance: 0, channels: 7, resolution: 12, referenceVoltage: 3.3, maxValue: 4095,
22
+ referenceVoltages: { DEFAULT: 3.3, INTERNAL: 1.1 } }, // ADC1 — usable with Wi-Fi active
23
+ { instance: 1, channels: 1, resolution: 12, referenceVoltage: 3.3, maxValue: 4095,
24
+ referenceVoltages: { DEFAULT: 3.3, INTERNAL: 1.1 } }, // ADC2 — NOT usable with Wi-Fi active
25
+ ];
26
+ export const PWM_CAPABILITIES = {
27
+ channels: 6, resolution: 14, maxFrequency: 40_000_000,
28
+ };
29
+ // No TOUCH_CAPABILITIES — the C6's touch peripheral is non-standard and not
30
+ // exposed by the Arduino core.
31
+ export const TIMER_INSTANCES = [
32
+ { instance: 0, type: 'general', bits: 64, features: ['interrupt'] },
33
+ { instance: 1, type: 'general', bits: 64, features: ['interrupt'] },
34
+ { instance: 2, type: 'general', bits: 64, features: ['interrupt'] },
35
+ { instance: 3, type: 'general', bits: 64, features: ['interrupt'] },
36
+ ];
37
+ export const WIFI_CAPABILITIES = { type: 'wifi6', supportsStation: true, supportsAp: true };
38
+ export const BLUETOOTH_CAPABILITIES = { type: 'ble', version: '5.3' };
39
+ export const USB_CAPABILITIES = { type: 'otg', vid: '0x303A', pid: '0x0001' };
40
+ export const MCU_PERIPHERALS = {
41
+ i2c: [...I2C_INSTANCES],
42
+ spi: [...SPI_INSTANCES],
43
+ uart: [...UART_INSTANCES],
44
+ adc: [...ADC_INSTANCES],
45
+ pwm: PWM_CAPABILITIES,
46
+ timers: [...TIMER_INSTANCES],
47
+ wifi: WIFI_CAPABILITIES,
48
+ bluetooth: BLUETOOTH_CAPABILITIES,
49
+ usb: USB_CAPABILITIES,
50
+ };
51
+ export const [I2C0] = createHALInstances(I2C_INSTANCES, i => new I2CBus(i2cName(i)));
52
+ export const [SPI0] = createHALInstances(SPI_INSTANCES, i => new SPIBus(spiName(i)));
53
+ export const [UART0, UART1] = createHALInstances(UART_INSTANCES, i => new SerialPort(serialName(i)));
package/dist/pins.d.ts ADDED
@@ -0,0 +1,48 @@
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 GPIO22: Pin;
25
+ export declare const GPIO23: Pin;
26
+ export declare const GPIO24: Pin;
27
+ export declare const GPIO25: Pin;
28
+ export declare const GPIO26: Pin;
29
+ export declare const GPIO27: Pin;
30
+ export declare const GPIO28: Pin;
31
+ export declare const GPIO29: Pin;
32
+ export declare const GPIO30: Pin;
33
+ /** I2C0 data line (GPIO23). */
34
+ export declare const SDA: Pin;
35
+ /** I2C0 clock line (GPIO22). */
36
+ export declare const SCL: Pin;
37
+ /** SPI0 MOSI (GPIO19). */
38
+ export declare const MOSI: Pin;
39
+ /** SPI0 MISO (GPIO20). */
40
+ export declare const MISO: Pin;
41
+ /** SPI0 clock (GPIO21). */
42
+ export declare const SCK: Pin;
43
+ /** SPI0 slave select (GPIO18). */
44
+ export declare const SS: Pin;
45
+ /** UART0 transmit (GPIO16). */
46
+ export declare const TX: Pin;
47
+ /** UART0 receive (GPIO17). */
48
+ export declare const RX: Pin;
package/dist/pins.js ADDED
@@ -0,0 +1,57 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/mcu-esp32c6 — Datasheet pin definitions
3
+ //
4
+ // Each pin is a Pin instance from @typecad/hal. The ESP32-C6 has 30 GPIO
5
+ // (0-7, 8-14, 15-30). All GPIOs are bidirectional. No DAC. No PSRAM.
6
+ // ---------------------------------------------------------------------------
7
+ import { Pin } from '@typecad/hal';
8
+ export const GPIO0 = new Pin(0);
9
+ export const GPIO1 = new Pin(1);
10
+ export const GPIO2 = new Pin(2);
11
+ export const GPIO3 = new Pin(3);
12
+ export const GPIO4 = new Pin(4);
13
+ export const GPIO5 = new Pin(5);
14
+ export const GPIO6 = new Pin(6);
15
+ export const GPIO7 = new Pin(7);
16
+ export const GPIO8 = new Pin(8);
17
+ export const GPIO9 = new Pin(9);
18
+ export const GPIO10 = new Pin(10);
19
+ export const GPIO11 = new Pin(11);
20
+ export const GPIO12 = new Pin(12);
21
+ export const GPIO13 = new Pin(13);
22
+ export const GPIO14 = new Pin(14);
23
+ export const GPIO15 = new Pin(15);
24
+ export const GPIO16 = new Pin(16);
25
+ export const GPIO17 = new Pin(17);
26
+ export const GPIO18 = new Pin(18);
27
+ export const GPIO19 = new Pin(19);
28
+ export const GPIO20 = new Pin(20);
29
+ export const GPIO21 = new Pin(21);
30
+ export const GPIO22 = new Pin(22);
31
+ export const GPIO23 = new Pin(23);
32
+ export const GPIO24 = new Pin(24);
33
+ export const GPIO25 = new Pin(25);
34
+ export const GPIO26 = new Pin(26);
35
+ export const GPIO27 = new Pin(27);
36
+ export const GPIO28 = new Pin(28);
37
+ export const GPIO29 = new Pin(29);
38
+ export const GPIO30 = new Pin(30);
39
+ // ---------------------------------------------------------------------------
40
+ // Convenience aliases (Silicon-level defaults — match Arduino-ESP32 core)
41
+ // ---------------------------------------------------------------------------
42
+ /** I2C0 data line (GPIO23). */
43
+ export const SDA = GPIO23;
44
+ /** I2C0 clock line (GPIO22). */
45
+ export const SCL = GPIO22;
46
+ /** SPI0 MOSI (GPIO19). */
47
+ export const MOSI = GPIO19;
48
+ /** SPI0 MISO (GPIO20). */
49
+ export const MISO = GPIO20;
50
+ /** SPI0 clock (GPIO21). */
51
+ export const SCK = GPIO21;
52
+ /** SPI0 slave select (GPIO18). */
53
+ export const SS = GPIO18;
54
+ /** UART0 transmit (GPIO16). */
55
+ export const TX = GPIO16;
56
+ /** UART0 receive (GPIO17). */
57
+ export const RX = GPIO17;
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@typecad/mcu-esp32c6",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "TypeCAD MCU definition for ESP32-C6 — 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-esp32c6"
28
+ },
29
+ "homepage": "https://github.com/justind000/typecode/tree/main/packages/mcu-esp32c6",
30
+ "bugs": {
31
+ "url": "https://github.com/justind000/typecode/issues"
32
+ },
33
+ "keywords": [
34
+ "arduino",
35
+ "cpp",
36
+ "cuttlefish",
37
+ "embedded",
38
+ "esp32c6",
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,199 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/mcu-esp32c6 — MCU definition manifest
3
+ //
4
+ // ESP32-C6 is a single-core RISC-V (RV32IMAC) @ 160 MHz with Wi-Fi 6
5
+ // (802.11ax) + BLE 5.3 and native USB Serial/JTAG + USB-OTG. It has 30 GPIO
6
+ // (0-7, 8-14, 15-30). All GPIOs are bidirectional. No DAC. No PSRAM.
7
+ // ---------------------------------------------------------------------------
8
+
9
+ import type { MCUDefinition } from '@typecad/cuttlefish/api/schema';
10
+ import { MCU_PERIPHERALS } from './peripherals.js';
11
+
12
+ const NO = false as const;
13
+ const YES = true as const;
14
+
15
+ const FULL_GPIO = {
16
+ digitalInput: YES, digitalOutput: YES,
17
+ analogInput: NO, analogOutput: NO,
18
+ pwm: YES, interrupt: YES,
19
+ pullUp: YES, pullDown: YES,
20
+ touch: NO, openDrain: NO,
21
+ } as const;
22
+
23
+ const FULL_GPIO_ANALOG = { ...FULL_GPIO, analogInput: YES } as const;
24
+ // No FULL_GPIO_ANALOG_TOUCH — the C6 has no exposed touch peripheral.
25
+
26
+ function adc(n: number, ch: number) {
27
+ return { type: 'adc' as const, instance: n, role: `ch${ch}` };
28
+ }
29
+
30
+ export const ESP32C6: MCUDefinition = {
31
+ id: 'esp32-c6',
32
+ name: 'ESP32-C6',
33
+ architecture: 'esp32c6',
34
+ memory: {
35
+ flash: 384 * 1024,
36
+ sram: 512 * 1024,
37
+ eeprom: 0,
38
+ rtcMemory: 16 * 1024,
39
+ },
40
+ pins: {
41
+ all: [
42
+ // ---- ADC1 pins (GPIO0-GPIO6) — no touch on the C6 --------------------
43
+ { number: 0, gpio: 0, name: 'GPIO0', capabilities: FULL_GPIO_ANALOG,
44
+ functions: [adc(1, 0)], alternateFunctions: ['ADC1_CH0'] },
45
+ { number: 1, gpio: 1, name: 'GPIO1', capabilities: FULL_GPIO_ANALOG,
46
+ functions: [adc(1, 1)], alternateFunctions: ['ADC1_CH1'] },
47
+ { number: 2, gpio: 2, name: 'GPIO2', capabilities: FULL_GPIO_ANALOG,
48
+ functions: [adc(1, 2)], alternateFunctions: ['ADC1_CH2'] },
49
+ { number: 3, gpio: 3, name: 'GPIO3', capabilities: FULL_GPIO_ANALOG,
50
+ functions: [adc(1, 3)], alternateFunctions: ['ADC1_CH3'] },
51
+ { number: 4, gpio: 4, name: 'GPIO4', capabilities: FULL_GPIO_ANALOG,
52
+ functions: [adc(1, 4)], alternateFunctions: ['ADC1_CH4'] },
53
+ { number: 5, gpio: 5, name: 'GPIO5', capabilities: FULL_GPIO_ANALOG,
54
+ functions: [adc(1, 5)], alternateFunctions: ['ADC1_CH5'] },
55
+ { number: 6, gpio: 6, name: 'GPIO6', capabilities: FULL_GPIO_ANALOG,
56
+ functions: [adc(1, 6)], alternateFunctions: ['ADC1_CH6'] },
57
+
58
+ // ---- ADC2 pin (GPIO7) — Wi-Fi conflicted ------------------------------
59
+ { number: 7, gpio: 7, name: 'GPIO7', capabilities: FULL_GPIO_ANALOG,
60
+ functions: [adc(2, 0)],
61
+ alternateFunctions: ['ADC2_CH0'],
62
+ warnings: ['GPIO7 is ADC2 — ADC2 is unusable while Wi-Fi is enabled'] },
63
+
64
+ { number: 8, gpio: 8, name: 'GPIO8', capabilities: FULL_GPIO,
65
+ alternateFunctions: [] },
66
+
67
+ // ---- Strapping pins (unsafe) -----------------------------------------
68
+ { number: 9, gpio: 9, name: 'GPIO9', capabilities: FULL_GPIO,
69
+ alternateFunctions: [],
70
+ warnings: ['GPIO9 is a strapping pin — boot mode select at boot'],
71
+ unsafe: true, notes: 'Boot strapping pin' },
72
+
73
+ { number: 10, gpio: 10, name: 'GPIO10', capabilities: FULL_GPIO, alternateFunctions: [] },
74
+ { number: 11, gpio: 11, name: 'GPIO11', capabilities: FULL_GPIO, alternateFunctions: [] },
75
+ { number: 12, gpio: 12, name: 'GPIO12', capabilities: FULL_GPIO, alternateFunctions: [] },
76
+
77
+ { number: 13, gpio: 13, name: 'GPIO13', capabilities: FULL_GPIO,
78
+ alternateFunctions: [],
79
+ warnings: ['GPIO13 is a strapping pin — controls VDD_SPI voltage at boot'],
80
+ unsafe: true, notes: 'Boot strapping pin' },
81
+
82
+ { number: 14, gpio: 14, name: 'GPIO14', capabilities: FULL_GPIO, alternateFunctions: [] },
83
+
84
+ // ---- GPIO 15-25 — general purpose (incl. bus defaults) ---------------
85
+ { number: 15, gpio: 15, name: 'GPIO15', capabilities: FULL_GPIO, alternateFunctions: [] },
86
+ { number: 16, gpio: 16, name: 'GPIO16', capabilities: FULL_GPIO,
87
+ functions: [{ type: 'uart', instance: 0, role: 'tx' }],
88
+ alternateFunctions: ['UART0 TX'],
89
+ warnings: ['Using GPIO16 as GPIO will interfere with UART0 transmit'] },
90
+ { number: 17, gpio: 17, name: 'GPIO17', capabilities: FULL_GPIO,
91
+ functions: [{ type: 'uart', instance: 0, role: 'rx' }],
92
+ alternateFunctions: ['UART0 RX'],
93
+ warnings: ['Using GPIO17 as GPIO will interfere with UART0 receive'] },
94
+ { number: 18, gpio: 18, name: 'GPIO18', capabilities: FULL_GPIO,
95
+ functions: [{ type: 'spi', instance: 0, role: 'cs' }],
96
+ alternateFunctions: ['SPI0 CS'] },
97
+ { number: 19, gpio: 19, name: 'GPIO19', capabilities: FULL_GPIO,
98
+ functions: [{ type: 'spi', instance: 0, role: 'mosi' }],
99
+ alternateFunctions: ['SPI0 MOSI'] },
100
+ { number: 20, gpio: 20, name: 'GPIO20', capabilities: FULL_GPIO,
101
+ functions: [{ type: 'spi', instance: 0, role: 'miso' }],
102
+ alternateFunctions: ['SPI0 MISO'] },
103
+ { number: 21, gpio: 21, name: 'GPIO21', capabilities: FULL_GPIO,
104
+ functions: [{ type: 'spi', instance: 0, role: 'sck' }],
105
+ alternateFunctions: ['SPI0 SCK'] },
106
+ { number: 22, gpio: 22, name: 'GPIO22', capabilities: FULL_GPIO,
107
+ functions: [{ type: 'i2c', instance: 0, role: 'scl' }],
108
+ alternateFunctions: ['I2C0 SCL'] },
109
+ { number: 23, gpio: 23, name: 'GPIO23', capabilities: FULL_GPIO,
110
+ functions: [{ type: 'i2c', instance: 0, role: 'sda' }],
111
+ alternateFunctions: ['I2C0 SDA'] },
112
+ { number: 24, gpio: 24, name: 'GPIO24', capabilities: FULL_GPIO, alternateFunctions: [] },
113
+ { number: 25, gpio: 25, name: 'GPIO25', capabilities: FULL_GPIO, alternateFunctions: [] },
114
+
115
+ // ---- USB Serial/JTAG + USB-OTG pins (unsafe) -------------------------
116
+ { number: 26, gpio: 26, name: 'GPIO26', capabilities: FULL_GPIO,
117
+ functions: [{ type: 'usb', instance: 0, role: 'dm' }],
118
+ alternateFunctions: ['USB D-'],
119
+ warnings: ['GPIO26 is USB D- — using it as GPIO disables native USB'],
120
+ unsafe: true, notes: 'USB D- pin' },
121
+ { number: 27, gpio: 27, name: 'GPIO27', capabilities: FULL_GPIO,
122
+ functions: [{ type: 'usb', instance: 0, role: 'dp' }],
123
+ alternateFunctions: ['USB D+'],
124
+ warnings: ['GPIO27 is USB D+ — using it as GPIO disables native USB'],
125
+ unsafe: true, notes: 'USB D+ pin' },
126
+
127
+ // ---- SPI flash / PSRAM pins (unsafe) ---------------------------------
128
+ { number: 28, gpio: 28, name: 'GPIO28', capabilities: FULL_GPIO,
129
+ alternateFunctions: ['SPICS0'],
130
+ warnings: ['GPIO28 is connected to SPI flash — do not use as GPIO'],
131
+ unsafe: true, notes: 'SPI flash pin' },
132
+ { number: 29, gpio: 29, name: 'GPIO29', capabilities: FULL_GPIO,
133
+ alternateFunctions: ['SPICLK'],
134
+ warnings: ['GPIO29 is connected to SPI flash — do not use as GPIO'],
135
+ unsafe: true, notes: 'SPI flash pin' },
136
+ { number: 30, gpio: 30, name: 'GPIO30', capabilities: FULL_GPIO,
137
+ alternateFunctions: ['SPIQ'],
138
+ warnings: ['GPIO30 is connected to SPI flash — do not use as GPIO'],
139
+ unsafe: true, notes: 'SPI flash pin' },
140
+ ],
141
+
142
+ digital: [
143
+ 'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
144
+ 'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
145
+ 'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
146
+ 'GPIO22', 'GPIO23', 'GPIO24', 'GPIO25', 'GPIO26', 'GPIO27', 'GPIO28',
147
+ 'GPIO29', 'GPIO30',
148
+ ],
149
+ analog: [
150
+ 'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', // ADC1
151
+ 'GPIO7', // ADC2
152
+ ],
153
+ pwm: [
154
+ 'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
155
+ 'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
156
+ 'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
157
+ 'GPIO22', 'GPIO23', 'GPIO24', 'GPIO25',
158
+ ],
159
+ unsafe: ['GPIO9', 'GPIO13', 'GPIO26', 'GPIO27', 'GPIO28', 'GPIO29', 'GPIO30'],
160
+
161
+ i2c: { 0: { sda: 'GPIO23', scl: 'GPIO22' } },
162
+ spi: { 0: { mosi: 'GPIO19', miso: 'GPIO20', sck: 'GPIO21', cs: 'GPIO18' } },
163
+ uart: { 0: { tx: 'GPIO16', rx: 'GPIO17' } },
164
+ },
165
+
166
+ peripherals: MCU_PERIPHERALS,
167
+
168
+ features: {
169
+ multicore: false,
170
+ coreCount: 1,
171
+ deepSleep: true,
172
+ watchdog: true,
173
+ externalInterrupts: true,
174
+ hardwareRng: true,
175
+ fpu: false,
176
+ },
177
+ build: { extraFlags: [] },
178
+ };
179
+
180
+ export default ESP32C6;
181
+
182
+ export * from './pins.js';
183
+ export * from './peripherals.js';
184
+
185
+ /**
186
+ * Structured manifest consumed by the TypeCAD CLI for contract-based
187
+ * board generation. Provides pin names and peripheral instance names
188
+ * without requiring the CLI to text-scrape compiled output.
189
+ */
190
+ export const TypeCADManifest = {
191
+ pinNames: [
192
+ 'GPIO0', 'GPIO1', 'GPIO2', 'GPIO3', 'GPIO4', 'GPIO5', 'GPIO6', 'GPIO7',
193
+ 'GPIO8', 'GPIO9', 'GPIO10', 'GPIO11', 'GPIO12', 'GPIO13', 'GPIO14',
194
+ 'GPIO15', 'GPIO16', 'GPIO17', 'GPIO18', 'GPIO19', 'GPIO20', 'GPIO21',
195
+ 'GPIO22', 'GPIO23', 'GPIO24', 'GPIO25', 'GPIO26', 'GPIO27', 'GPIO28',
196
+ 'GPIO29', 'GPIO30',
197
+ ] as const,
198
+ peripheralNames: ['I2C0', 'SPI0', 'UART0', 'UART1'] as const,
199
+ } as const;
@@ -0,0 +1,69 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/mcu-esp32c6 — Hardware peripheral descriptions
3
+ //
4
+ // ESP32-C6 peripherals: 1× I2C, 1× SPI, 2× UART, 2× ADC (12-bit),
5
+ // 4× general-purpose timers, Wi-Fi 6 (802.11ax), BLE 5.3, USB Serial/JTAG +
6
+ // USB-OTG. No DAC. No touch (the C6's touch peripheral is non-standard and
7
+ // not exposed by the Arduino core).
8
+ // ---------------------------------------------------------------------------
9
+
10
+ import type {
11
+ PeripheralInstance, ADCDefinition, PWMDefinition, TimerDefinition,
12
+ } from '@typecad/cuttlefish/api/schema';
13
+ import {
14
+ I2CBus, SPIBus, SerialPort, i2cName, spiName, serialName, createHALInstances,
15
+ } from '@typecad/hal';
16
+
17
+ export const I2C_INSTANCES: readonly PeripheralInstance[] = [
18
+ { instance: 0, defaultPins: { sda: 'GPIO23', scl: 'GPIO22' } },
19
+ ] as const;
20
+
21
+ export const SPI_INSTANCES: readonly PeripheralInstance[] = [
22
+ { instance: 0, defaultPins: { mosi: 'GPIO19', miso: 'GPIO20', sck: 'GPIO21', cs: 'GPIO18' } },
23
+ ] as const;
24
+
25
+ export const UART_INSTANCES: readonly PeripheralInstance[] = [
26
+ { instance: 0, defaultPins: { tx: 'GPIO16', rx: 'GPIO17' } },
27
+ { instance: 1, defaultPins: { tx: 'GPIO16', rx: 'GPIO17' } },
28
+ ] as const;
29
+
30
+ export const ADC_INSTANCES: readonly ADCDefinition[] = [
31
+ { instance: 0, channels: 7, resolution: 12, referenceVoltage: 3.3, maxValue: 4095,
32
+ referenceVoltages: { DEFAULT: 3.3, INTERNAL: 1.1 } }, // ADC1 — usable with Wi-Fi active
33
+ { instance: 1, channels: 1, resolution: 12, referenceVoltage: 3.3, maxValue: 4095,
34
+ referenceVoltages: { DEFAULT: 3.3, INTERNAL: 1.1 } }, // ADC2 — NOT usable with Wi-Fi active
35
+ ] as const;
36
+
37
+ export const PWM_CAPABILITIES: PWMDefinition = {
38
+ channels: 6, resolution: 14, maxFrequency: 40_000_000,
39
+ } as const;
40
+
41
+ // No TOUCH_CAPABILITIES — the C6's touch peripheral is non-standard and not
42
+ // exposed by the Arduino core.
43
+
44
+ export const TIMER_INSTANCES: readonly TimerDefinition[] = [
45
+ { instance: 0, type: 'general', bits: 64, features: ['interrupt'] },
46
+ { instance: 1, type: 'general', bits: 64, features: ['interrupt'] },
47
+ { instance: 2, type: 'general', bits: 64, features: ['interrupt'] },
48
+ { instance: 3, type: 'general', bits: 64, features: ['interrupt'] },
49
+ ] as const;
50
+
51
+ export const WIFI_CAPABILITIES = { type: 'wifi6', supportsStation: true, supportsAp: true } as const;
52
+ export const BLUETOOTH_CAPABILITIES = { type: 'ble', version: '5.3' } as const;
53
+ export const USB_CAPABILITIES = { type: 'otg', vid: '0x303A', pid: '0x0001' } as const;
54
+
55
+ export const MCU_PERIPHERALS = {
56
+ i2c: [...I2C_INSTANCES],
57
+ spi: [...SPI_INSTANCES],
58
+ uart: [...UART_INSTANCES],
59
+ adc: [...ADC_INSTANCES],
60
+ pwm: PWM_CAPABILITIES,
61
+ timers: [...TIMER_INSTANCES],
62
+ wifi: WIFI_CAPABILITIES,
63
+ bluetooth: BLUETOOTH_CAPABILITIES,
64
+ usb: USB_CAPABILITIES,
65
+ } as const;
66
+
67
+ export const [I2C0] = createHALInstances(I2C_INSTANCES, i => new I2CBus(i2cName(i)));
68
+ export const [SPI0] = createHALInstances(SPI_INSTANCES, i => new SPIBus(spiName(i)));
69
+ export const [UART0, UART1] = createHALInstances(UART_INSTANCES, i => new SerialPort(serialName(i)));
package/src/pins.ts ADDED
@@ -0,0 +1,63 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/mcu-esp32c6 — Datasheet pin definitions
3
+ //
4
+ // Each pin is a Pin instance from @typecad/hal. The ESP32-C6 has 30 GPIO
5
+ // (0-7, 8-14, 15-30). All GPIOs are bidirectional. No DAC. No PSRAM.
6
+ // ---------------------------------------------------------------------------
7
+
8
+ import { Pin } from '@typecad/hal';
9
+
10
+ export const GPIO0 = new Pin(0);
11
+ export const GPIO1 = new Pin(1);
12
+ export const GPIO2 = new Pin(2);
13
+ export const GPIO3 = new Pin(3);
14
+ export const GPIO4 = new Pin(4);
15
+ export const GPIO5 = new Pin(5);
16
+ export const GPIO6 = new Pin(6);
17
+ export const GPIO7 = new Pin(7);
18
+ export const GPIO8 = new Pin(8);
19
+ export const GPIO9 = new Pin(9);
20
+ export const GPIO10 = new Pin(10);
21
+ export const GPIO11 = new Pin(11);
22
+ export const GPIO12 = new Pin(12);
23
+ export const GPIO13 = new Pin(13);
24
+ export const GPIO14 = new Pin(14);
25
+ export const GPIO15 = new Pin(15);
26
+ export const GPIO16 = new Pin(16);
27
+ export const GPIO17 = new Pin(17);
28
+ export const GPIO18 = new Pin(18);
29
+ export const GPIO19 = new Pin(19);
30
+ export const GPIO20 = new Pin(20);
31
+ export const GPIO21 = new Pin(21);
32
+ export const GPIO22 = new Pin(22);
33
+ export const GPIO23 = new Pin(23);
34
+ export const GPIO24 = new Pin(24);
35
+ export const GPIO25 = new Pin(25);
36
+ export const GPIO26 = new Pin(26);
37
+ export const GPIO27 = new Pin(27);
38
+ export const GPIO28 = new Pin(28);
39
+ export const GPIO29 = new Pin(29);
40
+ export const GPIO30 = new Pin(30);
41
+
42
+ // ---------------------------------------------------------------------------
43
+ // Convenience aliases (Silicon-level defaults — match Arduino-ESP32 core)
44
+ // ---------------------------------------------------------------------------
45
+
46
+ /** I2C0 data line (GPIO23). */
47
+ export const SDA = GPIO23;
48
+ /** I2C0 clock line (GPIO22). */
49
+ export const SCL = GPIO22;
50
+
51
+ /** SPI0 MOSI (GPIO19). */
52
+ export const MOSI = GPIO19;
53
+ /** SPI0 MISO (GPIO20). */
54
+ export const MISO = GPIO20;
55
+ /** SPI0 clock (GPIO21). */
56
+ export const SCK = GPIO21;
57
+ /** SPI0 slave select (GPIO18). */
58
+ export const SS = GPIO18;
59
+
60
+ /** UART0 transmit (GPIO16). */
61
+ export const TX = GPIO16;
62
+ /** UART0 receive (GPIO17). */
63
+ export const RX = GPIO17;