@typecad/cuttlefish 1.0.0-alpha.13 → 1.0.0-alpha.15
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/README.md +82 -79
- package/assets/editor-extensions/typecad-debug/README.md +141 -0
- package/assets/editor-extensions/typecad-debug/out/extension.js +347 -0
- package/assets/editor-extensions/typecad-debug/out/extension.js.map +1 -0
- package/assets/editor-extensions/typecad-debug/package.json +76 -0
- package/assets/editor-extensions/typecad-ui/LICENSE +27 -0
- package/assets/editor-extensions/typecad-ui/README.md +52 -0
- package/assets/editor-extensions/typecad-ui/file-icon-dark.png +0 -0
- package/assets/editor-extensions/typecad-ui/file-icon-light.png +0 -0
- package/assets/editor-extensions/typecad-ui/icon.png +0 -0
- package/assets/editor-extensions/typecad-ui/language-configuration.json +43 -0
- package/assets/editor-extensions/typecad-ui/package.json +54 -0
- package/assets/editor-extensions/typecad-ui/snippets/typecad-ui.json +80 -0
- package/assets/editor-extensions/typecad-ui/syntaxes/markdown-ui.json +45 -0
- package/assets/editor-extensions/typecad-ui/syntaxes/typecad-ui.tmLanguage.json +1269 -0
- package/dist/api/config.d.ts +30 -27
- package/dist/api/schema/types.d.ts +20 -3
- package/dist/api/shared/async-runtime-static.d.ts +1 -1
- package/dist/api/shared/async-runtime-static.js +5 -5
- package/dist/api/shared/async-types.d.ts +3 -2
- package/dist/api/shared/board-catalog.d.ts +2 -0
- package/dist/api/shared/board-catalog.js +6 -0
- package/dist/api/shared/board-resolver.d.ts +4 -7
- package/dist/api/shared/board-resolver.js +2 -1
- package/dist/api/shared/coop-scheduler.d.ts +1 -1
- package/dist/api/shared/coop-scheduler.js +1 -1
- package/dist/api/shared/cpp-type-ir.d.ts +1 -1
- package/dist/api/shared/cpp-type-ir.js +1 -1
- package/dist/api/shared/display-profile.d.ts +1 -1
- package/dist/api/shared/display-profile.js +3 -5
- package/dist/api/shared/framework-manifest-registry.d.ts +1 -1
- package/dist/api/shared/framework-manifest-registry.js +0 -1
- package/dist/api/shared/framework-manifest.d.ts +65 -507
- package/dist/api/shared/framework-manifest.js +6 -11
- package/dist/api/shared/hal-op-ir.d.ts +294 -685
- package/dist/api/shared/hal-op-ir.js +31 -65
- package/dist/api/shared/index.d.ts +0 -4
- package/dist/api/shared/index.js +1 -7
- package/dist/api/shared/ir-core.d.ts +6 -0
- package/dist/api/shared/ir-declarations.d.ts +4 -0
- package/dist/api/shared/ir.d.ts +1 -3
- package/dist/api/shared/platform-strategy.d.ts +14 -37
- package/dist/api/shared/polyfill-helper-registry.js +0 -5
- package/dist/api/shared/polyfill-types.js +0 -27
- package/dist/api/shared/promise-runtime.js +3 -3
- package/dist/api/shared/spdx-licenses.d.ts +12 -10
- package/dist/api/shared/spdx-licenses.js +1 -1
- package/dist/api/shared/toolchain-types.d.ts +1 -1
- package/dist/api/shared/toolchain-types.js +3 -3
- package/dist/api/shared/types.d.ts +0 -3
- package/dist/api/shared/validate-framework-manifest.js +13 -33
- package/dist/board-catalog/dts-reader.d.ts +220 -0
- package/dist/board-catalog/dts-reader.js +1052 -0
- package/dist/board-catalog/index.d.ts +11 -0
- package/dist/board-catalog/index.js +12 -0
- package/dist/board-catalog/pinconfig.d.ts +48 -0
- package/dist/board-catalog/pinconfig.js +263 -0
- package/dist/board-catalog/sdk.d.ts +82 -0
- package/dist/board-catalog/sdk.js +180 -0
- package/dist/board-catalog/store.d.ts +196 -0
- package/dist/board-catalog/store.js +363 -0
- package/dist/board-catalog/types.d.ts +233 -0
- package/dist/board-catalog/types.js +7 -0
- package/dist/board-catalog/walker.d.ts +112 -0
- package/dist/board-catalog/walker.js +1101 -0
- package/dist/cli-utils.d.ts +2 -2
- package/dist/cli-utils.js +5 -5
- package/dist/cli.js +227 -244
- package/dist/config-loader.d.ts +14 -19
- package/dist/config-loader.js +242 -78
- package/dist/config-schema.d.ts +19 -227
- package/dist/config-schema.js +9 -8
- package/dist/contract/board-generator.d.ts +4 -4
- package/dist/contract/board-generator.js +16 -5
- package/dist/contract/contract-parser.d.ts +36 -127
- package/dist/contract/contract-parser.js +76 -0
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.js +70 -21
- package/dist/create/active-board-catalog.d.ts +9 -0
- package/dist/create/active-board-catalog.js +94 -0
- package/dist/create/board-catalog.generated.d.ts +96 -0
- package/dist/create/board-catalog.generated.js +128737 -0
- package/dist/create/board-search.d.ts +23 -0
- package/dist/create/board-search.js +88 -0
- package/dist/create/editor-integration.d.ts +32 -0
- package/dist/create/editor-integration.js +257 -0
- package/dist/create/eslint-rules-template.d.ts +2 -2
- package/dist/create/framework-catalog.d.ts +48 -8
- package/dist/create/framework-catalog.js +58 -44
- package/dist/create/index.d.ts +8 -13
- package/dist/create/index.js +5 -9
- package/dist/create/mcu-target.d.ts +39 -0
- package/dist/create/mcu-target.js +80 -0
- package/dist/create/pack-targets.d.ts +19 -0
- package/dist/create/pack-targets.js +56 -0
- package/dist/create/{init-scaffold.d.ts → scaffold.d.ts} +8 -11
- package/dist/create/{init-scaffold.js → scaffold.js} +28 -87
- package/dist/create/templates.d.ts +51 -0
- package/dist/create/{init-templates.js → templates.js} +135 -116
- package/dist/create/wizard.d.ts +19 -0
- package/dist/create/wizard.js +314 -0
- package/dist/debug/preprocessor.d.ts +5 -0
- package/dist/debug/preprocessor.js +31 -7
- package/dist/diagnostics/diagnostics-report.d.ts +1 -1
- package/dist/diagnostics/diagnostics-report.js +3 -11
- package/dist/diagnostics/json-schema.d.ts +1 -1
- package/dist/diagnostics/md-writer.js +2 -2
- package/dist/diagnostics/mermaid-builder.d.ts +1 -1
- package/dist/diagnostics/mermaid-builder.js +1 -1
- package/dist/emit/cpp-emitter.js +4 -1
- package/dist/emit/emitters/class-emitter.js +32 -4
- package/dist/emit/emitters/emitter-context.d.ts +11 -0
- package/dist/emit/emitters/entrypoint-synthesizer.js +1 -1
- package/dist/emit/emitters/function-emitter-impl.js +33 -17
- package/dist/emit/emitters/output-finalizer.d.ts +7 -0
- package/dist/emit/emitters/output-finalizer.js +31 -23
- package/dist/emit/emitters/setup.js +147 -63
- package/dist/emit/emitters/top-level-prep.js +1 -1
- package/dist/emit/emitters/type-decl-emitter.js +13 -8
- package/dist/emit/emitters/ui-emitter.js +1 -1
- package/dist/emit/expression-renderer.d.ts +3 -3
- package/dist/emit/expression-renderer.js +17 -7
- package/dist/emit/route-hal-op.js +17 -48
- package/dist/emit/snprintf-helpers.d.ts +1 -3
- package/dist/emit/snprintf-helpers.js +1 -39
- package/dist/emit/statement-renderer.d.ts +0 -4
- package/dist/emit/statement-renderer.js +54 -45
- package/dist/emit/utils/async-state-machine.d.ts +16 -9
- package/dist/emit/utils/async-state-machine.js +56 -54
- package/dist/emit/utils/comment-helpers.d.ts +0 -8
- package/dist/emit/utils/comment-helpers.js +1 -1
- package/dist/emit/utils/cpp-helpers.d.ts +2 -2
- package/dist/emit/utils/cpp-helpers.js +2 -2
- package/dist/emit/utils/hal-op-cpp-type.js +4 -6
- package/dist/emit/utils/index.d.ts +3 -3
- package/dist/emit/utils/index.js +3 -3
- package/dist/emit/utils/type-inference.d.ts +1 -29
- package/dist/emit/utils/type-inference.js +0 -75
- package/dist/framework-package.d.ts +3 -0
- package/dist/framework-package.js +23 -6
- package/dist/framework-registry.d.ts +5 -5
- package/dist/frameworks/native/graphics/terminal-preview.d.ts +5 -0
- package/dist/frameworks/native/graphics/terminal-preview.js +33 -0
- package/dist/frameworks/native/index.d.ts +3 -0
- package/dist/frameworks/native/index.js +15 -0
- package/dist/frameworks/native/native-compile.d.ts +17 -0
- package/dist/frameworks/native/native-compile.js +170 -0
- package/dist/frameworks/native/native-config.d.ts +41 -0
- package/dist/frameworks/native/native-config.js +7 -0
- package/dist/frameworks/native/strategy.d.ts +97 -0
- package/dist/frameworks/native/strategy.js +664 -0
- package/dist/ir/board-resolver.d.ts +18 -23
- package/dist/ir/board-resolver.js +43 -401
- package/dist/ir/build-ir-state.d.ts +3 -0
- package/dist/ir/build-ir-state.js +42 -0
- package/dist/ir/build-ir.d.ts +1 -1
- package/dist/ir/build-ir.js +64 -45
- package/dist/ir/declaration-builders.js +1 -0
- package/dist/ir/expression-to-ir.js +17 -10
- package/dist/ir/hal/hal-emitter.d.ts +0 -2
- package/dist/ir/hal/hal-emitter.js +92 -41
- package/dist/ir/hal/hal-parser.d.ts +5 -5
- package/dist/ir/hal/hal-parser.js +128 -36
- package/dist/ir/hal/hal-plugins.d.ts +0 -1
- package/dist/ir/hal/hal-plugins.js +425 -716
- package/dist/ir/heap-analysis.js +2 -41
- package/dist/ir/identifier-collector.js +32 -20
- package/dist/ir/network-validation.js +7 -11
- package/dist/ir/ownership-analysis.js +75 -13
- package/dist/ir/peripheral-usage.d.ts +8 -2
- package/dist/ir/peripheral-usage.js +78 -149
- package/dist/ir/peripheral-validation.js +23 -3
- package/dist/ir/pin-capability-validation.d.ts +12 -0
- package/dist/ir/pin-capability-validation.js +61 -97
- package/dist/ir/pin-mode-validation.js +5 -5
- package/dist/ir/program-analysis.d.ts +8 -15
- package/dist/ir/program-analysis.js +140 -323
- package/dist/ir/pulldown-validation.js +11 -4
- package/dist/ir/resource-analysis.js +15 -3
- package/dist/ir/statement-to-ir.js +0 -6
- package/dist/ir/timing-validation.js +1 -1
- package/dist/ir/transformers/array-methods.js +11 -5
- package/dist/ir/transformers/call-statement.js +20 -87
- package/dist/ir/transformers/callback-context-registry.d.ts +1 -1
- package/dist/ir/transformers/callback-context-registry.js +8 -16
- package/dist/ir/transformers/control-flow.js +0 -13
- package/dist/ir/transformers/expressions.js +10 -9
- package/dist/ir/transformers/hal-call-resolver.d.ts +2 -2
- package/dist/ir/transformers/hal-call-resolver.js +24 -10
- package/dist/ir/transformers/hal-emit-helpers.d.ts +2 -2
- package/dist/ir/transformers/hal-emit-helpers.js +2 -2
- package/dist/ir/transformers/namespace-methods.js +1 -1
- package/dist/ir/transformers/ui-callback-lowering.d.ts +0 -2
- package/dist/ir/transformers/ui-callback-lowering.js +0 -24
- package/dist/ir/transformers/variables.js +338 -42
- package/dist/ir/try-catch-validation.js +4 -3
- package/dist/ir/type-resolution.js +15 -4
- package/dist/ir/validation-orchestrator.js +0 -9
- package/dist/libdef/cpp-to-decl.d.ts +0 -9
- package/dist/libdef/cpp-to-decl.js +0 -72
- package/dist/libdef/registry.d.ts +0 -1
- package/dist/libdef/registry.js +1 -24
- package/dist/library/catalog.d.ts +35 -0
- package/dist/library/catalog.js +67 -0
- package/dist/library/cli.d.ts +2 -0
- package/dist/library/cli.js +168 -0
- package/dist/library/init.d.ts +25 -0
- package/dist/library/init.js +397 -0
- package/dist/library/install.d.ts +9 -0
- package/dist/library/install.js +80 -0
- package/dist/library/registry-search.d.ts +34 -0
- package/dist/library/registry-search.js +50 -0
- package/dist/library/validate.d.ts +17 -0
- package/dist/library/validate.js +175 -0
- package/dist/library-packages.d.ts +95 -0
- package/dist/library-packages.js +275 -0
- package/dist/mapping/peripheral-names.js +9 -4
- package/dist/mapping/source-map.d.ts +3 -4
- package/dist/mapping/source-map.js +12 -18
- package/dist/orchestrator/graph-builder.d.ts +3 -3
- package/dist/orchestrator/graph-builder.js +29 -12
- package/dist/orchestrator/type-checker.d.ts +3 -3
- package/dist/orchestrator/type-checker.js +3 -3
- package/dist/platform/async-runtime.js +1 -1
- package/dist/platform/coop-scheduler-runtime.js +2 -2
- package/dist/platform/generic-debug-codegen.d.ts +36 -0
- package/dist/platform/generic-debug-codegen.js +185 -0
- package/dist/platform/generic-strategy.d.ts +3 -4
- package/dist/platform/generic-strategy.js +5 -80
- package/dist/platform/index.js +1 -1
- package/dist/platform/registry.d.ts +2 -2
- package/dist/platform/registry.js +2 -2
- package/dist/preview/client.js +17 -3
- package/dist/safety/asil-decorators.d.ts +32 -0
- package/dist/safety/asil-decorators.js +32 -0
- package/dist/safety/authoring.d.ts +85 -0
- package/dist/safety/authoring.js +61 -0
- package/dist/safety/engine.d.ts +3 -0
- package/dist/safety/engine.js +83 -0
- package/dist/safety/hal/ops.d.ts +48 -0
- package/dist/safety/hal/ops.js +46 -0
- package/dist/safety/iso26262/analyze.d.ts +13 -0
- package/dist/safety/iso26262/analyze.js +29 -0
- package/dist/safety/iso26262/asil.d.ts +10 -0
- package/dist/safety/iso26262/asil.js +22 -0
- package/dist/safety/iso26262/collect.d.ts +14 -0
- package/dist/safety/iso26262/collect.js +137 -0
- package/dist/safety/iso26262/goto-checker.d.ts +10 -0
- package/dist/safety/iso26262/goto-checker.js +72 -0
- package/dist/safety/iso26262/heap-checker.d.ts +7 -0
- package/dist/safety/iso26262/heap-checker.js +57 -0
- package/dist/safety/iso26262/init-checker.d.ts +13 -0
- package/dist/safety/iso26262/init-checker.js +127 -0
- package/dist/safety/iso26262/loop-checker.d.ts +7 -0
- package/dist/safety/iso26262/loop-checker.js +86 -0
- package/dist/safety/iso26262/recursion-checker.d.ts +9 -0
- package/dist/safety/iso26262/recursion-checker.js +134 -0
- package/dist/safety/iso26262/sidecar-writer.d.ts +25 -0
- package/dist/safety/iso26262/sidecar-writer.js +13 -0
- package/dist/safety/passes/pinMode-intercept.d.ts +3 -0
- package/dist/safety/passes/pinMode-intercept.js +60 -0
- package/dist/safety/runtime/mode-table.d.ts +5 -0
- package/dist/safety/runtime/mode-table.js +55 -0
- package/dist/safety/runtime/polyfills.d.ts +6 -0
- package/dist/safety/runtime/polyfills.js +12 -0
- package/dist/safety/runtime/result-struct.d.ts +11 -0
- package/dist/safety/runtime/result-struct.js +98 -0
- package/dist/safety/runtime/safe-int.d.ts +33 -0
- package/dist/safety/runtime/safe-int.js +170 -0
- package/dist/safety/runtime/safe-traits.d.ts +4 -0
- package/dist/safety/runtime/safe-traits.js +95 -0
- package/dist/safety/runtime/safe-variable.d.ts +39 -0
- package/dist/safety/runtime/safe-variable.js +226 -0
- package/dist/safety/runtime/vote.d.ts +8 -0
- package/dist/safety/runtime/vote.js +92 -0
- package/dist/safety/runtime/write-verify.d.ts +8 -0
- package/dist/safety/runtime/write-verify.js +71 -0
- package/dist/safety/safe-int-types.d.ts +45 -0
- package/dist/safety/safe-int-types.js +25 -0
- package/dist/safety/safe-variable-types.d.ts +29 -0
- package/dist/safety/safe-variable-types.js +19 -0
- package/dist/safety/safety-bridge.d.ts +5 -6
- package/dist/safety/safety-bridge.js +15 -28
- package/dist/safety/sidecar-bridge.d.ts +1 -3
- package/dist/safety/sidecar-bridge.js +3 -20
- package/dist/safety/specifiers.d.ts +6 -0
- package/dist/safety/specifiers.js +14 -0
- package/dist/safety-hook.d.ts +8 -7
- package/dist/safety-hook.js +12 -13
- package/dist/testing.d.ts +5 -6
- package/dist/testing.js +5 -5
- package/dist/transpile/resolution.d.ts +1 -1
- package/dist/transpile/resolution.js +18 -9
- package/dist/transpile/test-pins.d.ts +18 -0
- package/dist/transpile/test-pins.js +142 -0
- package/dist/transpile.d.ts +1 -2
- package/dist/transpile.js +90 -29
- package/dist/types.d.ts +45 -26
- package/dist/ui-hook.d.ts +1 -1
- package/dist/utils/cli.d.ts +2 -2
- package/dist/utils/cli.js +160 -157
- package/dist/utils/fs.d.ts +3 -4
- package/dist/utils/fs.js +4 -5
- package/dist/utils/strings.d.ts +0 -1
- package/dist/utils/strings.js +0 -8
- package/dist/utils/ui.d.ts +5 -2
- package/dist/utils/ui.js +13 -3
- package/package.json +158 -149
- package/dist/add-preset.d.ts +0 -4
- package/dist/add-preset.js +0 -74
- package/dist/api/shared/async-symbol-detector.d.ts +0 -11
- package/dist/api/shared/async-symbol-detector.js +0 -140
- package/dist/api/shared/native-display-op-resolver.d.ts +0 -10
- package/dist/api/shared/native-display-op-resolver.js +0 -64
- package/dist/create/board-checklist.d.ts +0 -2
- package/dist/create/board-checklist.js +0 -52
- package/dist/create/board-codegen.d.ts +0 -9
- package/dist/create/board-codegen.js +0 -238
- package/dist/create/board-generators.d.ts +0 -12
- package/dist/create/board-generators.js +0 -651
- package/dist/create/board-spec.d.ts +0 -637
- package/dist/create/board-spec.js +0 -214
- package/dist/create/init-templates.d.ts +0 -28
- package/dist/create/init-wizard.d.ts +0 -8
- package/dist/create/init-wizard.js +0 -182
- package/dist/install/framework-catalog.d.ts +0 -53
- package/dist/install/framework-catalog.js +0 -107
- package/dist/install/handle-install.d.ts +0 -35
- package/dist/install/handle-install.js +0 -177
- package/dist/install/index.d.ts +0 -4
- package/dist/install/index.js +0 -3
- package/dist/ir/pin-state-tracking.d.ts +0 -58
- package/dist/ir/pin-state-tracking.js +0 -182
- package/dist/ir/pwm-timer-sharing.d.ts +0 -4
- package/dist/ir/pwm-timer-sharing.js +0 -94
- package/dist/ir/timer0-pwm-timing-conflict.d.ts +0 -4
- package/dist/ir/timer0-pwm-timing-conflict.js +0 -72
- package/dist/libdef/component-decls.d.ts +0 -2
- package/dist/libdef/component-decls.js +0 -6
- package/dist/libdef/component-discovery.d.ts +0 -43
- package/dist/libdef/component-discovery.js +0 -83
- package/dist/theme-tokens.d.ts +0 -22
- package/dist/theme-tokens.js +0 -172
package/dist/config-schema.d.ts
CHANGED
|
@@ -4,257 +4,49 @@ import { z } from 'zod';
|
|
|
4
4
|
*
|
|
5
5
|
* `target` and `board` are required. Everything else is optional.
|
|
6
6
|
*/
|
|
7
|
-
export declare const CuttlefishConfigSchema: z.
|
|
7
|
+
export declare const CuttlefishConfigSchema: z.ZodObject<{
|
|
8
8
|
entry: z.ZodOptional<z.ZodString>;
|
|
9
9
|
target: z.ZodOptional<z.ZodString>;
|
|
10
|
-
mcu: z.ZodOptional<z.ZodString>;
|
|
11
10
|
board: z.ZodOptional<z.ZodString>;
|
|
11
|
+
soc: z.ZodOptional<z.ZodString>;
|
|
12
12
|
contract: z.ZodOptional<z.ZodString>;
|
|
13
13
|
framework: z.ZodOptional<z.ZodString>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
psram: z.ZodOptional<z.ZodEnum<["opi", "quad"]>>;
|
|
14
|
+
psram: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
opi: "opi";
|
|
16
|
+
quad: "quad";
|
|
17
|
+
}>>;
|
|
19
18
|
output: z.ZodOptional<z.ZodObject<{
|
|
20
19
|
framework: z.ZodOptional<z.ZodString>;
|
|
21
20
|
outDir: z.ZodOptional<z.ZodString>;
|
|
22
21
|
defines: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
23
|
-
extraFlags: z.ZodOptional<z.ZodArray<z.ZodString
|
|
24
|
-
},
|
|
25
|
-
framework?: string | undefined;
|
|
26
|
-
outDir?: string | undefined;
|
|
27
|
-
defines?: Record<string, string> | undefined;
|
|
28
|
-
extraFlags?: string[] | undefined;
|
|
29
|
-
}, {
|
|
30
|
-
framework?: string | undefined;
|
|
31
|
-
outDir?: string | undefined;
|
|
32
|
-
defines?: Record<string, string> | undefined;
|
|
33
|
-
extraFlags?: string[] | undefined;
|
|
34
|
-
}>>;
|
|
22
|
+
extraFlags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
23
|
+
}, z.core.$strict>>;
|
|
35
24
|
frameworkData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
36
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString
|
|
37
|
-
exclude: z.ZodOptional<z.ZodArray<z.ZodString
|
|
25
|
+
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
27
|
test: z.ZodOptional<z.ZodObject<{
|
|
39
|
-
include: z.ZodOptional<z.ZodArray<z.ZodString
|
|
28
|
+
include: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
40
29
|
port: z.ZodOptional<z.ZodString>;
|
|
41
30
|
baudRate: z.ZodOptional<z.ZodNumber>;
|
|
42
31
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
43
32
|
buildTarget: z.ZodOptional<z.ZodString>;
|
|
44
33
|
board: z.ZodOptional<z.ZodString>;
|
|
45
|
-
},
|
|
46
|
-
board?: string | undefined;
|
|
47
|
-
include?: string[] | undefined;
|
|
48
|
-
port?: string | undefined;
|
|
49
|
-
baudRate?: number | undefined;
|
|
50
|
-
timeout?: number | undefined;
|
|
51
|
-
buildTarget?: string | undefined;
|
|
52
|
-
}, {
|
|
53
|
-
board?: string | undefined;
|
|
54
|
-
include?: string[] | undefined;
|
|
55
|
-
port?: string | undefined;
|
|
56
|
-
baudRate?: number | undefined;
|
|
57
|
-
timeout?: number | undefined;
|
|
58
|
-
buildTarget?: string | undefined;
|
|
59
|
-
}>>;
|
|
34
|
+
}, z.core.$strict>>;
|
|
60
35
|
toolchain: z.ZodOptional<z.ZodObject<{
|
|
61
36
|
type: z.ZodOptional<z.ZodString>;
|
|
62
37
|
frameworkOptions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
63
|
-
},
|
|
64
|
-
type?: string | undefined;
|
|
65
|
-
frameworkOptions?: Record<string, unknown> | undefined;
|
|
66
|
-
}, {
|
|
67
|
-
type?: string | undefined;
|
|
68
|
-
frameworkOptions?: Record<string, unknown> | undefined;
|
|
69
|
-
}>>;
|
|
70
|
-
console: z.ZodOptional<z.ZodObject<{
|
|
71
|
-
baudRate: z.ZodOptional<z.ZodNumber>;
|
|
72
|
-
port: z.ZodOptional<z.ZodString>;
|
|
73
|
-
}, "strict", z.ZodTypeAny, {
|
|
74
|
-
port?: string | undefined;
|
|
75
|
-
baudRate?: number | undefined;
|
|
76
|
-
}, {
|
|
77
|
-
port?: string | undefined;
|
|
78
|
-
baudRate?: number | undefined;
|
|
79
|
-
}>>;
|
|
38
|
+
}, z.core.$strict>>;
|
|
80
39
|
native: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
81
|
-
/** Display profile config (driver, wiring, touch) — loosely typed here so
|
|
82
|
-
* the loader's presence/shape extraction round-trips through validation. */
|
|
83
40
|
display: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
84
41
|
zephyr: z.ZodOptional<z.ZodObject<{
|
|
85
42
|
kconfig: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
86
|
-
cmakeArgs: z.ZodOptional<z.ZodArray<z.ZodString
|
|
43
|
+
cmakeArgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
44
|
+
probe: z.ZodOptional<z.ZodString>;
|
|
87
45
|
runner: z.ZodOptional<z.ZodString>;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}, {
|
|
93
|
-
kconfig?: Record<string, string> | undefined;
|
|
94
|
-
cmakeArgs?: string[] | undefined;
|
|
95
|
-
runner?: string | undefined;
|
|
96
|
-
}>>;
|
|
97
|
-
}, "strict", z.ZodTypeAny, {
|
|
98
|
-
entry?: string | undefined;
|
|
99
|
-
target?: string | undefined;
|
|
100
|
-
mcu?: string | undefined;
|
|
101
|
-
board?: string | undefined;
|
|
102
|
-
contract?: string | undefined;
|
|
103
|
-
framework?: string | undefined;
|
|
104
|
-
psram?: "opi" | "quad" | undefined;
|
|
105
|
-
output?: {
|
|
106
|
-
framework?: string | undefined;
|
|
107
|
-
outDir?: string | undefined;
|
|
108
|
-
defines?: Record<string, string> | undefined;
|
|
109
|
-
extraFlags?: string[] | undefined;
|
|
110
|
-
} | undefined;
|
|
111
|
-
frameworkData?: Record<string, unknown> | undefined;
|
|
112
|
-
include?: string[] | undefined;
|
|
113
|
-
exclude?: string[] | undefined;
|
|
114
|
-
test?: {
|
|
115
|
-
board?: string | undefined;
|
|
116
|
-
include?: string[] | undefined;
|
|
117
|
-
port?: string | undefined;
|
|
118
|
-
baudRate?: number | undefined;
|
|
119
|
-
timeout?: number | undefined;
|
|
120
|
-
buildTarget?: string | undefined;
|
|
121
|
-
} | undefined;
|
|
122
|
-
toolchain?: {
|
|
123
|
-
type?: string | undefined;
|
|
124
|
-
frameworkOptions?: Record<string, unknown> | undefined;
|
|
125
|
-
} | undefined;
|
|
126
|
-
console?: {
|
|
127
|
-
port?: string | undefined;
|
|
128
|
-
baudRate?: number | undefined;
|
|
129
|
-
} | undefined;
|
|
130
|
-
native?: Record<string, unknown> | undefined;
|
|
131
|
-
display?: Record<string, unknown> | undefined;
|
|
132
|
-
zephyr?: {
|
|
133
|
-
kconfig?: Record<string, string> | undefined;
|
|
134
|
-
cmakeArgs?: string[] | undefined;
|
|
135
|
-
runner?: string | undefined;
|
|
136
|
-
} | undefined;
|
|
137
|
-
}, {
|
|
138
|
-
entry?: string | undefined;
|
|
139
|
-
target?: string | undefined;
|
|
140
|
-
mcu?: string | undefined;
|
|
141
|
-
board?: string | undefined;
|
|
142
|
-
contract?: string | undefined;
|
|
143
|
-
framework?: string | undefined;
|
|
144
|
-
psram?: "opi" | "quad" | undefined;
|
|
145
|
-
output?: {
|
|
146
|
-
framework?: string | undefined;
|
|
147
|
-
outDir?: string | undefined;
|
|
148
|
-
defines?: Record<string, string> | undefined;
|
|
149
|
-
extraFlags?: string[] | undefined;
|
|
150
|
-
} | undefined;
|
|
151
|
-
frameworkData?: Record<string, unknown> | undefined;
|
|
152
|
-
include?: string[] | undefined;
|
|
153
|
-
exclude?: string[] | undefined;
|
|
154
|
-
test?: {
|
|
155
|
-
board?: string | undefined;
|
|
156
|
-
include?: string[] | undefined;
|
|
157
|
-
port?: string | undefined;
|
|
158
|
-
baudRate?: number | undefined;
|
|
159
|
-
timeout?: number | undefined;
|
|
160
|
-
buildTarget?: string | undefined;
|
|
161
|
-
} | undefined;
|
|
162
|
-
toolchain?: {
|
|
163
|
-
type?: string | undefined;
|
|
164
|
-
frameworkOptions?: Record<string, unknown> | undefined;
|
|
165
|
-
} | undefined;
|
|
166
|
-
console?: {
|
|
167
|
-
port?: string | undefined;
|
|
168
|
-
baudRate?: number | undefined;
|
|
169
|
-
} | undefined;
|
|
170
|
-
native?: Record<string, unknown> | undefined;
|
|
171
|
-
display?: Record<string, unknown> | undefined;
|
|
172
|
-
zephyr?: {
|
|
173
|
-
kconfig?: Record<string, string> | undefined;
|
|
174
|
-
cmakeArgs?: string[] | undefined;
|
|
175
|
-
runner?: string | undefined;
|
|
176
|
-
} | undefined;
|
|
177
|
-
}>, {
|
|
178
|
-
entry?: string | undefined;
|
|
179
|
-
target?: string | undefined;
|
|
180
|
-
mcu?: string | undefined;
|
|
181
|
-
board?: string | undefined;
|
|
182
|
-
contract?: string | undefined;
|
|
183
|
-
framework?: string | undefined;
|
|
184
|
-
psram?: "opi" | "quad" | undefined;
|
|
185
|
-
output?: {
|
|
186
|
-
framework?: string | undefined;
|
|
187
|
-
outDir?: string | undefined;
|
|
188
|
-
defines?: Record<string, string> | undefined;
|
|
189
|
-
extraFlags?: string[] | undefined;
|
|
190
|
-
} | undefined;
|
|
191
|
-
frameworkData?: Record<string, unknown> | undefined;
|
|
192
|
-
include?: string[] | undefined;
|
|
193
|
-
exclude?: string[] | undefined;
|
|
194
|
-
test?: {
|
|
195
|
-
board?: string | undefined;
|
|
196
|
-
include?: string[] | undefined;
|
|
197
|
-
port?: string | undefined;
|
|
198
|
-
baudRate?: number | undefined;
|
|
199
|
-
timeout?: number | undefined;
|
|
200
|
-
buildTarget?: string | undefined;
|
|
201
|
-
} | undefined;
|
|
202
|
-
toolchain?: {
|
|
203
|
-
type?: string | undefined;
|
|
204
|
-
frameworkOptions?: Record<string, unknown> | undefined;
|
|
205
|
-
} | undefined;
|
|
206
|
-
console?: {
|
|
207
|
-
port?: string | undefined;
|
|
208
|
-
baudRate?: number | undefined;
|
|
209
|
-
} | undefined;
|
|
210
|
-
native?: Record<string, unknown> | undefined;
|
|
211
|
-
display?: Record<string, unknown> | undefined;
|
|
212
|
-
zephyr?: {
|
|
213
|
-
kconfig?: Record<string, string> | undefined;
|
|
214
|
-
cmakeArgs?: string[] | undefined;
|
|
215
|
-
runner?: string | undefined;
|
|
216
|
-
} | undefined;
|
|
217
|
-
}, {
|
|
218
|
-
entry?: string | undefined;
|
|
219
|
-
target?: string | undefined;
|
|
220
|
-
mcu?: string | undefined;
|
|
221
|
-
board?: string | undefined;
|
|
222
|
-
contract?: string | undefined;
|
|
223
|
-
framework?: string | undefined;
|
|
224
|
-
psram?: "opi" | "quad" | undefined;
|
|
225
|
-
output?: {
|
|
226
|
-
framework?: string | undefined;
|
|
227
|
-
outDir?: string | undefined;
|
|
228
|
-
defines?: Record<string, string> | undefined;
|
|
229
|
-
extraFlags?: string[] | undefined;
|
|
230
|
-
} | undefined;
|
|
231
|
-
frameworkData?: Record<string, unknown> | undefined;
|
|
232
|
-
include?: string[] | undefined;
|
|
233
|
-
exclude?: string[] | undefined;
|
|
234
|
-
test?: {
|
|
235
|
-
board?: string | undefined;
|
|
236
|
-
include?: string[] | undefined;
|
|
237
|
-
port?: string | undefined;
|
|
238
|
-
baudRate?: number | undefined;
|
|
239
|
-
timeout?: number | undefined;
|
|
240
|
-
buildTarget?: string | undefined;
|
|
241
|
-
} | undefined;
|
|
242
|
-
toolchain?: {
|
|
243
|
-
type?: string | undefined;
|
|
244
|
-
frameworkOptions?: Record<string, unknown> | undefined;
|
|
245
|
-
} | undefined;
|
|
246
|
-
console?: {
|
|
247
|
-
port?: string | undefined;
|
|
248
|
-
baudRate?: number | undefined;
|
|
249
|
-
} | undefined;
|
|
250
|
-
native?: Record<string, unknown> | undefined;
|
|
251
|
-
display?: Record<string, unknown> | undefined;
|
|
252
|
-
zephyr?: {
|
|
253
|
-
kconfig?: Record<string, string> | undefined;
|
|
254
|
-
cmakeArgs?: string[] | undefined;
|
|
255
|
-
runner?: string | undefined;
|
|
256
|
-
} | undefined;
|
|
257
|
-
}>;
|
|
46
|
+
runnerArgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
47
|
+
customBoard: z.ZodOptional<z.ZodBoolean>;
|
|
48
|
+
}, z.core.$strict>>;
|
|
49
|
+
}, z.core.$strict>;
|
|
258
50
|
/** Inferred TypeScript type from the Zod schema. */
|
|
259
51
|
export type ValidatedCuttlefishConfig = z.infer<typeof CuttlefishConfigSchema>;
|
|
260
52
|
/**
|
package/dist/config-schema.js
CHANGED
|
@@ -15,11 +15,6 @@ const OutputConfig = z.object({
|
|
|
15
15
|
defines: z.record(z.string(), z.string()).optional(),
|
|
16
16
|
extraFlags: z.array(z.string()).optional(),
|
|
17
17
|
}).strict();
|
|
18
|
-
/** Schema for the `console` section. */
|
|
19
|
-
const ConsoleConfig = z.object({
|
|
20
|
-
baudRate: z.number().int().positive().optional(),
|
|
21
|
-
port: z.string().optional(),
|
|
22
|
-
}).strict();
|
|
23
18
|
/** Schema for the `test` section. */
|
|
24
19
|
const TestConfig = z.object({
|
|
25
20
|
include: z.array(z.string()).optional(),
|
|
@@ -38,7 +33,14 @@ const ToolchainConfig = z.object({
|
|
|
38
33
|
const ZephyrConfig = z.object({
|
|
39
34
|
kconfig: z.record(z.string(), z.string()).optional(),
|
|
40
35
|
cmakeArgs: z.array(z.string()).optional(),
|
|
36
|
+
probe: z.string().optional(),
|
|
41
37
|
runner: z.string().optional(),
|
|
38
|
+
runnerArgs: z.array(z.string()).optional(),
|
|
39
|
+
/** Generate an out-of-tree Zephyr board for an MCU-only target (no board
|
|
40
|
+
* package): the framework emits boards/typecad/<buildTarget>/ from the
|
|
41
|
+
* MCU package's silicon data (SoC, console, clock plan). The board is
|
|
42
|
+
* named after `frameworkData.buildTarget`. */
|
|
43
|
+
customBoard: z.boolean().optional(),
|
|
42
44
|
}).strict();
|
|
43
45
|
/**
|
|
44
46
|
* Schema for the full CuttlefishConfig shape.
|
|
@@ -48,8 +50,8 @@ const ZephyrConfig = z.object({
|
|
|
48
50
|
export const CuttlefishConfigSchema = z.object({
|
|
49
51
|
entry: z.string().optional(),
|
|
50
52
|
target: z.string().min(1).optional(),
|
|
51
|
-
mcu: z.string().min(1).optional(),
|
|
52
53
|
board: z.string().optional(),
|
|
54
|
+
soc: z.string().optional(),
|
|
53
55
|
contract: z.string().optional(),
|
|
54
56
|
framework: z.string().optional(),
|
|
55
57
|
/** ESP32 PSRAM type. When set, the framework emits the PSRAM-enabling
|
|
@@ -63,13 +65,12 @@ export const CuttlefishConfigSchema = z.object({
|
|
|
63
65
|
exclude: z.array(z.string()).optional(),
|
|
64
66
|
test: TestConfig.optional(),
|
|
65
67
|
toolchain: ToolchainConfig.optional(),
|
|
66
|
-
console: ConsoleConfig.optional(),
|
|
67
68
|
native: z.record(z.string(), z.unknown()).optional(),
|
|
68
69
|
/** Display profile config (driver, wiring, touch) — loosely typed here so
|
|
69
70
|
* the loader's presence/shape extraction round-trips through validation. */
|
|
70
71
|
display: z.record(z.string(), z.unknown()).optional(),
|
|
71
72
|
zephyr: ZephyrConfig.optional(),
|
|
72
|
-
}).strict().refine(data => !(data.board && data.contract), {
|
|
73
|
+
}).strict().refine(data => !(data.board && (data.contract || data.soc)), {
|
|
73
74
|
message: "Specifying both 'board' and 'contract' is not allowed. Choose one.",
|
|
74
75
|
path: ['board'],
|
|
75
76
|
});
|
|
@@ -3,11 +3,11 @@ export declare const CUTTLEFISH_DIR = ".cuttlefish";
|
|
|
3
3
|
export interface GenerateBoardOptions {
|
|
4
4
|
/** Absolute project root dir (where .cuttlefish/ lives). */
|
|
5
5
|
projectDir: string;
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
/** Matched
|
|
6
|
+
/** The Zephyr SoC name the contract narrows (e.g. 'stm32f411xe'). */
|
|
7
|
+
soc: string;
|
|
8
|
+
/** Matched pin names to export (e.g. ['PB5','PC4']). */
|
|
9
9
|
connectedPins: string[];
|
|
10
|
-
/** Selected peripheral instance names to
|
|
10
|
+
/** Selected peripheral instance names to export (e.g. ['I2C0']). */
|
|
11
11
|
peripherals: string[];
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
// ---------------------------------------------------------------------------
|
|
18
18
|
import fs from 'node:fs';
|
|
19
19
|
import path from 'node:path';
|
|
20
|
+
const BS_DOT = /\./g;
|
|
20
21
|
/** The directory (relative to the project root) where board.ts is generated. */
|
|
21
22
|
export const CUTTLEFISH_DIR = '.cuttlefish';
|
|
22
23
|
/**
|
|
@@ -24,7 +25,7 @@ export const CUTTLEFISH_DIR = '.cuttlefish';
|
|
|
24
25
|
* @returns the absolute path to the generated file.
|
|
25
26
|
*/
|
|
26
27
|
export function generateBoardFile(opts) {
|
|
27
|
-
const { projectDir,
|
|
28
|
+
const { projectDir, soc, connectedPins, peripherals } = opts;
|
|
28
29
|
const cuttlefishDir = path.join(projectDir, CUTTLEFISH_DIR);
|
|
29
30
|
if (!fs.existsSync(cuttlefishDir)) {
|
|
30
31
|
fs.mkdirSync(cuttlefishDir, { recursive: true });
|
|
@@ -34,21 +35,31 @@ export function generateBoardFile(opts) {
|
|
|
34
35
|
'// Do not edit manually — regenerate by re-running cuttlefish.',
|
|
35
36
|
'//',
|
|
36
37
|
'// This board exposes only the pins and peripherals that the source contract',
|
|
37
|
-
`// (${
|
|
38
|
+
`// (soc ${soc}) declares as connected on the PCB. Pins the board did not wire`,
|
|
38
39
|
'// are intentionally absent: using one is a compile error.',
|
|
39
40
|
'',
|
|
40
41
|
'// Full HAL runtime surface (constants, timing, math, GPIO/bus helpers).',
|
|
41
|
-
"
|
|
42
|
+
"import { Pin, I2CBus, SPIBus, UART } from '@typecad/hal';",
|
|
42
43
|
'',
|
|
43
44
|
'// Narrowed pin set — only pins the contract declares connected.',
|
|
44
45
|
];
|
|
45
46
|
if (connectedPins.length > 0) {
|
|
46
|
-
|
|
47
|
+
for (const pin of connectedPins) {
|
|
48
|
+
const ident = pin.replace(BS_DOT, '_');
|
|
49
|
+
lines.push(`export const ${ident} = Pin.fromPort('${pin}');`);
|
|
50
|
+
}
|
|
47
51
|
}
|
|
48
52
|
if (peripherals.length > 0) {
|
|
49
53
|
lines.push('');
|
|
50
54
|
lines.push('// Narrowed peripheral set — only buses whose pins are wired on the PCB.');
|
|
51
|
-
|
|
55
|
+
for (const p of peripherals) {
|
|
56
|
+
if (p.startsWith('I2C'))
|
|
57
|
+
lines.push(`export const ${p} = new I2CBus('${p}');`);
|
|
58
|
+
else if (p.startsWith('SPI'))
|
|
59
|
+
lines.push(`export const ${p} = new SPIBus('${p}');`);
|
|
60
|
+
else if (p.startsWith('UART'))
|
|
61
|
+
lines.push(`export const ${p} = new UART('${p}');`);
|
|
62
|
+
}
|
|
52
63
|
}
|
|
53
64
|
lines.push(''); // trailing newline
|
|
54
65
|
const outPath = path.join(cuttlefishDir, 'board.ts');
|
|
@@ -11,13 +11,7 @@ export declare const CONTRACT_VERSION: 1;
|
|
|
11
11
|
declare const ContractComponentSchema: z.ZodObject<{
|
|
12
12
|
reference: z.ZodString;
|
|
13
13
|
dnp: z.ZodBoolean;
|
|
14
|
-
},
|
|
15
|
-
reference: z.ZodString;
|
|
16
|
-
dnp: z.ZodBoolean;
|
|
17
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
18
|
-
reference: z.ZodString;
|
|
19
|
-
dnp: z.ZodBoolean;
|
|
20
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
14
|
+
}, z.core.$loose>;
|
|
21
15
|
/**
|
|
22
16
|
* Info about a single connected MCU pin. The fields cuttlefish consumes
|
|
23
17
|
* (pinName, pinType, net) are required; boardName is optional (present only
|
|
@@ -31,46 +25,14 @@ declare const ContractPinSchema: z.ZodObject<{
|
|
|
31
25
|
externalComponents: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
32
26
|
reference: z.ZodString;
|
|
33
27
|
dnp: z.ZodBoolean;
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
dnp: z.ZodBoolean;
|
|
37
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
38
|
-
reference: z.ZodString;
|
|
39
|
-
dnp: z.ZodBoolean;
|
|
40
|
-
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
41
|
-
}, "strict", z.ZodTypeAny, {
|
|
42
|
-
pinName: string;
|
|
43
|
-
pinType: string;
|
|
44
|
-
net: string;
|
|
45
|
-
externalComponents: z.objectOutputType<{
|
|
46
|
-
reference: z.ZodString;
|
|
47
|
-
dnp: z.ZodBoolean;
|
|
48
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
49
|
-
boardName?: string | undefined;
|
|
50
|
-
}, {
|
|
51
|
-
pinName: string;
|
|
52
|
-
pinType: string;
|
|
53
|
-
net: string;
|
|
54
|
-
boardName?: string | undefined;
|
|
55
|
-
externalComponents?: z.objectInputType<{
|
|
56
|
-
reference: z.ZodString;
|
|
57
|
-
dnp: z.ZodBoolean;
|
|
58
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
59
|
-
}>;
|
|
28
|
+
}, z.core.$loose>>>;
|
|
29
|
+
}, z.core.$strict>;
|
|
60
30
|
/** Which peripheral buses have all their required pins wired. */
|
|
61
31
|
declare const AvailablePeripheralsSchema: z.ZodObject<{
|
|
62
32
|
i2c: z.ZodBoolean;
|
|
63
33
|
spi: z.ZodBoolean;
|
|
64
34
|
uart: z.ZodBoolean;
|
|
65
|
-
},
|
|
66
|
-
i2c: boolean;
|
|
67
|
-
spi: boolean;
|
|
68
|
-
uart: boolean;
|
|
69
|
-
}, {
|
|
70
|
-
i2c: boolean;
|
|
71
|
-
spi: boolean;
|
|
72
|
-
uart: boolean;
|
|
73
|
-
}>;
|
|
35
|
+
}, z.core.$strict>;
|
|
74
36
|
/**
|
|
75
37
|
* The top-level contract object. `.strict()` so a future v2 contract with new
|
|
76
38
|
* top-level keys is rejected clearly (complementing the version check) rather
|
|
@@ -80,11 +42,7 @@ export declare const HwContractSchema: z.ZodObject<{
|
|
|
80
42
|
version: z.ZodLiteral<1>;
|
|
81
43
|
mcu: z.ZodObject<{
|
|
82
44
|
symbol: z.ZodString;
|
|
83
|
-
},
|
|
84
|
-
symbol: z.ZodString;
|
|
85
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
86
|
-
symbol: z.ZodString;
|
|
87
|
-
}, z.ZodTypeAny, "passthrough">>;
|
|
45
|
+
}, z.core.$loose>;
|
|
88
46
|
connectedPins: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
89
47
|
pinName: z.ZodString;
|
|
90
48
|
pinType: z.ZodString;
|
|
@@ -93,90 +51,14 @@ export declare const HwContractSchema: z.ZodObject<{
|
|
|
93
51
|
externalComponents: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
94
52
|
reference: z.ZodString;
|
|
95
53
|
dnp: z.ZodBoolean;
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
dnp: z.ZodBoolean;
|
|
99
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
100
|
-
reference: z.ZodString;
|
|
101
|
-
dnp: z.ZodBoolean;
|
|
102
|
-
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
103
|
-
}, "strict", z.ZodTypeAny, {
|
|
104
|
-
pinName: string;
|
|
105
|
-
pinType: string;
|
|
106
|
-
net: string;
|
|
107
|
-
externalComponents: z.objectOutputType<{
|
|
108
|
-
reference: z.ZodString;
|
|
109
|
-
dnp: z.ZodBoolean;
|
|
110
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
111
|
-
boardName?: string | undefined;
|
|
112
|
-
}, {
|
|
113
|
-
pinName: string;
|
|
114
|
-
pinType: string;
|
|
115
|
-
net: string;
|
|
116
|
-
boardName?: string | undefined;
|
|
117
|
-
externalComponents?: z.objectInputType<{
|
|
118
|
-
reference: z.ZodString;
|
|
119
|
-
dnp: z.ZodBoolean;
|
|
120
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
121
|
-
}>>;
|
|
54
|
+
}, z.core.$loose>>>;
|
|
55
|
+
}, z.core.$strict>>;
|
|
122
56
|
availablePeripherals: z.ZodObject<{
|
|
123
57
|
i2c: z.ZodBoolean;
|
|
124
58
|
spi: z.ZodBoolean;
|
|
125
59
|
uart: z.ZodBoolean;
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
spi: boolean;
|
|
129
|
-
uart: boolean;
|
|
130
|
-
}, {
|
|
131
|
-
i2c: boolean;
|
|
132
|
-
spi: boolean;
|
|
133
|
-
uart: boolean;
|
|
134
|
-
}>;
|
|
135
|
-
}, "strict", z.ZodTypeAny, {
|
|
136
|
-
mcu: {
|
|
137
|
-
symbol: string;
|
|
138
|
-
} & {
|
|
139
|
-
[k: string]: unknown;
|
|
140
|
-
};
|
|
141
|
-
version: 1;
|
|
142
|
-
connectedPins: Record<string, {
|
|
143
|
-
pinName: string;
|
|
144
|
-
pinType: string;
|
|
145
|
-
net: string;
|
|
146
|
-
externalComponents: z.objectOutputType<{
|
|
147
|
-
reference: z.ZodString;
|
|
148
|
-
dnp: z.ZodBoolean;
|
|
149
|
-
}, z.ZodTypeAny, "passthrough">[];
|
|
150
|
-
boardName?: string | undefined;
|
|
151
|
-
}>;
|
|
152
|
-
availablePeripherals: {
|
|
153
|
-
i2c: boolean;
|
|
154
|
-
spi: boolean;
|
|
155
|
-
uart: boolean;
|
|
156
|
-
};
|
|
157
|
-
}, {
|
|
158
|
-
mcu: {
|
|
159
|
-
symbol: string;
|
|
160
|
-
} & {
|
|
161
|
-
[k: string]: unknown;
|
|
162
|
-
};
|
|
163
|
-
version: 1;
|
|
164
|
-
connectedPins: Record<string, {
|
|
165
|
-
pinName: string;
|
|
166
|
-
pinType: string;
|
|
167
|
-
net: string;
|
|
168
|
-
boardName?: string | undefined;
|
|
169
|
-
externalComponents?: z.objectInputType<{
|
|
170
|
-
reference: z.ZodString;
|
|
171
|
-
dnp: z.ZodBoolean;
|
|
172
|
-
}, z.ZodTypeAny, "passthrough">[] | undefined;
|
|
173
|
-
}>;
|
|
174
|
-
availablePeripherals: {
|
|
175
|
-
i2c: boolean;
|
|
176
|
-
spi: boolean;
|
|
177
|
-
uart: boolean;
|
|
178
|
-
};
|
|
179
|
-
}>;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
}, z.core.$strict>;
|
|
180
62
|
export type ContractComponent = z.infer<typeof ContractComponentSchema>;
|
|
181
63
|
export type ContractPin = z.infer<typeof ContractPinSchema>;
|
|
182
64
|
export type AvailablePeripherals = z.infer<typeof AvailablePeripheralsSchema>;
|
|
@@ -214,4 +96,31 @@ export declare function matchConnectedPins(contract: HwContract, mcuPinNames: re
|
|
|
214
96
|
* becomes a compile error on a board whose PCB doesn't route SPI.
|
|
215
97
|
*/
|
|
216
98
|
export declare function selectPeripherals(contract: HwContract, mcuPeripheralNames: readonly string[]): string[];
|
|
99
|
+
/**
|
|
100
|
+
* The canonical MCU pad names the contract declares wired — boardName when
|
|
101
|
+
* typecad.net carried a mapping, else the KiCAD pin-name segment that looks
|
|
102
|
+
* like a datasheet pad (PA5, PB6, P0.28, GPIO9). De-duplicated, order
|
|
103
|
+
* preserved. This replaces the old soc-manifest pinNames source: under
|
|
104
|
+
* SDK-as-truth the contract itself declares the wired pads.
|
|
105
|
+
*/
|
|
106
|
+
export declare function contractPinNames(contract: HwContract): string[];
|
|
107
|
+
/** One wired pad: the MCU datasheet name plus an optional functional alias. */
|
|
108
|
+
export interface ContractPad {
|
|
109
|
+
/** Datasheet-form pad name (PA9, P0.28, GP25) — what boardgen can place. */
|
|
110
|
+
mcuName: string;
|
|
111
|
+
/** Functional name from the schematic (TX, RX, LED) when boardName is not
|
|
112
|
+
* itself a pad name. Exported as an alias pointing at the pad. */
|
|
113
|
+
alias?: string;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The wired pads of the contract, as MCU datasheet names plus optional
|
|
117
|
+
* functional aliases. For each non-power pin: boardName is preferred when
|
|
118
|
+
* it is itself pad-form (PA9); otherwise the KiCAD pin-name segments are
|
|
119
|
+
* searched for a pad-form name ("XTAL1/PB6" → PB6). When boardName is set
|
|
120
|
+
* but NOT pad-form (TX, LED), it rides along as the pad's alias.
|
|
121
|
+
*
|
|
122
|
+
* This replaces the old soc-manifest pinNames source: under SDK-as-truth
|
|
123
|
+
* the contract declares the wired pads itself.
|
|
124
|
+
*/
|
|
125
|
+
export declare function contractPads(contract: HwContract): ContractPad[];
|
|
217
126
|
export {};
|
|
@@ -222,3 +222,79 @@ export function selectPeripherals(contract, mcuPeripheralNames) {
|
|
|
222
222
|
return true;
|
|
223
223
|
});
|
|
224
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* The canonical MCU pad names the contract declares wired — boardName when
|
|
227
|
+
* typecad.net carried a mapping, else the KiCAD pin-name segment that looks
|
|
228
|
+
* like a datasheet pad (PA5, PB6, P0.28, GPIO9). De-duplicated, order
|
|
229
|
+
* preserved. This replaces the old soc-manifest pinNames source: under
|
|
230
|
+
* SDK-as-truth the contract itself declares the wired pads.
|
|
231
|
+
*/
|
|
232
|
+
export function contractPinNames(contract) {
|
|
233
|
+
const out = [];
|
|
234
|
+
const seen = new Set();
|
|
235
|
+
for (const pin of Object.values(contract.connectedPins)) {
|
|
236
|
+
if (isPowerPin(pin))
|
|
237
|
+
continue;
|
|
238
|
+
if (pin.boardName && !seen.has(pin.boardName)) {
|
|
239
|
+
seen.add(pin.boardName);
|
|
240
|
+
out.push(pin.boardName);
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const segments = pin.pinName.replace(/[~{}]/g, '').split(/[/-]/);
|
|
244
|
+
const padLike = segments.find((seg) => /^(?:P[A-Za-z]\d|P\d\.\d{1,2}|GPIO\d{1,2}|GP\d{1,2})$/i.test(seg));
|
|
245
|
+
if (padLike && !seen.has(padLike.toUpperCase())) {
|
|
246
|
+
seen.add(padLike.toUpperCase());
|
|
247
|
+
out.push(padLike.toUpperCase());
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return out;
|
|
251
|
+
}
|
|
252
|
+
/** A pad-form name in any supported family notation. */
|
|
253
|
+
function isPadName(name) {
|
|
254
|
+
return /^(?:P[A-Pa-p]\d{1,2}|P\d\.\d{1,2}|GPIO\d{1,2}|GP\d{1,2})$/.test(name.trim());
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* The wired pads of the contract, as MCU datasheet names plus optional
|
|
258
|
+
* functional aliases. For each non-power pin: boardName is preferred when
|
|
259
|
+
* it is itself pad-form (PA9); otherwise the KiCAD pin-name segments are
|
|
260
|
+
* searched for a pad-form name ("XTAL1/PB6" → PB6). When boardName is set
|
|
261
|
+
* but NOT pad-form (TX, LED), it rides along as the pad's alias.
|
|
262
|
+
*
|
|
263
|
+
* This replaces the old soc-manifest pinNames source: under SDK-as-truth
|
|
264
|
+
* the contract declares the wired pads itself.
|
|
265
|
+
*/
|
|
266
|
+
export function contractPads(contract) {
|
|
267
|
+
const out = [];
|
|
268
|
+
const seen = new Set();
|
|
269
|
+
for (const pin of Object.values(contract.connectedPins)) {
|
|
270
|
+
if (isPowerPin(pin))
|
|
271
|
+
continue;
|
|
272
|
+
let pad;
|
|
273
|
+
let alias;
|
|
274
|
+
if (pin.boardName && isPadName(pin.boardName)) {
|
|
275
|
+
pad = pin.boardName.toUpperCase().replace(/^P([AP]) (\d{1,2})$/, 'P$1.$2');
|
|
276
|
+
}
|
|
277
|
+
if (!pad) {
|
|
278
|
+
const segments = pin.pinName.replace(/[~{}]/g, '').split(/[/-]/);
|
|
279
|
+
pad = segments.find((seg) => isPadName(seg));
|
|
280
|
+
}
|
|
281
|
+
if (!pad)
|
|
282
|
+
continue;
|
|
283
|
+
pad = pad.toUpperCase();
|
|
284
|
+
if (pin.boardName && pin.boardName !== pad)
|
|
285
|
+
alias = pin.boardName;
|
|
286
|
+
if (seen.has(pad)) {
|
|
287
|
+
// Same pad, new functional alias — keep the alias on the existing pad
|
|
288
|
+
// (a pad can be exported under two names).
|
|
289
|
+
if (alias) {
|
|
290
|
+
const existing = out.find((p) => p.mcuName === pad);
|
|
291
|
+
if (existing && !existing.alias)
|
|
292
|
+
existing.alias = alias;
|
|
293
|
+
}
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
seen.add(pad);
|
|
297
|
+
out.push({ mcuName: pad, ...(alias ? { alias } : {}) });
|
|
298
|
+
}
|
|
299
|
+
return out;
|
|
300
|
+
}
|