@typecad/board-esp32-devkit 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-esp32-devkit
2
+
3
+ ESP32 DevKit (WROOM-32) board definition package for TypeCAD.
4
+
5
+ ## Overview
6
+
7
+ `@typecad/board-esp32-devkit` provides typed pins, peripherals, and board metadata for the standard ESP32 DevKit module (ESP32-WROOM-32 dual-core Xtensa LX6 @ 240 MHz, Wi-Fi + BLE). It re-exports the silicon-level pin definitions from [`@typecad/mcu-esp32`](../mcu-esp32) and the HAL utilities from [`@typecad/hal`](../hal) so a single import gives you everything.
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-esp32-devkit',
26
+ ```
27
+
28
+ ## What's inside
29
+
30
+ - **GPIO pins**: `GPIO0`–`GPIO39` (silicon pins from `@typecad/mcu-esp32`)
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-esp32-devkit` are also supported when you want explicit board package references.
36
+
37
+ ## Related packages
38
+
39
+ - [`@typecad/mcu-esp32`](../mcu-esp32) — silicon-level pin definitions for the ESP32 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-esp32-devkit — 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,89 @@
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
+ D0: boardIndex.Pin;
6
+ D1: boardIndex.Pin;
7
+ D2: boardIndex.Pin;
8
+ D3: boardIndex.Pin;
9
+ D4: boardIndex.Pin;
10
+ D5: boardIndex.Pin;
11
+ D12: boardIndex.Pin;
12
+ D13: boardIndex.Pin;
13
+ D14: boardIndex.Pin;
14
+ D15: boardIndex.Pin;
15
+ D16: boardIndex.Pin;
16
+ D17: boardIndex.Pin;
17
+ D18: boardIndex.Pin;
18
+ D19: boardIndex.Pin;
19
+ D21: boardIndex.Pin;
20
+ D22: boardIndex.Pin;
21
+ D23: boardIndex.Pin;
22
+ D25: boardIndex.Pin;
23
+ D26: boardIndex.Pin;
24
+ D27: boardIndex.Pin;
25
+ D32: boardIndex.Pin;
26
+ D33: boardIndex.Pin;
27
+ D34: boardIndex.Pin;
28
+ D35: boardIndex.Pin;
29
+ D36: boardIndex.Pin;
30
+ D39: boardIndex.Pin;
31
+ A0: boardIndex.Pin;
32
+ A1: boardIndex.Pin;
33
+ A2: boardIndex.Pin;
34
+ A3: boardIndex.Pin;
35
+ A4: boardIndex.Pin;
36
+ A5: boardIndex.Pin;
37
+ LED: boardIndex.Pin;
38
+ SDA: boardIndex.Pin;
39
+ SCL: boardIndex.Pin;
40
+ MOSI: boardIndex.Pin;
41
+ MISO: boardIndex.Pin;
42
+ SCK: boardIndex.Pin;
43
+ SS: boardIndex.Pin;
44
+ TX: boardIndex.Pin;
45
+ RX: boardIndex.Pin;
46
+ TX2: boardIndex.Pin;
47
+ RX2: boardIndex.Pin;
48
+ DAC1: boardIndex.Pin;
49
+ DAC2: boardIndex.Pin;
50
+ I2C0: boardIndex.I2CBus;
51
+ I2C1: boardIndex.I2CBus;
52
+ SPI0: boardIndex.SPIBus;
53
+ SPI1: boardIndex.SPIBus;
54
+ UART0: boardIndex.SerialPort;
55
+ UART2: boardIndex.SerialPort;
56
+ digital: {
57
+ D0: boardIndex.Pin;
58
+ D1: boardIndex.Pin;
59
+ D2: boardIndex.Pin;
60
+ D3: boardIndex.Pin;
61
+ D4: boardIndex.Pin;
62
+ D5: boardIndex.Pin;
63
+ D12: boardIndex.Pin;
64
+ D13: boardIndex.Pin;
65
+ D14: boardIndex.Pin;
66
+ D15: boardIndex.Pin;
67
+ D16: boardIndex.Pin;
68
+ D17: boardIndex.Pin;
69
+ D18: boardIndex.Pin;
70
+ D19: boardIndex.Pin;
71
+ D21: boardIndex.Pin;
72
+ D22: boardIndex.Pin;
73
+ D23: boardIndex.Pin;
74
+ D25: boardIndex.Pin;
75
+ D26: boardIndex.Pin;
76
+ D27: boardIndex.Pin;
77
+ D32: boardIndex.Pin;
78
+ D33: boardIndex.Pin;
79
+ };
80
+ analog: {
81
+ A0: boardIndex.Pin;
82
+ A1: boardIndex.Pin;
83
+ A2: boardIndex.Pin;
84
+ A3: boardIndex.Pin;
85
+ A4: boardIndex.Pin;
86
+ A5: boardIndex.Pin;
87
+ };
88
+ };
89
+ export default Board;
package/dist/board.js ADDED
@@ -0,0 +1,34 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32-devkit — Board namespace
3
+ //
4
+ // Convenience namespace that exposes every board feature under one object.
5
+ // For method calls on pins/peripherals, prefer direct imports:
6
+ //
7
+ // import { D2, UART0 } from '@typecad/board-esp32-devkit';
8
+ // D2.high();
9
+ // UART0.begin(115200);
10
+ //
11
+ // The Board object is useful for pin iteration and metadata access.
12
+ // ---------------------------------------------------------------------------
13
+ import { D0, D1, D2, D3, D4, D5, D12, D13, D14, D15, D16, D17, D18, D19, D21, D22, D23, D25, D26, D27, D32, D33, D34, D35, D36, D39, A0, A1, A2, A3, A4, A5, LED, SDA, SCL, MOSI, MISO, SCK, SS, TX, RX, TX2, RX2, DAC1, DAC2, } from './pins.js';
14
+ import { I2C0, I2C1, SPI0, SPI1, UART0, UART2 } from '@typecad/mcu-esp32';
15
+ import * as boardIndex from './index.js';
16
+ export const Board = {
17
+ get definition() { return boardIndex.ESP32DevKit; },
18
+ // Output-capable GPIOs
19
+ D0, D1, D2, D3, D4, D5,
20
+ D12, D13, D14, D15, D16, D17, D18, D19,
21
+ D21, D22, D23, D25, D26, D27, D32, D33,
22
+ // Input-only pins
23
+ D34, D35, D36, D39,
24
+ // Analog aliases
25
+ A0, A1, A2, A3, A4, A5,
26
+ // Convenience aliases
27
+ LED, SDA, SCL, MOSI, MISO, SCK, SS, TX, RX, TX2, RX2, DAC1, DAC2,
28
+ // Peripherals
29
+ I2C0, I2C1, SPI0, SPI1, UART0, UART2,
30
+ // Collections
31
+ digital: { D0, D1, D2, D3, D4, D5, D12, D13, D14, D15, D16, D17, D18, D19, D21, D22, D23, D25, D26, D27, D32, D33 },
32
+ analog: { A0, A1, A2, A3, A4, A5 },
33
+ };
34
+ export default Board;
@@ -0,0 +1,60 @@
1
+ import type { BoardDefinition } from '@typecad/cuttlefish/api/schema';
2
+ export declare const ESP32DevKit: BoardDefinition;
3
+ export default ESP32DevKit;
4
+ export * from '@typecad/mcu-esp32';
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 on ESP32). */
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, import("@typecad/hal").Pin];
12
+ /** Analog input pins. */
13
+ readonly analog: 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];
14
+ /** All GPIOs support interrupts on ESP32. */
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, 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, 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 DevKit.
21
+ */
22
+ export declare const PeripheralPins: {
23
+ /** I2C bus 0 — requires GPIO21 (SDA) and GPIO22 (SCL). */
24
+ readonly I2C0: {
25
+ readonly SDA: "GPIO21";
26
+ readonly SCL: "GPIO22";
27
+ };
28
+ /** I2C bus 1 — no fixed pins (remappable). */
29
+ readonly I2C1: {
30
+ readonly SDA: "remappable";
31
+ readonly SCL: "remappable";
32
+ };
33
+ /** SPI bus 0 / HSPI — GPIO13 (MOSI), GPIO12 (MISO), GPIO14 (SCK). GPIO15 is default CS. */
34
+ readonly SPI0: {
35
+ readonly MOSI: "GPIO13";
36
+ readonly MISO: "GPIO12";
37
+ readonly SCK: "GPIO14";
38
+ readonly CS: "GPIO15";
39
+ };
40
+ /** SPI bus 1 / VSPI — GPIO23 (MOSI), GPIO19 (MISO), GPIO18 (SCK). GPIO5 is default CS. */
41
+ readonly SPI1: {
42
+ readonly MOSI: "GPIO23";
43
+ readonly MISO: "GPIO19";
44
+ readonly SCK: "GPIO18";
45
+ readonly CS: "GPIO5";
46
+ };
47
+ /** UART 0 — GPIO1 (TX) and GPIO3 (RX). USB serial. */
48
+ readonly UART0: {
49
+ readonly TX: "GPIO1";
50
+ readonly RX: "GPIO3";
51
+ };
52
+ /** UART 2 — GPIO17 (TX) and GPIO16 (RX). */
53
+ readonly UART2: {
54
+ readonly TX: "GPIO17";
55
+ readonly RX: "GPIO16";
56
+ };
57
+ };
58
+ export * from './pins.js';
59
+ export * from './analog.js';
60
+ export { Board } from './board.js';
package/dist/index.js ADDED
@@ -0,0 +1,95 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32-devkit — Board definition manifest
3
+ // ---------------------------------------------------------------------------
4
+ import { ESP32WROOM32 } from '@typecad/mcu-esp32';
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 ESP32DevKit = {
11
+ id: 'esp32-devkit',
12
+ name: 'ESP32 DevKit',
13
+ vendor: 'Espressif',
14
+ description: 'ESP32 DevKit v1 (38-pin) — ESP32-WROOM-32',
15
+ mcu: ESP32WROOM32,
16
+ clockSpeed: 240_000_000, // 240 MHz
17
+ // ----- Pins --------------------------------------------------------------
18
+ pins: {
19
+ ...ESP32WROOM32.pins,
20
+ led: 'GPIO2',
21
+ },
22
+ // ----- Peripherals -------------------------------------------------------
23
+ peripherals: {
24
+ ...ESP32WROOM32.peripherals,
25
+ aliases: {
26
+ UART0: 'Serial',
27
+ UART1: 'Serial1',
28
+ UART2: 'Serial2',
29
+ I2C0: 'Wire',
30
+ I2C1: 'Wire1',
31
+ SPI0: 'SPI',
32
+ SPI1: 'SPI1',
33
+ },
34
+ },
35
+ // ----- Build config ------------------------------------------------------
36
+ build: {
37
+ frameworks: {
38
+ platformio: 'esp32dev',
39
+ arduino: 'esp32:esp32:esp32',
40
+ },
41
+ defines: {
42
+ F_CPU: '240000000UL',
43
+ ARDUINO: ARDUINO_CORE_VERSION,
44
+ ARDUINO_ESP32_DEV: '1',
45
+ },
46
+ },
47
+ };
48
+ export default ESP32DevKit;
49
+ // ---------------------------------------------------------------------------
50
+ // Re-exports — convenience barrel
51
+ // ---------------------------------------------------------------------------
52
+ // Silicon-level re-exports from MCU package
53
+ export * from '@typecad/mcu-esp32';
54
+ // Generic HAL re-exports from @typecad/hal. Full re-export so this board package
55
+ // is a superset of @typecad/hal — `import { ... } from '@typecad/hal'` resolves
56
+ // here at transpile time and exposes every HAL symbol plus board-specific pins.
57
+ export * from '@typecad/hal';
58
+ // Board-level pin Discovery API overrides (using silicon pins from MCU)
59
+ import { GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33, GPIO34, GPIO35, GPIO36, GPIO39, } from '@typecad/mcu-esp32';
60
+ /**
61
+ * Pin collections for runtime capability discovery.
62
+ */
63
+ export const pins = {
64
+ /** PWM-capable pins (all output-capable GPIOs on ESP32). */
65
+ pwm: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33],
66
+ /** Analog input pins. */
67
+ analog: [GPIO36, GPIO39, GPIO34, GPIO35, GPIO32, GPIO33],
68
+ /** All GPIOs support interrupts on ESP32. */
69
+ interrupt: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33, GPIO34, GPIO35, GPIO36, GPIO39],
70
+ /** All digital I/O pins. */
71
+ digital: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33, GPIO34, GPIO35, GPIO36, GPIO39],
72
+ };
73
+ /**
74
+ * Peripheral-to-pin mapping for the ESP32 DevKit.
75
+ */
76
+ export const PeripheralPins = {
77
+ /** I2C bus 0 — requires GPIO21 (SDA) and GPIO22 (SCL). */
78
+ I2C0: { SDA: 'GPIO21', SCL: 'GPIO22' },
79
+ /** I2C bus 1 — no fixed pins (remappable). */
80
+ I2C1: { SDA: 'remappable', SCL: 'remappable' },
81
+ /** SPI bus 0 / HSPI — GPIO13 (MOSI), GPIO12 (MISO), GPIO14 (SCK). GPIO15 is default CS. */
82
+ SPI0: { MOSI: 'GPIO13', MISO: 'GPIO12', SCK: 'GPIO14', CS: 'GPIO15' },
83
+ /** SPI bus 1 / VSPI — GPIO23 (MOSI), GPIO19 (MISO), GPIO18 (SCK). GPIO5 is default CS. */
84
+ SPI1: { MOSI: 'GPIO23', MISO: 'GPIO19', SCK: 'GPIO18', CS: 'GPIO5' },
85
+ /** UART 0 — GPIO1 (TX) and GPIO3 (RX). USB serial. */
86
+ UART0: { TX: 'GPIO1', RX: 'GPIO3' },
87
+ /** UART 2 — GPIO17 (TX) and GPIO16 (RX). */
88
+ UART2: { TX: 'GPIO17', RX: 'GPIO16' },
89
+ };
90
+ // Board-level typed pins (including Arduino-style aliases D0, A0, etc.)
91
+ export * from './pins.js';
92
+ // Board-specific analog constants
93
+ export * from './analog.js';
94
+ // Board namespace (single-import convenience)
95
+ export { Board } from './board.js';
package/dist/pins.d.ts ADDED
@@ -0,0 +1,36 @@
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 D12: import("@typecad/hal").Pin;
8
+ export declare const D13: import("@typecad/hal").Pin;
9
+ export declare const D14: import("@typecad/hal").Pin;
10
+ export declare const D15: import("@typecad/hal").Pin;
11
+ export declare const D16: import("@typecad/hal").Pin;
12
+ export declare const D17: import("@typecad/hal").Pin;
13
+ export declare const D18: import("@typecad/hal").Pin;
14
+ export declare const D19: import("@typecad/hal").Pin;
15
+ export declare const D21: import("@typecad/hal").Pin;
16
+ export declare const D22: import("@typecad/hal").Pin;
17
+ export declare const D23: import("@typecad/hal").Pin;
18
+ export declare const D25: import("@typecad/hal").Pin;
19
+ export declare const D26: import("@typecad/hal").Pin;
20
+ export declare const D27: import("@typecad/hal").Pin;
21
+ export declare const D32: import("@typecad/hal").Pin;
22
+ export declare const D33: import("@typecad/hal").Pin;
23
+ export declare const D34: import("@typecad/hal").Pin;
24
+ export declare const D35: import("@typecad/hal").Pin;
25
+ export declare const D36: import("@typecad/hal").Pin;
26
+ export declare const D39: import("@typecad/hal").Pin;
27
+ /** Analog input aliases (ADC1 channels on ESP32). */
28
+ export declare const A0: import("@typecad/hal").Pin;
29
+ export declare const A1: import("@typecad/hal").Pin;
30
+ export declare const A2: import("@typecad/hal").Pin;
31
+ export declare const A3: import("@typecad/hal").Pin;
32
+ export declare const A4: import("@typecad/hal").Pin;
33
+ export declare const A5: import("@typecad/hal").Pin;
34
+ /** On-board LED (GPIO2 on most ESP32 DevKit boards). */
35
+ export declare const LED: import("@typecad/hal").Pin;
36
+ export { SDA, SCL, MOSI, MISO, SCK, SS, TX, RX, TX2, RX2, DAC1, DAC2 } from '@typecad/mcu-esp32';
package/dist/pins.js ADDED
@@ -0,0 +1,47 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32-devkit — Pin aliases and header mappings
3
+ // ---------------------------------------------------------------------------
4
+ import { GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33, GPIO34, GPIO35, GPIO36, GPIO39, } from '@typecad/mcu-esp32';
5
+ // ---------------------------------------------------------------------------
6
+ // Arduino-style pin aliases (D-numbers match GPIO numbers on ESP32 DevKit)
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 D12 = GPIO12;
15
+ export const D13 = GPIO13;
16
+ export const D14 = GPIO14;
17
+ export const D15 = GPIO15;
18
+ export const D16 = GPIO16;
19
+ export const D17 = GPIO17;
20
+ export const D18 = GPIO18;
21
+ export const D19 = GPIO19;
22
+ export const D21 = GPIO21;
23
+ export const D22 = GPIO22;
24
+ export const D23 = GPIO23;
25
+ export const D25 = GPIO25;
26
+ export const D26 = GPIO26;
27
+ export const D27 = GPIO27;
28
+ export const D32 = GPIO32;
29
+ export const D33 = GPIO33;
30
+ export const D34 = GPIO34;
31
+ export const D35 = GPIO35;
32
+ export const D36 = GPIO36;
33
+ export const D39 = GPIO39;
34
+ /** Analog input aliases (ADC1 channels on ESP32). */
35
+ export const A0 = GPIO36;
36
+ export const A1 = GPIO39;
37
+ export const A2 = GPIO34;
38
+ export const A3 = GPIO35;
39
+ export const A4 = GPIO32;
40
+ export const A5 = GPIO33;
41
+ // ---------------------------------------------------------------------------
42
+ // Board-specific aliases
43
+ // ---------------------------------------------------------------------------
44
+ /** On-board LED (GPIO2 on most ESP32 DevKit boards). */
45
+ export const LED = GPIO2;
46
+ // Re-export silicon-level aliases (SDA, MOSI, etc.) from MCU package
47
+ export { SDA, SCL, MOSI, MISO, SCK, SS, TX, RX, TX2, RX2, DAC1, DAC2 } from '@typecad/mcu-esp32';
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@typecad/board-esp32-devkit",
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "TypeCAD ESP32 DevKit (WROOM-32) 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-esp32": "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-esp32-devkit"
29
+ },
30
+ "homepage": "https://github.com/justind000/typecode/tree/main/packages/board-esp32-devkit",
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
+ "esp32-devkit",
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-esp32-devkit — 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,53 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32-devkit — Board namespace
3
+ //
4
+ // Convenience namespace that exposes every board feature under one object.
5
+ // For method calls on pins/peripherals, prefer direct imports:
6
+ //
7
+ // import { D2, UART0 } from '@typecad/board-esp32-devkit';
8
+ // D2.high();
9
+ // UART0.begin(115200);
10
+ //
11
+ // The Board object is useful for pin iteration and metadata access.
12
+ // ---------------------------------------------------------------------------
13
+
14
+ import type { BoardDefinition } from '@typecad/cuttlefish/api/schema';
15
+
16
+ import {
17
+ D0, D1, D2, D3, D4, D5,
18
+ D12, D13, D14, D15, D16, D17, D18, D19,
19
+ D21, D22, D23, D25, D26, D27, D32, D33,
20
+ D34, D35, D36, D39,
21
+ A0, A1, A2, A3, A4, A5,
22
+ LED, SDA, SCL, MOSI, MISO, SCK, SS, TX, RX, TX2, RX2, DAC1, DAC2,
23
+ } from './pins.js';
24
+
25
+ import { I2C0, I2C1, SPI0, SPI1, UART0, UART2 } from '@typecad/mcu-esp32';
26
+ import * as boardIndex from './index.js';
27
+
28
+ export const Board = {
29
+ get definition() { return boardIndex.ESP32DevKit; },
30
+
31
+ // Output-capable GPIOs
32
+ D0, D1, D2, D3, D4, D5,
33
+ D12, D13, D14, D15, D16, D17, D18, D19,
34
+ D21, D22, D23, D25, D26, D27, D32, D33,
35
+
36
+ // Input-only pins
37
+ D34, D35, D36, D39,
38
+
39
+ // Analog aliases
40
+ A0, A1, A2, A3, A4, A5,
41
+
42
+ // Convenience aliases
43
+ LED, SDA, SCL, MOSI, MISO, SCK, SS, TX, RX, TX2, RX2, DAC1, DAC2,
44
+
45
+ // Peripherals
46
+ I2C0, I2C1, SPI0, SPI1, UART0, UART2,
47
+
48
+ // Collections
49
+ digital: { D0, D1, D2, D3, D4, D5, D12, D13, D14, D15, D16, D17, D18, D19, D21, D22, D23, D25, D26, D27, D32, D33 },
50
+ analog: { A0, A1, A2, A3, A4, A5 },
51
+ };
52
+
53
+ export default Board;
package/src/index.ts ADDED
@@ -0,0 +1,119 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32-devkit — Board definition manifest
3
+ // ---------------------------------------------------------------------------
4
+
5
+ import type { BoardDefinition } from '@typecad/cuttlefish/api/schema';
6
+ import { ESP32WROOM32 } from '@typecad/mcu-esp32';
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 ESP32DevKit: BoardDefinition = {
16
+ id: 'esp32-devkit',
17
+ name: 'ESP32 DevKit',
18
+ vendor: 'Espressif',
19
+ description: 'ESP32 DevKit v1 (38-pin) — ESP32-WROOM-32',
20
+
21
+ mcu: ESP32WROOM32,
22
+ clockSpeed: 240_000_000, // 240 MHz
23
+
24
+ // ----- Pins --------------------------------------------------------------
25
+ pins: {
26
+ ...ESP32WROOM32.pins,
27
+ led: 'GPIO2',
28
+ },
29
+
30
+ // ----- Peripherals -------------------------------------------------------
31
+ peripherals: {
32
+ ...ESP32WROOM32.peripherals,
33
+ aliases: {
34
+ UART0: 'Serial',
35
+ UART1: 'Serial1',
36
+ UART2: 'Serial2',
37
+ I2C0: 'Wire',
38
+ I2C1: 'Wire1',
39
+ SPI0: 'SPI',
40
+ SPI1: 'SPI1',
41
+ },
42
+ },
43
+
44
+ // ----- Build config ------------------------------------------------------
45
+ build: {
46
+ frameworks: {
47
+ platformio: 'esp32dev',
48
+ arduino: 'esp32:esp32:esp32',
49
+ },
50
+ defines: {
51
+ F_CPU: '240000000UL',
52
+ ARDUINO: ARDUINO_CORE_VERSION,
53
+ ARDUINO_ESP32_DEV: '1',
54
+ },
55
+ },
56
+ };
57
+
58
+ export default ESP32DevKit;
59
+
60
+ // ---------------------------------------------------------------------------
61
+ // Re-exports — convenience barrel
62
+ // ---------------------------------------------------------------------------
63
+
64
+ // Silicon-level re-exports from MCU package
65
+ export * from '@typecad/mcu-esp32';
66
+
67
+ // Generic HAL re-exports from @typecad/hal. Full re-export so this board package
68
+ // is a superset of @typecad/hal — `import { ... } from '@typecad/hal'` resolves
69
+ // here at transpile time and exposes every HAL symbol plus board-specific pins.
70
+ export * from '@typecad/hal';
71
+
72
+ // Board-level pin Discovery API overrides (using silicon pins from MCU)
73
+ import {
74
+ GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5,
75
+ GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19,
76
+ GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33,
77
+ GPIO34, GPIO35, GPIO36, GPIO39,
78
+ } from '@typecad/mcu-esp32';
79
+
80
+ /**
81
+ * Pin collections for runtime capability discovery.
82
+ */
83
+ export const pins = {
84
+ /** PWM-capable pins (all output-capable GPIOs on ESP32). */
85
+ pwm: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33] as const,
86
+ /** Analog input pins. */
87
+ analog: [GPIO36, GPIO39, GPIO34, GPIO35, GPIO32, GPIO33] as const,
88
+ /** All GPIOs support interrupts on ESP32. */
89
+ interrupt: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33, GPIO34, GPIO35, GPIO36, GPIO39] as const,
90
+ /** All digital I/O pins. */
91
+ digital: [GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19, GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33, GPIO34, GPIO35, GPIO36, GPIO39] as const,
92
+ } as const;
93
+
94
+ /**
95
+ * Peripheral-to-pin mapping for the ESP32 DevKit.
96
+ */
97
+ export const PeripheralPins = {
98
+ /** I2C bus 0 — requires GPIO21 (SDA) and GPIO22 (SCL). */
99
+ I2C0: { SDA: 'GPIO21', SCL: 'GPIO22' } as const,
100
+ /** I2C bus 1 — no fixed pins (remappable). */
101
+ I2C1: { SDA: 'remappable', SCL: 'remappable' } as const,
102
+ /** SPI bus 0 / HSPI — GPIO13 (MOSI), GPIO12 (MISO), GPIO14 (SCK). GPIO15 is default CS. */
103
+ SPI0: { MOSI: 'GPIO13', MISO: 'GPIO12', SCK: 'GPIO14', CS: 'GPIO15' } as const,
104
+ /** SPI bus 1 / VSPI — GPIO23 (MOSI), GPIO19 (MISO), GPIO18 (SCK). GPIO5 is default CS. */
105
+ SPI1: { MOSI: 'GPIO23', MISO: 'GPIO19', SCK: 'GPIO18', CS: 'GPIO5' } as const,
106
+ /** UART 0 — GPIO1 (TX) and GPIO3 (RX). USB serial. */
107
+ UART0: { TX: 'GPIO1', RX: 'GPIO3' } as const,
108
+ /** UART 2 — GPIO17 (TX) and GPIO16 (RX). */
109
+ UART2: { TX: 'GPIO17', RX: 'GPIO16' } as const,
110
+ } as const;
111
+
112
+ // Board-level typed pins (including Arduino-style aliases D0, A0, etc.)
113
+ export * from './pins.js';
114
+
115
+ // Board-specific analog constants
116
+ export * from './analog.js';
117
+
118
+ // Board namespace (single-import convenience)
119
+ export { Board } from './board.js';
package/src/pins.ts ADDED
@@ -0,0 +1,59 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/board-esp32-devkit — Pin aliases and header mappings
3
+ // ---------------------------------------------------------------------------
4
+
5
+ import {
6
+ GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5,
7
+ GPIO12, GPIO13, GPIO14, GPIO15, GPIO16, GPIO17, GPIO18, GPIO19,
8
+ GPIO21, GPIO22, GPIO23, GPIO25, GPIO26, GPIO27, GPIO32, GPIO33,
9
+ GPIO34, GPIO35, GPIO36, GPIO39,
10
+ } from '@typecad/mcu-esp32';
11
+
12
+ // ---------------------------------------------------------------------------
13
+ // Arduino-style pin aliases (D-numbers match GPIO numbers on ESP32 DevKit)
14
+ // ---------------------------------------------------------------------------
15
+
16
+ export const D0 = GPIO0;
17
+ export const D1 = GPIO1;
18
+ export const D2 = GPIO2;
19
+ export const D3 = GPIO3;
20
+ export const D4 = GPIO4;
21
+ export const D5 = GPIO5;
22
+ export const D12 = GPIO12;
23
+ export const D13 = GPIO13;
24
+ export const D14 = GPIO14;
25
+ export const D15 = GPIO15;
26
+ export const D16 = GPIO16;
27
+ export const D17 = GPIO17;
28
+ export const D18 = GPIO18;
29
+ export const D19 = GPIO19;
30
+ export const D21 = GPIO21;
31
+ export const D22 = GPIO22;
32
+ export const D23 = GPIO23;
33
+ export const D25 = GPIO25;
34
+ export const D26 = GPIO26;
35
+ export const D27 = GPIO27;
36
+ export const D32 = GPIO32;
37
+ export const D33 = GPIO33;
38
+ export const D34 = GPIO34;
39
+ export const D35 = GPIO35;
40
+ export const D36 = GPIO36;
41
+ export const D39 = GPIO39;
42
+
43
+ /** Analog input aliases (ADC1 channels on ESP32). */
44
+ export const A0 = GPIO36;
45
+ export const A1 = GPIO39;
46
+ export const A2 = GPIO34;
47
+ export const A3 = GPIO35;
48
+ export const A4 = GPIO32;
49
+ export const A5 = GPIO33;
50
+
51
+ // ---------------------------------------------------------------------------
52
+ // Board-specific aliases
53
+ // ---------------------------------------------------------------------------
54
+
55
+ /** On-board LED (GPIO2 on most ESP32 DevKit boards). */
56
+ export const LED = GPIO2;
57
+
58
+ // Re-export silicon-level aliases (SDA, MOSI, etc.) from MCU package
59
+ export { SDA, SCL, MOSI, MISO, SCK, SS, TX, RX, TX2, RX2, DAC1, DAC2 } from '@typecad/mcu-esp32';