@typecad/framework-zephyr 1.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +100 -0
- package/dist/async/timer-polyfill.d.ts +10 -0
- package/dist/async/timer-polyfill.js +95 -0
- package/dist/chips/controllers.d.ts +21 -0
- package/dist/chips/controllers.js +66 -0
- package/dist/chips/esp32.d.ts +2 -0
- package/dist/chips/esp32.js +59 -0
- package/dist/chips/esp32s3.d.ts +2 -0
- package/dist/chips/esp32s3.js +54 -0
- package/dist/chips/index.d.ts +15 -0
- package/dist/chips/index.js +45 -0
- package/dist/chips/resolve.d.ts +9 -0
- package/dist/chips/resolve.js +121 -0
- package/dist/chips/types.d.ts +154 -0
- package/dist/chips/types.js +14 -0
- package/dist/chips/xiao-ble.d.ts +2 -0
- package/dist/chips/xiao-ble.js +61 -0
- package/dist/debug-codegen.d.ts +33 -0
- package/dist/debug-codegen.js +162 -0
- package/dist/display/gfx.d.ts +17 -0
- package/dist/display/gfx.js +171 -0
- package/dist/display/index.d.ts +20 -0
- package/dist/display/index.js +53 -0
- package/dist/display/profiles.d.ts +25 -0
- package/dist/display/profiles.js +41 -0
- package/dist/display/touch-adapter.d.ts +9 -0
- package/dist/display/touch-adapter.js +95 -0
- package/dist/display/ui-adapter.d.ts +21 -0
- package/dist/display/ui-adapter.js +534 -0
- package/dist/dt-config/kconfig.d.ts +27 -0
- package/dist/dt-config/kconfig.js +283 -0
- package/dist/dt-config/overlay.d.ts +35 -0
- package/dist/dt-config/overlay.js +246 -0
- package/dist/framework.manifest.d.ts +98 -0
- package/dist/framework.manifest.js +525 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +12 -0
- package/dist/lowering/adc.d.ts +19 -0
- package/dist/lowering/adc.js +76 -0
- package/dist/lowering/ble.d.ts +20 -0
- package/dist/lowering/ble.js +419 -0
- package/dist/lowering/board.d.ts +9 -0
- package/dist/lowering/board.js +33 -0
- package/dist/lowering/gpio.d.ts +12 -0
- package/dist/lowering/gpio.js +123 -0
- package/dist/lowering/http.d.ts +23 -0
- package/dist/lowering/http.js +482 -0
- package/dist/lowering/i2c.d.ts +15 -0
- package/dist/lowering/i2c.js +114 -0
- package/dist/lowering/index.d.ts +29 -0
- package/dist/lowering/index.js +93 -0
- package/dist/lowering/interrupts.d.ts +21 -0
- package/dist/lowering/interrupts.js +91 -0
- package/dist/lowering/mqtt.d.ts +19 -0
- package/dist/lowering/mqtt.js +366 -0
- package/dist/lowering/power.d.ts +9 -0
- package/dist/lowering/power.js +64 -0
- package/dist/lowering/preferences.d.ts +23 -0
- package/dist/lowering/preferences.js +345 -0
- package/dist/lowering/pulse.d.ts +7 -0
- package/dist/lowering/pulse.js +82 -0
- package/dist/lowering/pwm.d.ts +15 -0
- package/dist/lowering/pwm.js +59 -0
- package/dist/lowering/random.d.ts +18 -0
- package/dist/lowering/random.js +129 -0
- package/dist/lowering/spi.d.ts +17 -0
- package/dist/lowering/spi.js +113 -0
- package/dist/lowering/timing.d.ts +9 -0
- package/dist/lowering/timing.js +63 -0
- package/dist/lowering/tone.d.ts +10 -0
- package/dist/lowering/tone.js +50 -0
- package/dist/lowering/uart.d.ts +15 -0
- package/dist/lowering/uart.js +102 -0
- package/dist/lowering/util.d.ts +4 -0
- package/dist/lowering/util.js +12 -0
- package/dist/lowering/wdt.d.ts +15 -0
- package/dist/lowering/wdt.js +80 -0
- package/dist/lowering/wifi.d.ts +21 -0
- package/dist/lowering/wifi.js +447 -0
- package/dist/lowering/worker-backing.d.ts +14 -0
- package/dist/lowering/worker-backing.js +79 -0
- package/dist/lowering/worker.d.ts +6 -0
- package/dist/lowering/worker.js +14 -0
- package/dist/strategy.d.ts +168 -0
- package/dist/strategy.js +1094 -0
- package/dist/toolchain/debug-config.d.ts +82 -0
- package/dist/toolchain/debug-config.js +359 -0
- package/dist/toolchain/index.d.ts +73 -0
- package/dist/toolchain/index.js +427 -0
- package/dist/toolchain/scaffold.d.ts +15 -0
- package/dist/toolchain/scaffold.js +196 -0
- package/dist/toolchain/west-discover.d.ts +40 -0
- package/dist/toolchain/west-discover.js +203 -0
- package/dist/toolchain/west-spawn.d.ts +39 -0
- package/dist/toolchain/west-spawn.js +117 -0
- package/package.json +82 -0
- package/src/async/timer-polyfill.ts +107 -0
- package/src/chips/controllers.ts +74 -0
- package/src/chips/esp32.ts +62 -0
- package/src/chips/esp32s3.ts +57 -0
- package/src/chips/index.ts +54 -0
- package/src/chips/resolve.ts +146 -0
- package/src/chips/types.ts +163 -0
- package/src/chips/xiao-ble.ts +64 -0
- package/src/debug-codegen.ts +207 -0
- package/src/display/gfx.ts +190 -0
- package/src/display/index.ts +70 -0
- package/src/display/profiles.ts +63 -0
- package/src/display/touch-adapter.ts +100 -0
- package/src/display/ui-adapter.ts +558 -0
- package/src/dt-config/kconfig.ts +308 -0
- package/src/dt-config/overlay.ts +293 -0
- package/src/framework.manifest.ts +545 -0
- package/src/index.ts +23 -0
- package/src/lowering/adc.ts +102 -0
- package/src/lowering/ble.ts +426 -0
- package/src/lowering/board.ts +38 -0
- package/src/lowering/gpio.ts +148 -0
- package/src/lowering/http.ts +488 -0
- package/src/lowering/i2c.ts +126 -0
- package/src/lowering/index.ts +86 -0
- package/src/lowering/interrupts.ts +114 -0
- package/src/lowering/mqtt.ts +371 -0
- package/src/lowering/power.ts +70 -0
- package/src/lowering/preferences.ts +354 -0
- package/src/lowering/pulse.ts +93 -0
- package/src/lowering/pwm.ts +74 -0
- package/src/lowering/random.ts +135 -0
- package/src/lowering/spi.ts +124 -0
- package/src/lowering/timing.ts +72 -0
- package/src/lowering/tone.ts +60 -0
- package/src/lowering/uart.ts +111 -0
- package/src/lowering/util.ts +12 -0
- package/src/lowering/wdt.ts +84 -0
- package/src/lowering/wifi.ts +452 -0
- package/src/lowering/worker-backing.ts +94 -0
- package/src/lowering/worker.ts +17 -0
- package/src/strategy.ts +1265 -0
- package/src/toolchain/debug-config.ts +399 -0
- package/src/toolchain/index.ts +459 -0
- package/src/toolchain/scaffold.ts +196 -0
- package/src/toolchain/west-discover.ts +233 -0
- package/src/toolchain/west-spawn.ts +141 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import type { PlatformStrategy, ProgramIR, Diagnostic, PlatformContext, BoardConstants, RuntimePolyfillIR, StdLibSupport, AsyncRuntimeConfig, GraphicsCapacity, HALOpIR, DisplayHALOp, ResolvedDisplay, DisplayAdapterCode, DisplayProfile, TouchProfile, TouchAdapterCodegen } from '@typecad/cuttlefish/api/shared';
|
|
2
|
+
export declare class ZephyrStrategy implements PlatformStrategy {
|
|
3
|
+
readonly id = "zephyr";
|
|
4
|
+
/**
|
|
5
|
+
* Resolve + cache the active chip from the platform context. Called lazily
|
|
6
|
+
* by the methods that need the descriptor (shimLines, resolveHALOperation
|
|
7
|
+
* via lowerHalOp).
|
|
8
|
+
*
|
|
9
|
+
* Tries to derive the chip descriptor from the board/MCU package's zephyr
|
|
10
|
+
* fields (via boardConstants) first. Falls back to the hardcoded
|
|
11
|
+
* chipForTarget registry for boards that haven't shipped zephyr config yet.
|
|
12
|
+
*/
|
|
13
|
+
private resolveChip;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the debug mode for the active target from the platform context.
|
|
16
|
+
* Mirrors resolveChip's target extraction so shimLines/forcedIncludes can
|
|
17
|
+
* gate the printf halt shim + console UART include to printf builds only
|
|
18
|
+
* (gdb builds use VS Code native breakpoints + #line markers, so the
|
|
19
|
+
* __tc_debug_wait_for_continue shim and its <zephyr/drivers/uart.h> include
|
|
20
|
+
* are dead code there).
|
|
21
|
+
*/
|
|
22
|
+
private resolveDebugMode;
|
|
23
|
+
forcedIncludes(_program?: ProgramIR, ctx?: PlatformContext): string[];
|
|
24
|
+
symbolAliases(): Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* Detect async-runtime usage: a program needs the Promise/microtask runtime
|
|
27
|
+
* if it declares an async function OR references an async-runtime symbol
|
|
28
|
+
* (`__cuttlefish_async_`) — e.g. Async.sleep()/.then() called from a non-async
|
|
29
|
+
* function. Mirrors Arduino's programUsesAsyncRuntime walk (that helper is
|
|
30
|
+
* private to framework-arduino and not exported from cuttlefish, so we walk
|
|
31
|
+
* here). The token appears in `raw` expr nodes and in `hal-expr`/`hal-op`
|
|
32
|
+
* nodes whose resolved `raw` code references it.
|
|
33
|
+
*/
|
|
34
|
+
private programUsesAsyncRuntime;
|
|
35
|
+
shimLines(program?: ProgramIR, ctx?: PlatformContext): string[];
|
|
36
|
+
profileDiagnostics(program?: ProgramIR, ctx?: PlatformContext): Diagnostic[];
|
|
37
|
+
/**
|
|
38
|
+
* `loop` is forward-declared `extern` by the main() bridge shim
|
|
39
|
+
* (extern void loop(void); → int main(void) {...}), so emitting a
|
|
40
|
+
* `static void loop()` definition redeclares it with conflicting linkage,
|
|
41
|
+
* which GCC rejects. Exclude it from the static forward-declaration path
|
|
42
|
+
* — mirrors how ArduinoStrategy excludes `loop` (the Arduino core forward-
|
|
43
|
+
* declares it extern). `setup` is already handled because it equals
|
|
44
|
+
* entrypointFunctionName().
|
|
45
|
+
*/
|
|
46
|
+
forwardDeclarationExclusions(): string[];
|
|
47
|
+
sourceExtension(): string;
|
|
48
|
+
entrypointFunctionName(): string;
|
|
49
|
+
requiresLoopFunction(): boolean;
|
|
50
|
+
overrideBaseName(originalBaseName: string, outDirBaseName: string, isEntryFile: boolean, isNpmPackage: boolean): string;
|
|
51
|
+
effectiveEmitMode(requestedMode: string, _isNpmPackage: boolean): string;
|
|
52
|
+
normalizeCppType(typeName: string): string;
|
|
53
|
+
defaultNumericType(compliance?: {
|
|
54
|
+
isBanned(ruleId: string): boolean;
|
|
55
|
+
}): string;
|
|
56
|
+
mapReturnType(functionName: string, returnType: string): string;
|
|
57
|
+
isStringLikeType(cppType: string): boolean;
|
|
58
|
+
isPointerType(cppType: string): boolean;
|
|
59
|
+
mapFunctionName(originalName: string): string;
|
|
60
|
+
normalizeRawExpression(value: string): string;
|
|
61
|
+
nullValue(): string;
|
|
62
|
+
wrapStringConcat(): string | undefined;
|
|
63
|
+
wrapStringObject(value: string): string;
|
|
64
|
+
useSnprintfForStrings(): boolean;
|
|
65
|
+
renameEnumMember(_enumName: string, memberName: string): string;
|
|
66
|
+
private _largeEnumNames;
|
|
67
|
+
setLargeEnumNames(names: ReadonlySet<string>): void;
|
|
68
|
+
enumCastType(_enumName: string): string | undefined;
|
|
69
|
+
renderBoardDefinitionAccess(chain: string[], boardConstants?: BoardConstants): string | undefined;
|
|
70
|
+
promotesArrayLiteralsToStaticArray(): boolean;
|
|
71
|
+
renderThrow(_valueExpr: string): string;
|
|
72
|
+
isConsoleCall(callee: string): boolean;
|
|
73
|
+
transformConsoleCall(method: string, renderedArgs: string, forHeader: boolean): string;
|
|
74
|
+
transformConsoleExpression(_method: string, _renderedArgs: string): string | undefined;
|
|
75
|
+
objectFieldInitializer(): string | undefined;
|
|
76
|
+
overrideClassFieldType(_fieldName: string, normalizedType: string): string;
|
|
77
|
+
reservedNames(): ReadonlySet<string>;
|
|
78
|
+
passthroughMacroNames(): ReadonlySet<string>;
|
|
79
|
+
apiReservedEnumNames(): ReadonlySet<string>;
|
|
80
|
+
apiReservedEnumGuard(): string;
|
|
81
|
+
ambientTypeDeclarations(): string[];
|
|
82
|
+
needsIostream(): boolean;
|
|
83
|
+
needsStdString(): boolean;
|
|
84
|
+
needsStdVector(): boolean;
|
|
85
|
+
needsStdExcept(): boolean;
|
|
86
|
+
needsStdFunction(): boolean;
|
|
87
|
+
mathHeader(): string;
|
|
88
|
+
cstringHeader(): string;
|
|
89
|
+
needsVectorOverload(): boolean;
|
|
90
|
+
needsLargeEnumUnderlying(): boolean;
|
|
91
|
+
renameStructField(fieldName: string): string;
|
|
92
|
+
structFieldInitializer(): string | undefined;
|
|
93
|
+
getAsyncRuntimeConfig(): AsyncRuntimeConfig;
|
|
94
|
+
asyncLoopInjection(taskVarNames: string[], config: AsyncRuntimeConfig): string[];
|
|
95
|
+
asyncLoopInjection(taskVarNames: string[], hasPromiseRuntime: boolean, hasTimers: boolean): string[];
|
|
96
|
+
asyncDriverFunctionName(): string;
|
|
97
|
+
shouldSkipTypeAlias(): boolean;
|
|
98
|
+
emitDiagnostics(): Diagnostic[];
|
|
99
|
+
currentTimeMillis(): string;
|
|
100
|
+
asyncQueueCapacity(): number;
|
|
101
|
+
outputSubdirectory(_baseName: string): string;
|
|
102
|
+
generateHeaderFile(): boolean;
|
|
103
|
+
enumApiGuard(_enumName: string): {
|
|
104
|
+
open: string;
|
|
105
|
+
close: string;
|
|
106
|
+
} | undefined;
|
|
107
|
+
getStdLibSupport(_architecture?: string): StdLibSupport;
|
|
108
|
+
nativePolyfills(): Set<string>;
|
|
109
|
+
generateNativePolyfills(program?: ProgramIR, ctx?: PlatformContext): RuntimePolyfillIR[];
|
|
110
|
+
resolveHALOperation(op: HALOpIR): {
|
|
111
|
+
code?: string;
|
|
112
|
+
expression?: string;
|
|
113
|
+
} | undefined;
|
|
114
|
+
modelsGpio(): boolean;
|
|
115
|
+
readDigitalPin(pin: string): string;
|
|
116
|
+
readAnalogPin(pin: string): string;
|
|
117
|
+
writeDigitalPin(pin: string, val: string): string;
|
|
118
|
+
setPinMode(_pin: string, _mode: string): string;
|
|
119
|
+
delayMs(ms: string): string;
|
|
120
|
+
delayMicroseconds(us: string): string;
|
|
121
|
+
halCallNames(): ReadonlySet<string>;
|
|
122
|
+
isHalCall(name: string): boolean;
|
|
123
|
+
analogReadCallNames(): ReadonlySet<string>;
|
|
124
|
+
isRtosTarget(): boolean;
|
|
125
|
+
private _workerBacking;
|
|
126
|
+
private _displayState;
|
|
127
|
+
workerSpawnLines(handleId: number, trampolineName: string, waiterExpr: string): string[] | undefined;
|
|
128
|
+
workerSignalDoneExpr(handleId: number): string | undefined;
|
|
129
|
+
workerIsDoneExpr(handleId: number): string | undefined;
|
|
130
|
+
resolveDisplayOp(op: DisplayHALOp): {
|
|
131
|
+
code?: string;
|
|
132
|
+
expression?: string;
|
|
133
|
+
} | undefined;
|
|
134
|
+
supportedDisplayDrivers(): ReadonlySet<string>;
|
|
135
|
+
providesDisplayAdapter(): boolean;
|
|
136
|
+
resolveDisplayAdapter(display: ResolvedDisplay): DisplayAdapterCode | undefined;
|
|
137
|
+
providesTouchAdapter(): boolean;
|
|
138
|
+
resolveTouchAdapter(touch: TouchProfile): TouchAdapterCodegen | undefined;
|
|
139
|
+
getProfileRegistry(): Map<string, DisplayProfile>;
|
|
140
|
+
colorFormat(): 'rgb565' | 'rgb666' | 'rgb888' | 'mono';
|
|
141
|
+
graphicsCapacity(): GraphicsCapacity;
|
|
142
|
+
debugMode(target?: string): 'gdb' | 'printf';
|
|
143
|
+
generateDebugInitCode(): string[];
|
|
144
|
+
generateDebugBreakpointCode(params: {
|
|
145
|
+
fileName: string;
|
|
146
|
+
lineNum: number;
|
|
147
|
+
originalLine: string;
|
|
148
|
+
variables: Array<{
|
|
149
|
+
name: string;
|
|
150
|
+
isFunction?: boolean;
|
|
151
|
+
cppType?: 'bool' | 'int' | 'long' | 'float' | 'string' | 'unknown';
|
|
152
|
+
}>;
|
|
153
|
+
normalizedCondition?: string;
|
|
154
|
+
breakpointId?: number;
|
|
155
|
+
}): string[];
|
|
156
|
+
generateDebugLogpointCode(params: {
|
|
157
|
+
fileName: string;
|
|
158
|
+
lineNum: number;
|
|
159
|
+
parts: Array<{
|
|
160
|
+
type: 'text' | 'variable';
|
|
161
|
+
value: string;
|
|
162
|
+
}>;
|
|
163
|
+
variables: Array<{
|
|
164
|
+
name: string;
|
|
165
|
+
isFunction?: boolean;
|
|
166
|
+
}>;
|
|
167
|
+
}): string[];
|
|
168
|
+
}
|