@typecad/board-esp32c3 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,44 @@
1
+ # @typecad/board-esp32c3
2
+
3
+ ESP32-C3 board definition package for TypeCAD.
4
+
5
+ ## Overview
6
+
7
+ `@typecad/board-esp32c3` provides typed pins, peripherals, and board metadata for boards built on the ESP32-C3 (single-core 32-bit RISC-V @ 160 MHz, Wi-Fi 4 + BLE 5). It re-exports silicon-level pin definitions from [`@typecad/mcu-esp32c3`](../mcu-esp32c3) and HAL utilities from [`@typecad/hal`](../hal).
8
+
9
+ ## Quick start
10
+
11
+ ```ts
12
+ import { GPIO2, delay } from '@typecad/board';
13
+
14
+ const led = GPIO2.asOutput(false);
15
+
16
+ while (true) {
17
+ led.toggle();
18
+ delay(1000);
19
+ }
20
+ ```
21
+
22
+ Reference this board in `cuttlefish.config.ts`:
23
+
24
+ ```ts
25
+ board: '@typecad/board-esp32c3',
26
+ ```
27
+
28
+ ## What's inside
29
+
30
+ - **GPIO pins**: `GPIO0`–`GPIO21` (silicon pins from `@typecad/mcu-esp32c3`)
31
+ - **Peripheral instances**: `I2C0`, `SPI0`, `UART0`, `ADC`
32
+ - **HAL utilities** (re-exported from `@typecad/hal`): `delay`, `millis`, `Pin`, `I2CBus`, `SPIBus`, etc.
33
+ - **Board metadata**: `BoardDefinition` manifest with PWM/analog/interrupt pin capabilities and memory specs
34
+
35
+ Direct imports from `@typecad/board-esp32c3` are also supported when you want explicit board package references.
36
+
37
+ ## Related packages
38
+
39
+ - [`@typecad/mcu-esp32c3`](../mcu-esp32c3) — silicon-level pin definitions for the ESP32-C3 chip
40
+ - [`@typecad/hal`](../hal) — hardware abstraction layer (GPIO, I2C, SPI, UART)
41
+
42
+ ## License
43
+
44
+ MIT
@@ -0,0 +1,4 @@
1
+ /** Default reference (3.3V). */
2
+ export declare const DEFAULT = 0;
3
+ /** Internal 1.1V reference. */
4
+ export declare const INTERNAL = 3;
package/dist/analog.js ADDED
@@ -0,0 +1,7 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32c3 — Analog constants
3
+ // ---------------------------------------------------------------------------
4
+ /** Default reference (3.3V). */
5
+ export const DEFAULT = 0;
6
+ /** Internal 1.1V reference. */
7
+ export const INTERNAL = 3;
@@ -0,0 +1,62 @@
1
+ import type { BoardDefinition } from '@typecad/cuttlefish/api/schema';
2
+ import * as boardIndex from './index.js';
3
+ export declare const Board: {
4
+ readonly definition: BoardDefinition;
5
+ D2: boardIndex.Pin;
6
+ D3: boardIndex.Pin;
7
+ D4: boardIndex.Pin;
8
+ D5: boardIndex.Pin;
9
+ D6: boardIndex.Pin;
10
+ D7: boardIndex.Pin;
11
+ D8: boardIndex.Pin;
12
+ D9: boardIndex.Pin;
13
+ D10: boardIndex.Pin;
14
+ D12: boardIndex.Pin;
15
+ D13: boardIndex.Pin;
16
+ D14: boardIndex.Pin;
17
+ D15: boardIndex.Pin;
18
+ D16: boardIndex.Pin;
19
+ D17: boardIndex.Pin;
20
+ D18: boardIndex.Pin;
21
+ D19: boardIndex.Pin;
22
+ D20: boardIndex.Pin;
23
+ D21: boardIndex.Pin;
24
+ A0: boardIndex.Pin;
25
+ A1: boardIndex.Pin;
26
+ A2: boardIndex.Pin;
27
+ A3: boardIndex.Pin;
28
+ A4: boardIndex.Pin;
29
+ I2C0: boardIndex.I2CBus;
30
+ SPI0: boardIndex.SPIBus;
31
+ UART0: boardIndex.SerialPort;
32
+ UART1: boardIndex.SerialPort;
33
+ digital: {
34
+ D2: boardIndex.Pin;
35
+ D3: boardIndex.Pin;
36
+ D4: boardIndex.Pin;
37
+ D5: boardIndex.Pin;
38
+ D6: boardIndex.Pin;
39
+ D7: boardIndex.Pin;
40
+ D8: boardIndex.Pin;
41
+ D9: boardIndex.Pin;
42
+ D10: boardIndex.Pin;
43
+ D12: boardIndex.Pin;
44
+ D13: boardIndex.Pin;
45
+ D14: boardIndex.Pin;
46
+ D15: boardIndex.Pin;
47
+ D16: boardIndex.Pin;
48
+ D17: boardIndex.Pin;
49
+ D18: boardIndex.Pin;
50
+ D19: boardIndex.Pin;
51
+ D20: boardIndex.Pin;
52
+ D21: boardIndex.Pin;
53
+ };
54
+ analog: {
55
+ A0: boardIndex.Pin;
56
+ A1: boardIndex.Pin;
57
+ A2: boardIndex.Pin;
58
+ A3: boardIndex.Pin;
59
+ A4: boardIndex.Pin;
60
+ };
61
+ };
62
+ export default Board;
package/dist/board.js ADDED
@@ -0,0 +1,22 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32c3 — Board namespace
3
+ //
4
+ // Convenience namespace that exposes every board feature under one object.
5
+ // ---------------------------------------------------------------------------
6
+ import { D2, D3, D4, D5, D6, D7, D8, D9, D10, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21, A0, A1, A2, A3, A4, } from './pins.js';
7
+ import { I2C0, SPI0, UART0, UART1 } from '@typecad/mcu-esp32c3';
8
+ import * as boardIndex from './index.js';
9
+ export const Board = {
10
+ get definition() { return boardIndex.ESP32C3Board; },
11
+ // Common digital pins (strapping/USB pins omitted from the convenience namespace)
12
+ D2, D3, D4, D5, D6, D7, D8, D9, D10,
13
+ D12, D13, D14, D15, D16, D17, D18, D19, D20, D21,
14
+ // Analog aliases
15
+ A0, A1, A2, A3, A4,
16
+ // Peripherals
17
+ I2C0, SPI0, UART0, UART1,
18
+ // Collections
19
+ digital: { D2, D3, D4, D5, D6, D7, D8, D9, D10, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21 },
20
+ analog: { A0, A1, A2, A3, A4 },
21
+ };
22
+ export default Board;
@@ -0,0 +1,48 @@
1
+ import type { BoardDefinition } from '@typecad/cuttlefish/api/schema';
2
+ export declare const ESP32C3Board: BoardDefinition;
3
+ export default ESP32C3Board;
4
+ export * from '@typecad/mcu-esp32c3';
5
+ export * from '@typecad/hal';
6
+ /**
7
+ * Pin collections for runtime capability discovery.
8
+ */
9
+ export declare const pins: {
10
+ /** PWM-capable pins (all output-capable GPIOs that are not USB/strap). */
11
+ readonly pwm: readonly [import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin];
12
+ /** Analog input pins (ADC1 — usable while Wi-Fi active). */
13
+ readonly analog: readonly [import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin];
14
+ /** All GPIOs support interrupts on ESP32-C3. */
15
+ readonly interrupt: readonly [import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin];
16
+ /** All digital I/O pins. */
17
+ readonly digital: readonly [import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin, import("@typecad/hal").Pin];
18
+ };
19
+ /**
20
+ * Peripheral-to-pin mapping for the ESP32-C3.
21
+ */
22
+ export declare const PeripheralPins: {
23
+ /** I2C bus 0 — default GPIO8 (SDA) / GPIO9 (SCL); remappable via GPIO matrix. */
24
+ readonly I2C0: {
25
+ readonly SDA: "GPIO8";
26
+ readonly SCL: "GPIO9";
27
+ };
28
+ /** SPI bus 0 / GPSPI2 — GPIO6 (MOSI), GPIO5 (MISO), GPIO4 (SCK). GPIO7 is default CS. */
29
+ readonly SPI0: {
30
+ readonly MOSI: "GPIO6";
31
+ readonly MISO: "GPIO5";
32
+ readonly SCK: "GPIO4";
33
+ readonly CS: "GPIO7";
34
+ };
35
+ /** UART 0 — GPIO21 (TX) / GPIO20 (RX). USB-CDC serial available too. */
36
+ readonly UART0: {
37
+ readonly TX: "GPIO21";
38
+ readonly RX: "GPIO20";
39
+ };
40
+ /** UART 1 — no fixed pins (remappable). */
41
+ readonly UART1: {
42
+ readonly TX: "remappable";
43
+ readonly RX: "remappable";
44
+ };
45
+ };
46
+ export * from './pins.js';
47
+ export * from './analog.js';
48
+ export { Board } from './board.js';
package/dist/index.js ADDED
@@ -0,0 +1,100 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32c3 — Board definition manifest
3
+ // ---------------------------------------------------------------------------
4
+ import { ESP32C3 } from '@typecad/mcu-esp32c3';
5
+ /** Arduino core API version for this board's build defines. */
6
+ const ARDUINO_CORE_VERSION = '10819';
7
+ // ---------------------------------------------------------------------------
8
+ // Board definition
9
+ // ---------------------------------------------------------------------------
10
+ export const ESP32C3Board = {
11
+ id: 'esp32c3',
12
+ name: 'ESP32-C3',
13
+ vendor: 'Espressif',
14
+ description: 'Generic ESP32-C3 devboard (vendor-agnostic). Single-core RISC-V ' +
15
+ '(RV32IMC) @ 160 MHz with Wi-Fi 4 + BLE 5 and native USB Serial/JTAG. ' +
16
+ '22 GPIO; no PSRAM support.',
17
+ mcu: ESP32C3,
18
+ clockSpeed: 160_000_000, // 160 MHz
19
+ // ----- Memory (module-level; silicon memory lives on the MCU) -----------
20
+ // 4 MB module flash; no external RAM (the C3 silicon does not support it).
21
+ memory: {
22
+ flash: 4 * 1024 * 1024,
23
+ },
24
+ // ----- Pins (no onboard LED declared — generic board) -------------------
25
+ pins: {
26
+ ...ESP32C3.pins,
27
+ },
28
+ // ----- Peripherals -------------------------------------------------------
29
+ peripherals: {
30
+ ...ESP32C3.peripherals,
31
+ aliases: {
32
+ UART0: 'Serial',
33
+ UART1: 'Serial1',
34
+ I2C0: 'Wire',
35
+ SPI0: 'SPI',
36
+ },
37
+ },
38
+ // ----- Build config ------------------------------------------------------
39
+ build: {
40
+ frameworks: {
41
+ platformio: 'esp32c3',
42
+ arduino: 'esp32:esp32:esp32c3',
43
+ },
44
+ defines: {
45
+ F_CPU: '160000000UL',
46
+ ARDUINO: ARDUINO_CORE_VERSION,
47
+ ARDUINO_ESP32C3_DEV: '1',
48
+ },
49
+ },
50
+ };
51
+ export default ESP32C3Board;
52
+ // ---------------------------------------------------------------------------
53
+ // Re-exports — convenience barrel
54
+ // ---------------------------------------------------------------------------
55
+ // Silicon-level
56
+ export * from '@typecad/mcu-esp32c3';
57
+ // Generic HAL re-exports from @typecad/hal. Full re-export so this board package
58
+ // is a superset of @typecad/hal — `import { ... } from '@typecad/hal'` resolves
59
+ // here at transpile time and exposes every HAL symbol plus board-specific pins.
60
+ export * from '@typecad/hal';
61
+ // Board-level pin Discovery API (uses silicon pins from MCU)
62
+ import { GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7, GPIO8, GPIO9, GPIO10, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO20, GPIO21, } from '@typecad/mcu-esp32c3';
63
+ /**
64
+ * Pin collections for runtime capability discovery.
65
+ */
66
+ export const pins = {
67
+ /** PWM-capable pins (all output-capable GPIOs that are not USB/strap). */
68
+ pwm: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7, GPIO8, GPIO9,
69
+ GPIO10, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17,
70
+ GPIO18, GPIO19, GPIO20, GPIO21],
71
+ /** Analog input pins (ADC1 — usable while Wi-Fi active). */
72
+ analog: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4],
73
+ /** All GPIOs support interrupts on ESP32-C3. */
74
+ interrupt: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7, GPIO8, GPIO9,
75
+ GPIO10, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17,
76
+ GPIO18, GPIO19, GPIO20, GPIO21],
77
+ /** All digital I/O pins. */
78
+ digital: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7, GPIO8, GPIO9,
79
+ GPIO10, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17,
80
+ GPIO18, GPIO19, GPIO20, GPIO21],
81
+ };
82
+ /**
83
+ * Peripheral-to-pin mapping for the ESP32-C3.
84
+ */
85
+ export const PeripheralPins = {
86
+ /** I2C bus 0 — default GPIO8 (SDA) / GPIO9 (SCL); remappable via GPIO matrix. */
87
+ I2C0: { SDA: 'GPIO8', SCL: 'GPIO9' },
88
+ /** SPI bus 0 / GPSPI2 — GPIO6 (MOSI), GPIO5 (MISO), GPIO4 (SCK). GPIO7 is default CS. */
89
+ SPI0: { MOSI: 'GPIO6', MISO: 'GPIO5', SCK: 'GPIO4', CS: 'GPIO7' },
90
+ /** UART 0 — GPIO21 (TX) / GPIO20 (RX). USB-CDC serial available too. */
91
+ UART0: { TX: 'GPIO21', RX: 'GPIO20' },
92
+ /** UART 1 — no fixed pins (remappable). */
93
+ UART1: { TX: 'remappable', RX: 'remappable' },
94
+ };
95
+ // Board-level typed pins (Arduino-style aliases D0, A0, etc.)
96
+ export * from './pins.js';
97
+ // Board-specific analog constants
98
+ export * from './analog.js';
99
+ // Board namespace (single-import convenience)
100
+ export { Board } from './board.js';
package/dist/pins.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ export declare const D0: import("@typecad/hal").Pin;
2
+ export declare const D1: import("@typecad/hal").Pin;
3
+ export declare const D2: import("@typecad/hal").Pin;
4
+ export declare const D3: import("@typecad/hal").Pin;
5
+ export declare const D4: import("@typecad/hal").Pin;
6
+ export declare const D5: import("@typecad/hal").Pin;
7
+ export declare const D6: import("@typecad/hal").Pin;
8
+ export declare const D7: import("@typecad/hal").Pin;
9
+ export declare const D8: import("@typecad/hal").Pin;
10
+ export declare const D9: import("@typecad/hal").Pin;
11
+ export declare const D10: import("@typecad/hal").Pin;
12
+ export declare const D12: import("@typecad/hal").Pin;
13
+ export declare const D13: import("@typecad/hal").Pin;
14
+ export declare const D14: import("@typecad/hal").Pin;
15
+ export declare const D15: import("@typecad/hal").Pin;
16
+ export declare const D16: import("@typecad/hal").Pin;
17
+ export declare const D17: import("@typecad/hal").Pin;
18
+ export declare const D18: import("@typecad/hal").Pin;
19
+ export declare const D19: import("@typecad/hal").Pin;
20
+ export declare const D20: import("@typecad/hal").Pin;
21
+ export declare const D21: import("@typecad/hal").Pin;
22
+ export declare const A0: import("@typecad/hal").Pin;
23
+ export declare const A1: import("@typecad/hal").Pin;
24
+ export declare const A2: import("@typecad/hal").Pin;
25
+ export declare const A3: import("@typecad/hal").Pin;
26
+ export declare const A4: import("@typecad/hal").Pin;
27
+ export { I2C0, SPI0, UART0, UART1 } from '@typecad/mcu-esp32c3';
package/dist/pins.js ADDED
@@ -0,0 +1,40 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32c3 — Pin aliases
3
+ // ---------------------------------------------------------------------------
4
+ import { GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7, GPIO8, GPIO9, GPIO10, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO20, GPIO21, } from '@typecad/mcu-esp32c3';
5
+ // ---------------------------------------------------------------------------
6
+ // Arduino-style digital pin aliases (D-numbers match GPIO numbers on ESP32-C3)
7
+ // ---------------------------------------------------------------------------
8
+ export const D0 = GPIO0;
9
+ export const D1 = GPIO1;
10
+ export const D2 = GPIO2;
11
+ export const D3 = GPIO3;
12
+ export const D4 = GPIO4;
13
+ export const D5 = GPIO5;
14
+ export const D6 = GPIO6;
15
+ export const D7 = GPIO7;
16
+ export const D8 = GPIO8;
17
+ export const D9 = GPIO9;
18
+ export const D10 = GPIO10;
19
+ export const D12 = GPIO12;
20
+ export const D13 = GPIO13;
21
+ export const D14 = GPIO14;
22
+ export const D15 = GPIO15;
23
+ export const D16 = GPIO16;
24
+ export const D17 = GPIO17;
25
+ export const D18 = GPIO18;
26
+ export const D19 = GPIO19;
27
+ export const D20 = GPIO20;
28
+ export const D21 = GPIO21;
29
+ // ---------------------------------------------------------------------------
30
+ // Analog input aliases (ADC1 channels — usable while Wi-Fi is active).
31
+ // ADC2 pin (GPIO5) is omitted from Ax aliases because it is unusable while
32
+ // Wi-Fi is enabled.
33
+ // ---------------------------------------------------------------------------
34
+ export const A0 = GPIO0;
35
+ export const A1 = GPIO1;
36
+ export const A2 = GPIO2;
37
+ export const A3 = GPIO3;
38
+ export const A4 = GPIO4;
39
+ // Bus aliases (default pins for I2C0 / SPI0 / UART0)
40
+ export { I2C0, SPI0, UART0, UART1 } from '@typecad/mcu-esp32c3';
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@typecad/board-esp32c3",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "TypeCAD ESP32-C3 board definition with typed pins and peripherals",
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
+ "@typecad/mcu-esp32c3": "0.1.0-alpha.1"
20
+ },
21
+ "license": "MIT",
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/justind000/typecode.git",
28
+ "directory": "packages/board-esp32c3"
29
+ },
30
+ "homepage": "https://github.com/justind000/typecode/tree/main/packages/board-esp32c3",
31
+ "bugs": {
32
+ "url": "https://github.com/justind000/typecode/issues"
33
+ },
34
+ "keywords": [
35
+ "arduino",
36
+ "board",
37
+ "cpp",
38
+ "cuttlefish",
39
+ "devkit",
40
+ "embedded",
41
+ "esp32c3",
42
+ "firmware",
43
+ "microcontroller",
44
+ "pins",
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/analog.ts ADDED
@@ -0,0 +1,8 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32c3 — Analog constants
3
+ // ---------------------------------------------------------------------------
4
+
5
+ /** Default reference (3.3V). */
6
+ export const DEFAULT = 0;
7
+ /** Internal 1.1V reference. */
8
+ export const INTERNAL = 3;
package/src/board.ts ADDED
@@ -0,0 +1,36 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32c3 — Board namespace
3
+ //
4
+ // Convenience namespace that exposes every board feature under one object.
5
+ // ---------------------------------------------------------------------------
6
+
7
+ import type { BoardDefinition } from '@typecad/cuttlefish/api/schema';
8
+
9
+ import {
10
+ D2, D3, D4, D5, D6, D7, D8, D9, D10,
11
+ D12, D13, D14, D15, D16, D17, D18, D19, D20, D21,
12
+ A0, A1, A2, A3, A4,
13
+ } from './pins.js';
14
+
15
+ import { I2C0, SPI0, UART0, UART1 } from '@typecad/mcu-esp32c3';
16
+ import * as boardIndex from './index.js';
17
+
18
+ export const Board = {
19
+ get definition() { return boardIndex.ESP32C3Board; },
20
+
21
+ // Common digital pins (strapping/USB pins omitted from the convenience namespace)
22
+ D2, D3, D4, D5, D6, D7, D8, D9, D10,
23
+ D12, D13, D14, D15, D16, D17, D18, D19, D20, D21,
24
+
25
+ // Analog aliases
26
+ A0, A1, A2, A3, A4,
27
+
28
+ // Peripherals
29
+ I2C0, SPI0, UART0, UART1,
30
+
31
+ // Collections
32
+ digital: { D2, D3, D4, D5, D6, D7, D8, D9, D10, D12, D13, D14, D15, D16, D17, D18, D19, D20, D21 },
33
+ analog: { A0, A1, A2, A3, A4 },
34
+ };
35
+
36
+ export default Board;
package/src/index.ts ADDED
@@ -0,0 +1,126 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32c3 — Board definition manifest
3
+ // ---------------------------------------------------------------------------
4
+
5
+ import type { BoardDefinition } from '@typecad/cuttlefish/api/schema';
6
+ import { ESP32C3 } from '@typecad/mcu-esp32c3';
7
+
8
+ /** Arduino core API version for this board's build defines. */
9
+ const ARDUINO_CORE_VERSION = '10819';
10
+
11
+ // ---------------------------------------------------------------------------
12
+ // Board definition
13
+ // ---------------------------------------------------------------------------
14
+
15
+ export const ESP32C3Board: BoardDefinition = {
16
+ id: 'esp32c3',
17
+ name: 'ESP32-C3',
18
+ vendor: 'Espressif',
19
+ description:
20
+ 'Generic ESP32-C3 devboard (vendor-agnostic). Single-core RISC-V ' +
21
+ '(RV32IMC) @ 160 MHz with Wi-Fi 4 + BLE 5 and native USB Serial/JTAG. ' +
22
+ '22 GPIO; no PSRAM support.',
23
+
24
+ mcu: ESP32C3,
25
+ clockSpeed: 160_000_000, // 160 MHz
26
+
27
+ // ----- Memory (module-level; silicon memory lives on the MCU) -----------
28
+ // 4 MB module flash; no external RAM (the C3 silicon does not support it).
29
+ memory: {
30
+ flash: 4 * 1024 * 1024,
31
+ },
32
+
33
+ // ----- Pins (no onboard LED declared — generic board) -------------------
34
+ pins: {
35
+ ...ESP32C3.pins,
36
+ },
37
+
38
+ // ----- Peripherals -------------------------------------------------------
39
+ peripherals: {
40
+ ...ESP32C3.peripherals,
41
+ aliases: {
42
+ UART0: 'Serial',
43
+ UART1: 'Serial1',
44
+ I2C0: 'Wire',
45
+ SPI0: 'SPI',
46
+ },
47
+ },
48
+
49
+ // ----- Build config ------------------------------------------------------
50
+ build: {
51
+ frameworks: {
52
+ platformio: 'esp32c3',
53
+ arduino: 'esp32:esp32:esp32c3',
54
+ },
55
+ defines: {
56
+ F_CPU: '160000000UL',
57
+ ARDUINO: ARDUINO_CORE_VERSION,
58
+ ARDUINO_ESP32C3_DEV: '1',
59
+ },
60
+ },
61
+ };
62
+
63
+ export default ESP32C3Board;
64
+
65
+ // ---------------------------------------------------------------------------
66
+ // Re-exports — convenience barrel
67
+ // ---------------------------------------------------------------------------
68
+
69
+ // Silicon-level
70
+ export * from '@typecad/mcu-esp32c3';
71
+
72
+ // Generic HAL re-exports from @typecad/hal. Full re-export so this board package
73
+ // is a superset of @typecad/hal — `import { ... } from '@typecad/hal'` resolves
74
+ // here at transpile time and exposes every HAL symbol plus board-specific pins.
75
+ export * from '@typecad/hal';
76
+
77
+ // Board-level pin Discovery API (uses silicon pins from MCU)
78
+ import {
79
+ GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7,
80
+ GPIO8, GPIO9, GPIO10,
81
+ GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17,
82
+ GPIO18, GPIO19, GPIO20, GPIO21,
83
+ } from '@typecad/mcu-esp32c3';
84
+
85
+ /**
86
+ * Pin collections for runtime capability discovery.
87
+ */
88
+ export const pins = {
89
+ /** PWM-capable pins (all output-capable GPIOs that are not USB/strap). */
90
+ pwm: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7, GPIO8, GPIO9,
91
+ GPIO10, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17,
92
+ GPIO18, GPIO19, GPIO20, GPIO21] as const,
93
+ /** Analog input pins (ADC1 — usable while Wi-Fi active). */
94
+ analog: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4] as const,
95
+ /** All GPIOs support interrupts on ESP32-C3. */
96
+ interrupt: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7, GPIO8, GPIO9,
97
+ GPIO10, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17,
98
+ GPIO18, GPIO19, GPIO20, GPIO21] as const,
99
+ /** All digital I/O pins. */
100
+ digital: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7, GPIO8, GPIO9,
101
+ GPIO10, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17,
102
+ GPIO18, GPIO19, GPIO20, GPIO21] as const,
103
+ } as const;
104
+
105
+ /**
106
+ * Peripheral-to-pin mapping for the ESP32-C3.
107
+ */
108
+ export const PeripheralPins = {
109
+ /** I2C bus 0 — default GPIO8 (SDA) / GPIO9 (SCL); remappable via GPIO matrix. */
110
+ I2C0: { SDA: 'GPIO8', SCL: 'GPIO9' } as const,
111
+ /** SPI bus 0 / GPSPI2 — GPIO6 (MOSI), GPIO5 (MISO), GPIO4 (SCK). GPIO7 is default CS. */
112
+ SPI0: { MOSI: 'GPIO6', MISO: 'GPIO5', SCK: 'GPIO4', CS: 'GPIO7' } as const,
113
+ /** UART 0 — GPIO21 (TX) / GPIO20 (RX). USB-CDC serial available too. */
114
+ UART0: { TX: 'GPIO21', RX: 'GPIO20' } as const,
115
+ /** UART 1 — no fixed pins (remappable). */
116
+ UART1: { TX: 'remappable', RX: 'remappable' } as const,
117
+ } as const;
118
+
119
+ // Board-level typed pins (Arduino-style aliases D0, A0, etc.)
120
+ export * from './pins.js';
121
+
122
+ // Board-specific analog constants
123
+ export * from './analog.js';
124
+
125
+ // Board namespace (single-import convenience)
126
+ export { Board } from './board.js';
package/src/pins.ts ADDED
@@ -0,0 +1,38 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32c3 — Pin aliases
3
+ // ---------------------------------------------------------------------------
4
+
5
+ import {
6
+ GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7,
7
+ GPIO8, GPIO9, GPIO10,
8
+ GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17,
9
+ GPIO18, GPIO19, GPIO20, GPIO21,
10
+ } from '@typecad/mcu-esp32c3';
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // Arduino-style digital pin aliases (D-numbers match GPIO numbers on ESP32-C3)
14
+ // ---------------------------------------------------------------------------
15
+
16
+ export const D0 = GPIO0; export const D1 = GPIO1; export const D2 = GPIO2;
17
+ export const D3 = GPIO3; export const D4 = GPIO4; export const D5 = GPIO5;
18
+ export const D6 = GPIO6; export const D7 = GPIO7; export const D8 = GPIO8;
19
+ export const D9 = GPIO9; export const D10 = GPIO10;
20
+ export const D12 = GPIO12; export const D13 = GPIO13; export const D14 = GPIO14;
21
+ export const D15 = GPIO15; export const D16 = GPIO16; export const D17 = GPIO17;
22
+ export const D18 = GPIO18; export const D19 = GPIO19; export const D20 = GPIO20;
23
+ export const D21 = GPIO21;
24
+
25
+ // ---------------------------------------------------------------------------
26
+ // Analog input aliases (ADC1 channels — usable while Wi-Fi is active).
27
+ // ADC2 pin (GPIO5) is omitted from Ax aliases because it is unusable while
28
+ // Wi-Fi is enabled.
29
+ // ---------------------------------------------------------------------------
30
+
31
+ export const A0 = GPIO0;
32
+ export const A1 = GPIO1;
33
+ export const A2 = GPIO2;
34
+ export const A3 = GPIO3;
35
+ export const A4 = GPIO4;
36
+
37
+ // Bus aliases (default pins for I2C0 / SPI0 / UART0)
38
+ export { I2C0, SPI0, UART0, UART1 } from '@typecad/mcu-esp32c3';