@typecad/framework-zephyr 1.0.0-alpha.15 → 1.0.0-alpha.18

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.
Files changed (132) hide show
  1. package/LICENSE +202 -21
  2. package/README.md +49 -87
  3. package/dist/as-built.d.ts +2 -2
  4. package/dist/as-built.js +2 -2
  5. package/dist/boardgen.d.ts +1 -9
  6. package/dist/boardgen.js +228 -45
  7. package/dist/chips/types.d.ts +1 -1
  8. package/dist/debug-codegen.js +1 -1
  9. package/dist/display/touch-adapter.js +1 -1
  10. package/dist/display/ui-adapter.js +549 -549
  11. package/dist/doctor.js +4 -4
  12. package/dist/dt-config/custom-board.js +2 -2
  13. package/dist/dt-config/kconfig.js +18 -12
  14. package/dist/dt-config/overlay.d.ts +2 -2
  15. package/dist/dt-config/overlay.js +2 -2
  16. package/dist/framework.manifest.d.ts +3 -3
  17. package/dist/framework.manifest.js +10 -7
  18. package/dist/index.js +5 -5
  19. package/dist/licenses.d.ts +2 -2
  20. package/dist/licenses.js +8 -8
  21. package/dist/lowering/fs.js +1 -1
  22. package/dist/lowering/gpio.js +0 -32
  23. package/dist/lowering/http.js +264 -32
  24. package/dist/lowering/i2c.js +0 -8
  25. package/dist/lowering/interrupts.js +6 -0
  26. package/dist/lowering/mqtt.js +110 -8
  27. package/dist/lowering/usb.js +11 -11
  28. package/dist/lowering/wdt.js +2 -29
  29. package/dist/sdk/board-catalog-sync.d.ts +1 -3
  30. package/dist/sdk/board-catalog-sync.js +4 -10
  31. package/dist/strategy.d.ts +22 -44
  32. package/dist/strategy.js +152 -155
  33. package/dist/tmp-probe.d.ts +2 -0
  34. package/dist/tmp-probe.js +9 -0
  35. package/dist/toolchain/debug-config.d.ts +50 -90
  36. package/dist/toolchain/debug-config.js +241 -502
  37. package/dist/toolchain/env-check.d.ts +1 -3
  38. package/dist/toolchain/env-check.js +2 -7
  39. package/dist/toolchain/index.d.ts +65 -2
  40. package/dist/toolchain/index.js +432 -55
  41. package/dist/toolchain/runners.d.ts +16 -0
  42. package/dist/toolchain/runners.js +75 -0
  43. package/dist/toolchain/scaffold.d.ts +1 -1
  44. package/dist/toolchain/scaffold.js +12 -12
  45. package/dist/toolchain/west-discover.d.ts +6 -0
  46. package/dist/toolchain/west-discover.js +36 -13
  47. package/dist/toolchain/west-spawn.js +8 -2
  48. package/installer/README.md +328 -328
  49. package/installer/install.sh +2 -2
  50. package/installer/templates/project/.typecad/activate-zephyr.ps1 +1 -1
  51. package/installer/templates/project/.typecad/activate-zephyr.sh +1 -1
  52. package/installer/templates/project/.vscode/settings.json +1 -1
  53. package/installer/templates/project/README.md +2 -2
  54. package/package.json +5 -5
  55. package/src/as-built.ts +206 -206
  56. package/src/boardgen.ts +214 -48
  57. package/src/chips/types.ts +567 -567
  58. package/src/display/touch-adapter.ts +204 -204
  59. package/src/display/ui-adapter.ts +781 -781
  60. package/src/doctor.ts +4 -4
  61. package/src/dt-config/custom-board.ts +2 -2
  62. package/src/dt-config/kconfig.ts +18 -12
  63. package/src/dt-config/overlay.ts +1058 -1058
  64. package/src/framework.manifest.ts +538 -535
  65. package/src/index.ts +5 -5
  66. package/src/licenses.ts +425 -425
  67. package/src/lowering/fs.ts +135 -135
  68. package/src/lowering/gpio.ts +0 -33
  69. package/src/lowering/http.ts +264 -32
  70. package/src/lowering/i2c.ts +0 -9
  71. package/src/lowering/interrupts.ts +6 -0
  72. package/src/lowering/mqtt.ts +109 -8
  73. package/src/lowering/usb.ts +221 -221
  74. package/src/lowering/wdt.ts +2 -25
  75. package/src/sdk/board-catalog-sync.ts +4 -25
  76. package/src/strategy.ts +2265 -2309
  77. package/src/toolchain/debug-config.ts +264 -514
  78. package/src/toolchain/env-check.ts +279 -285
  79. package/src/toolchain/index.ts +1703 -1286
  80. package/src/toolchain/runners.ts +80 -0
  81. package/src/toolchain/scaffold.ts +296 -296
  82. package/src/toolchain/west-discover.ts +35 -13
  83. package/src/toolchain/west-spawn.ts +174 -168
  84. package/dist/async/timer-polyfill.d.ts +0 -10
  85. package/dist/async/timer-polyfill.js +0 -95
  86. package/dist/chips/board-overrides.d.ts +0 -7
  87. package/dist/chips/board-overrides.js +0 -11
  88. package/dist/chips/esp32.d.ts +0 -2
  89. package/dist/chips/esp32.js +0 -71
  90. package/dist/chips/esp32s3.d.ts +0 -2
  91. package/dist/chips/esp32s3.js +0 -103
  92. package/dist/chips/soc/.d.ts +0 -2
  93. package/dist/chips/soc/.js +0 -129
  94. package/dist/chips/soc/esp32.d.ts +0 -2
  95. package/dist/chips/soc/esp32.js +0 -120
  96. package/dist/chips/soc/esp32c3.d.ts +0 -2
  97. package/dist/chips/soc/esp32c3.js +0 -90
  98. package/dist/chips/soc/esp32c6.d.ts +0 -2
  99. package/dist/chips/soc/esp32c6.js +0 -109
  100. package/dist/chips/soc/esp32s3.d.ts +0 -2
  101. package/dist/chips/soc/esp32s3.js +0 -189
  102. package/dist/chips/soc/index.d.ts +0 -2
  103. package/dist/chips/soc/index.js +0 -23
  104. package/dist/chips/soc/nrf52840.d.ts +0 -2
  105. package/dist/chips/soc/nrf52840.js +0 -130
  106. package/dist/chips/soc/rp2040.d.ts +0 -2
  107. package/dist/chips/soc/rp2040.js +0 -141
  108. package/dist/chips/soc/rp2350a.d.ts +0 -2
  109. package/dist/chips/soc/rp2350a.js +0 -145
  110. package/dist/chips/soc/samd21g18a.d.ts +0 -2
  111. package/dist/chips/soc/samd21g18a.js +0 -143
  112. package/dist/chips/soc/stm32f411xe.d.ts +0 -2
  113. package/dist/chips/soc/stm32f411xe.js +0 -251
  114. package/dist/chips/xiao-ble.d.ts +0 -2
  115. package/dist/chips/xiao-ble.js +0 -100
  116. package/dist/lowering/power.d.ts +0 -9
  117. package/dist/lowering/power.js +0 -60
  118. package/dist/lowering/pulse.d.ts +0 -7
  119. package/dist/lowering/pulse.js +0 -51
  120. package/dist/lowering/tone.d.ts +0 -10
  121. package/dist/lowering/tone.js +0 -63
  122. package/dist/lowering/worker-backing.d.ts +0 -14
  123. package/dist/lowering/worker-backing.js +0 -79
  124. package/dist/lowering/worker.d.ts +0 -6
  125. package/dist/lowering/worker.js +0 -14
  126. package/dist/sdk/board-data.generated.d.ts +0 -2
  127. package/dist/sdk/board-data.generated.js +0 -4
  128. package/dist/sdk/catalog-walker.d.ts +0 -90
  129. package/dist/sdk/catalog-walker.js +0 -682
  130. package/dist/sdk/dts-reader.d.ts +0 -83
  131. package/dist/sdk/dts-reader.js +0 -596
  132. package/src/debug-codegen.ts +0 -207
@@ -1,143 +0,0 @@
1
- // Hand-maintained descriptor table — mechanically migrated from the
2
- // board-nano-33-iot + mcu-samd21 package data (the exact flatten+reconstruct the build
3
- // performed). Curated additions: tier/pinNaming/excludedPins. Regenerate
4
- // only alongside a descriptor-type change (edit this file; the original
5
- // migration script was never committed).
6
- export const SAMD21G18A_SOC = {
7
- "id": "arduino_nano_33_iot/samd21g18a",
8
- "soc": "samd21g18a",
9
- "gpioController": "porta",
10
- "gpioControllers": [
11
- {
12
- "nodelabel": "porta",
13
- "minPin": 0,
14
- "maxPin": 31
15
- },
16
- {
17
- "nodelabel": "portb",
18
- "minPin": 32,
19
- "maxPin": 55
20
- }
21
- ],
22
- "gpio": {
23
- "dtSpecs": [
24
- {
25
- "pin": 17,
26
- "dtSpec": "led0"
27
- }
28
- ]
29
- },
30
- "i2c": {
31
- "controllers": [
32
- {
33
- "nodeLabel": "sercom4"
34
- }
35
- ]
36
- },
37
- "spi": {
38
- "controllers": [
39
- {
40
- "nodeLabel": "sercom1"
41
- }
42
- ]
43
- },
44
- "uart": {
45
- "controllers": [
46
- {
47
- "nodeLabel": "sercom5"
48
- }
49
- ]
50
- },
51
- "pwm": {
52
- "specs": [
53
- {
54
- "pin": 17,
55
- "dtSpec": "pwm-led0"
56
- }
57
- ],
58
- "maxFrequencyHz": 46875,
59
- "resolutionBits": 16
60
- },
61
- "adc": {
62
- "nodeLabel": "adc",
63
- "resolution": 12,
64
- "vrefMv": 1650,
65
- "channels": [
66
- {
67
- "pin": 2,
68
- "channel": 0
69
- },
70
- {
71
- "pin": 40,
72
- "channel": 2
73
- },
74
- {
75
- "pin": 41,
76
- "channel": 3
77
- },
78
- {
79
- "pin": 34,
80
- "channel": 10
81
- },
82
- {
83
- "pin": 9,
84
- "channel": 17
85
- },
86
- {
87
- "pin": 10,
88
- "channel": 18
89
- },
90
- {
91
- "pin": 11,
92
- "channel": 19
93
- }
94
- ],
95
- "gain": "ADC_GAIN_1",
96
- "reference": "ADC_REF_VDD_1_2"
97
- },
98
- "usb": {
99
- "controller": "zephyr_udc0",
100
- "cdcInstances": 1,
101
- "vid": "0x2FE3",
102
- "pid": "0x0003",
103
- "touchReset": {
104
- "flagAddress": 536903676,
105
- "magic": 125010229,
106
- "bootloaderVid": "0x2341",
107
- "bootloaderPid": "0x0057"
108
- }
109
- },
110
- "consoleDescription": "sercom5 on PB22 (TX, D1) / PB23 (RX, D0) at 115200",
111
- "probeMethods": [
112
- {
113
- "id": "bossac",
114
- "runner": "bossac",
115
- "description": "Built-in USB bootloader: double-tap reset, flash over the USB port (no debug)",
116
- "debug": false
117
- },
118
- {
119
- "id": "openocd",
120
- "runner": "openocd",
121
- "description": "Any CMSIS-DAP-class SWD probe on the underside SWD pads — also debugs",
122
- "debug": true,
123
- "debugInterface": "swd",
124
- "debugCfg": [
125
- "reset_config none"
126
- ],
127
- "debugCfgSource": [
128
- "interface/cmsis-dap.cfg",
129
- "target/at91samd.cfg"
130
- ]
131
- },
132
- {
133
- "id": "jlink",
134
- "runner": "jlink",
135
- "description": "J-Link probe (SWD) on the underside SWD pads — also debugs",
136
- "debug": true,
137
- "debugInterface": "swd",
138
- "debugDevice": "ATSAMD21G18"
139
- }
140
- ],
141
- "tier": "validated",
142
- "pinNaming": "samd-port"
143
- };
@@ -1,2 +0,0 @@
1
- import type { ZephyrChipDescriptor } from '../types.js';
2
- export declare const STM32F411XE_SOC: ZephyrChipDescriptor;
@@ -1,251 +0,0 @@
1
- // Hand-maintained descriptor table — mechanically migrated from the
2
- // board-blackpill-f411ce + mcu-stm32f411 package data (the exact flatten+reconstruct the build
3
- // performed). Curated additions: tier/pinNaming/excludedPins. Regenerate
4
- // only alongside a descriptor-type change (edit this file; the original
5
- // migration script was never committed).
6
- export const STM32F411XE_SOC = {
7
- "id": "blackpill_f411ce/stm32f411xe",
8
- "soc": "stm32f411xe",
9
- "gpioController": "gpioa",
10
- "gpioControllers": [
11
- {
12
- "nodelabel": "gpioa",
13
- "minPin": 0,
14
- "maxPin": 15
15
- },
16
- {
17
- "nodelabel": "gpiob",
18
- "minPin": 16,
19
- "maxPin": 31
20
- },
21
- {
22
- "nodelabel": "gpioc",
23
- "minPin": 32,
24
- "maxPin": 47
25
- }
26
- ],
27
- "gpio": {
28
- "dtSpecs": [
29
- {
30
- "pin": 45,
31
- "dtSpec": "led0"
32
- },
33
- {
34
- "pin": 0,
35
- "dtSpec": "sw0"
36
- }
37
- ],
38
- "interruptPins": [
39
- {
40
- "pin": 0,
41
- "dtSpec": "sw0"
42
- }
43
- ]
44
- },
45
- "i2c": {
46
- "controllers": [
47
- {
48
- "nodeLabel": "i2c1"
49
- }
50
- ]
51
- },
52
- "spi": {
53
- "controllers": [
54
- {
55
- "nodeLabel": "spi1"
56
- }
57
- ]
58
- },
59
- "uart": {
60
- "controllers": [
61
- {
62
- "nodeLabel": "usart1"
63
- }
64
- ]
65
- },
66
- "pwm": {
67
- "specs": [
68
- {
69
- "pin": 22,
70
- "controller": "pwm4",
71
- "channel": 1,
72
- "periodNs": 20000000,
73
- "pinctrl": "tim4_ch1_pb6"
74
- },
75
- {
76
- "pin": 23,
77
- "controller": "pwm4",
78
- "channel": 2,
79
- "periodNs": 20000000,
80
- "pinctrl": "tim4_ch2_pb7"
81
- }
82
- ],
83
- "clockHz": 96000000,
84
- "maxFrequencyHz": 50000000,
85
- "resolutionBits": 16
86
- },
87
- "adc": {
88
- "nodeLabel": "adc1",
89
- "resolution": 12,
90
- "vrefMv": 3300,
91
- "channels": [
92
- {
93
- "pin": 0,
94
- "channel": 0,
95
- "pinctrl": "adc1_in0_pa0"
96
- },
97
- {
98
- "pin": 1,
99
- "channel": 1,
100
- "pinctrl": "adc1_in1_pa1"
101
- },
102
- {
103
- "pin": 2,
104
- "channel": 2,
105
- "pinctrl": "adc1_in2_pa2"
106
- },
107
- {
108
- "pin": 3,
109
- "channel": 3,
110
- "pinctrl": "adc1_in3_pa3"
111
- },
112
- {
113
- "pin": 4,
114
- "channel": 4,
115
- "pinctrl": "adc1_in4_pa4"
116
- },
117
- {
118
- "pin": 5,
119
- "channel": 5,
120
- "pinctrl": "adc1_in5_pa5"
121
- },
122
- {
123
- "pin": 6,
124
- "channel": 6,
125
- "pinctrl": "adc1_in6_pa6"
126
- },
127
- {
128
- "pin": 7,
129
- "channel": 7,
130
- "pinctrl": "adc1_in7_pa7"
131
- },
132
- {
133
- "pin": 16,
134
- "channel": 8,
135
- "pinctrl": "adc1_in8_pb0"
136
- },
137
- {
138
- "pin": 17,
139
- "channel": 9,
140
- "pinctrl": "adc1_in9_pb1"
141
- }
142
- ],
143
- "gain": "ADC_GAIN_1",
144
- "reference": "ADC_REF_INTERNAL"
145
- },
146
- "wdt": {
147
- "nodeLabel": "iwdg"
148
- },
149
- "storage": {
150
- "offset": 262144,
151
- "size": 262144
152
- },
153
- "usb": {
154
- "controller": "zephyr_udc0",
155
- "cdcInstances": 1,
156
- "vid": "0x2FE3",
157
- "pid": "0x0002"
158
- },
159
- "consoleDescription": "usart1 on PA9 (TX) / PA10 (RX)",
160
- "probeMethods": [
161
- {
162
- "id": "stlink",
163
- "runner": "openocd",
164
- "args": [
165
- "--cmd-pre-init=reset_config none"
166
- ],
167
- "description": "ST-Link or any SWD probe openocd supports (no BOOT0 needed)",
168
- "debug": true,
169
- "debugInterface": "swd",
170
- "debugCfg": [
171
- "reset_config none"
172
- ],
173
- "debugCfgSource": [
174
- "interface/stlink.cfg",
175
- "target/stm32f4x.cfg"
176
- ]
177
- },
178
- {
179
- "id": "stlink-srst",
180
- "runner": "openocd",
181
- "args": [
182
- "--cmd-pre-init=reset_config srst_only srst_nogate connect_assert_srst"
183
- ],
184
- "description": "ST-Link with the RST/SRST line wired — connect under reset (recovers wedged targets)",
185
- "debug": true,
186
- "debugInterface": "swd",
187
- "debugCfg": [
188
- "reset_config srst_only srst_nogate connect_assert_srst"
189
- ],
190
- "debugCfgSource": [
191
- "interface/stlink.cfg",
192
- "target/stm32f4x.cfg"
193
- ]
194
- },
195
- {
196
- "id": "dfu",
197
- "runner": "dfu-util",
198
- "description": "Built-in USB bootloader: hold BOOT0, tap reset",
199
- "debug": false
200
- },
201
- {
202
- "id": "jlink",
203
- "runner": "jlink",
204
- "description": "J-Link probe (SWD)",
205
- "debug": true,
206
- "debugInterface": "swd",
207
- "debugDevice": "STM32F411CE"
208
- }
209
- ],
210
- "customBoard": {
211
- "socs": [
212
- "stm32f411xe"
213
- ],
214
- "dtsIncludes": [
215
- "st/f4/stm32f411Xe.dtsi",
216
- "st/f4/stm32f411c(c-e)ux-pinctrl.dtsi"
217
- ],
218
- "console": {
219
- "nodeLabel": "usart1",
220
- "tx": "usart1_tx_pa9",
221
- "rx": "usart1_rx_pa10",
222
- "speed": 115200
223
- },
224
- "clocks": {
225
- "hseMHz": 25,
226
- "pll": {
227
- "divM": 25,
228
- "mulN": 192,
229
- "divP": 2,
230
- "divQ": 4
231
- },
232
- "sysMHz": 96,
233
- "ahbPrescaler": 1,
234
- "apb1Prescaler": 2,
235
- "apb2Prescaler": 1
236
- },
237
- "usbNode": "usbotg_fs",
238
- "usbPinctrl": [
239
- "usb_otg_fs_dm_pa11",
240
- "usb_otg_fs_dp_pa12"
241
- ],
242
- "adcNode": {
243
- "nodeLabel": "adc1",
244
- "clockSource": "SYNC",
245
- "prescaler": 2,
246
- "pinctrl": "adc1_in1_pa1"
247
- }
248
- },
249
- "tier": "validated",
250
- "pinNaming": "stm32-port"
251
- };
@@ -1,2 +0,0 @@
1
- import type { ZephyrChipDescriptor } from './types.js';
2
- export declare const XIAO_BLE: ZephyrChipDescriptor;
@@ -1,100 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Seeed Studio XIAO nRF52840 — Zephyr board descriptor
3
- //
4
- // Board target: `xiao_ble` (mainline Zephyr, boards/seeed/xiao_ble).
5
- // The onboard user LED is active-low and exposed as the DT alias `led0`.
6
- // ---------------------------------------------------------------------------
7
- export const XIAO_BLE = {
8
- id: 'xiao_ble',
9
- soc: 'nrf52840',
10
- gpioController: 'gpio0',
11
- // GPIO is split across two devicetree controllers: gpio0 (P0.00–P0.31)
12
- // and gpio1 (P1.00–P1.15, HAL pins 32–47). Declaring the split makes the
13
- // raw path emit the port-relative index against gpio1 (P1.11 = raw 11),
14
- // which NRF_GPIO_PIN_MAP(1, 11) resolves to absolute pin 43 — the same
15
- // physical pin the old single-controller form reached only by accident:
16
- // gpio0 + global 43 also maps to 43 (MAP(0, 43) = 43), but that form
17
- // trips the generic layer's port_pin_mask __ASSERT ("Unsupported pin",
18
- // gpio0's mask covers 0–31) on any assert-enabled build.
19
- gpioControllers: [
20
- { nodelabel: 'gpio0', minPin: 0, maxPin: 31 },
21
- { nodelabel: 'gpio1', minPin: 32, maxPin: 47 },
22
- ],
23
- gpio: {
24
- dtSpecs: [
25
- // Onboard RGB LEDs — active-low (GPIO_ACTIVE_LOW in xiao_ble_common.dtsi).
26
- // Verified against the board's `aliases { led0 = &led0; led1 = &led1; led2 = &led2; }`.
27
- { pin: 26, dtSpec: 'led0' }, // Red (P0.26)
28
- { pin: 30, dtSpec: 'led1' }, // Green (P0.30)
29
- { pin: 6, dtSpec: 'led2' }, // Blue (P0.06)
30
- ],
31
- // The XIAO nRF52840 has a user button on P0.04, but mainline Zephyr's
32
- // xiao_ble board (verified against Zephyr 4.3.99) does NOT expose it as a
33
- // DT `sw0` alias — there is no gpio-keys node in xiao_ble.dts. Emitting
34
- // GPIO_DT_SPEC_GET(DT_ALIAS(sw0), gpios) therefore fails to compile
35
- // ('DT_N_ALIAS_sw0_... was not declared'). Until a button node + alias is
36
- // added (via an overlay or an upstream board update), interruptPins stays
37
- // empty: attachInterrupt on this board lowers to the no-DT-spec comment
38
- // fallback rather than a hard compile error.
39
- interruptPins: [],
40
- },
41
- // The XIAO connector wiring (from seeed_xiao_connector.dtsi + xiao_ble-pinctrl.dtsi):
42
- // xiao_i2c → i2c1 (SDA P0.04/D4, SCL P0.05/D5)
43
- // xiao_spi → spi2 (SCK P1.13/D8, MOSI P1.15/D10, MISO P1.14/D9)
44
- // xiao_serial → uart0 (TX P1.11/D6, RX P1.12/D7)
45
- // The board DTS leaves i2c0/spi0/spi1 disabled (shared instances).
46
- i2c: {
47
- controllers: [{ nodeLabel: 'i2c1' }],
48
- },
49
- spi: {
50
- controllers: [{ nodeLabel: 'spi2' }],
51
- },
52
- uart: {
53
- controllers: [{ nodeLabel: 'uart0' }],
54
- },
55
- // nRF52840 native USB device (USBD). The board DTS carries `zephyr_udc0`
56
- // (the nRF USBD driver node); the overlay enables it + composes one CDC-ACM
57
- // instance when a program uses USB0. (The console on this board is already
58
- // USB-CDC via the board's own chosen cdc_acm_uart0 — this field exposes the
59
- // same peripheral to usb.* HAL ops.)
60
- usb: {
61
- controller: 'zephyr_udc0',
62
- cdcInstances: 1,
63
- },
64
- pwm: {
65
- // pwm-led0 drives the board PWM LED (PWM_OUT0 on P0.17, inverted).
66
- specs: [{ pin: 17, dtSpec: 'pwm-led0' }],
67
- },
68
- adc: {
69
- // SAADC node is `adc`; no pre-declared channels. XIAO D0–D3 = AIN0–AIN3
70
- // (P0.02/P0.03/P0.28/P0.29). Internal VREF ~0.6V with VDD/4 gain ⇒ 3000mV.
71
- nodeLabel: 'adc',
72
- resolution: 12,
73
- vrefMv: 3000,
74
- channels: [
75
- { pin: 2, channel: 0 }, // P0.02 / D0 / AIN0
76
- { pin: 3, channel: 1 }, // P0.03 / D1 / AIN1
77
- { pin: 28, channel: 2 }, // P0.28 / D2 / AIN2
78
- { pin: 29, channel: 3 }, // P0.29 / D3 / AIN3
79
- ],
80
- },
81
- wdt: { nodeLabel: 'wdt0' },
82
- // Hardware timer: nRF RTC1 is the free counter (RTC0 is kernel-owned by the
83
- // softdevice/clock driver). The hwtimer lowering drives it as a Zephyr
84
- // counter device (counter_start/stop + a top-value alarm for set_frequency).
85
- // Verified against the nRF52840 SoC dtsi (rtc0/rtc1 nodes). The kernel uses
86
- // RTC0 for the system tick; RTC1 is available for application use.
87
- hwtimer: { controllers: [{ nodeLabel: 'rtc1' }] },
88
- // Mirror of board-xiao-nrf52840's probeMethods (registry fallback parity —
89
- // the board package's zephyr field wins when board constants are present).
90
- probeMethods: [
91
- { id: 'jlink', runner: 'jlink', description: 'J-Link probe (SWD)',
92
- debug: true, debugInterface: 'swd', debugDevice: 'nRF52840_xxAA' },
93
- { id: 'openocd', runner: 'openocd',
94
- description: 'Any SWD probe openocd supports (CMSIS-DAP, cheap clones)',
95
- debug: true, debugInterface: 'swd',
96
- debugCfgSource: ['interface/stlink.cfg', 'target/nrf52.cfg'] },
97
- { id: 'uf2', runner: 'uf2', description: 'Bootloader UF2 drag-and-drop: double-tap reset',
98
- debug: false },
99
- ],
100
- };
@@ -1,9 +0,0 @@
1
- import type { HALOpIR } from '@typecad/cuttlefish/api/shared';
2
- /**
3
- * Resolve a HAL power.* op to Zephyr C++.
4
- * Returns `{ code }` for statement ops, `{ expression }` for value-returning ops.
5
- */
6
- export declare function lowerPower(op: HALOpIR): {
7
- code?: string;
8
- expression?: string;
9
- };
@@ -1,60 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Power lowering — Zephyr power management
3
- //
4
- // Zephyr enters low-power states from the idle thread per policy. The app-facing
5
- // controls are pm_state_force (override policy to force a state on next idle)
6
- // and k_sleep (block the calling thread, allowing the system to idle into a
7
- // low-power state). "Deep sleep" maps to k_sleep (the SoC picks its deepest
8
- // allowed state); "light sleep" best-effort forces SUSPEND_TO_IDLE.
9
- //
10
- // deep_sleep_pin configures the wake GPIO as an interrupt source then k_sleeps
11
- // (the interrupt wakes the SoC). CPU frequency is SoC-specific (nRF52 has a
12
- // fixed 64 MHz HFXO with no portable dynamic scaling) and stays a documented
13
- // no-op. deep_sleep_pin targets gpio0 (single-controller nRF52840 case);
14
- // multi-controller SoC routing is a documented follow-on.
15
- // ---------------------------------------------------------------------------
16
- /**
17
- * Resolve a HAL power.* op to Zephyr C++.
18
- * Returns `{ code }` for statement ops, `{ expression }` for value-returning ops.
19
- */
20
- export function lowerPower(op) {
21
- const o = op;
22
- switch (op.operation) {
23
- case 'power.deep_sleep':
24
- // Block for the requested duration; the idle thread + PM policy will enter
25
- // the deepest state the SoC allows during the sleep.
26
- return { code: `k_sleep(K_MSEC(${o.ms}));` };
27
- case 'power.light_sleep':
28
- // Best-effort: force a shallow suspend on the next idle. pm_state_force
29
- // requires a pm_state_info; SUSPEND_TO_IDLE is a common shallow state.
30
- return { code: `pm_state_force(0, &(const struct pm_state_info){ .state = PM_STATE_SUSPEND_TO_IDLE, .substate_id = 0 });` };
31
- case 'power.deep_sleep_pin': {
32
- // Configure the pin as a GPIO wake source (level interrupt), then k_sleep
33
- // until the interrupt fires. A static gpio_callback + a no-op handler (the
34
- // wake just needs the interrupt enabled; the handler does nothing). level:
35
- // 1=high, 0=low. Targets gpio0 (single-controller nRF52840); multi-
36
- // controller SoC routing is a documented follow-on.
37
- const pin = o.pin;
38
- const level = o.level;
39
- const flags = level ? 'GPIO_INT_LEVEL_HIGH' : 'GPIO_INT_LEVEL_LOW';
40
- return {
41
- code: [
42
- '{',
43
- ` static struct gpio_callback __tc_wake_cb;`,
44
- ` const struct device* __dev = DEVICE_DT_GET(DT_NODELABEL(gpio0));`,
45
- ` gpio_pin_configure(__dev, ${pin}, GPIO_INPUT);`,
46
- ` gpio_init_callback(&__tc_wake_cb, [](const struct device*, struct gpio_callback*, gpio_port_pins_t) { (void)0; }, BIT(${pin}));`,
47
- ` gpio_add_callback(__dev, &__tc_wake_cb);`,
48
- ` gpio_pin_interrupt_configure(__dev, ${pin}, ${flags});`,
49
- ` k_sleep(K_FOREVER);`,
50
- ` gpio_pin_interrupt_configure(__dev, ${pin}, GPIO_INT_DISABLE);`,
51
- ` gpio_remove_callback(__dev, &__tc_wake_cb);`,
52
- '}',
53
- ].join(' '),
54
- };
55
- }
56
- default:
57
- throw new Error(`framework-zephyr does not yet support HAL op \`${op.operation}\`. ` +
58
- `Open an issue or use rawCpp() to emit it manually.`);
59
- }
60
- }
@@ -1,7 +0,0 @@
1
- import type { HALOpIR } from '@typecad/cuttlefish/api/shared';
2
- import type { ZephyrChipDescriptor } from '../chips/types.js';
3
- /** Resolve a HAL pulse.* or shift.* op to Zephyr C++ (bit-bang). */
4
- export declare function lowerPulseOrShift(op: HALOpIR, chip: ZephyrChipDescriptor): {
5
- code?: string;
6
- expression?: string;
7
- };
@@ -1,51 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Pulse + shift lowering — bit-bang via GPIO + timing
3
- //
4
- // pulse.in measures the duration of a pulse (HIGH or LOW) on a GPIO pin by
5
- // edge-polling with k_uptime_get. shift.out/in bit-bang a byte through a data
6
- // + clock pin pair using gpio_pin_set + k_busy_wait. These are software
7
- // implementations (no hardware pulse capture on nRF for the HAL surface); they
8
- // are correct but not high-precision.
9
- // ---------------------------------------------------------------------------
10
- import { controllerNodelabelForPin, controllerRawPinForPin } from '../chips/controllers.js';
11
- /** `DEVICE_DT_GET(DT_NODELABEL(<owning-controller>))` for a HAL pin. */
12
- function devForPin(chip, pin) {
13
- return `DEVICE_DT_GET(DT_NODELABEL(${controllerNodelabelForPin(chip, pin)}))`;
14
- }
15
- /** Resolve a HAL pulse.* or shift.* op to Zephyr C++ (bit-bang). */
16
- export function lowerPulseOrShift(op, chip) {
17
- const o = op;
18
- switch (op.operation) {
19
- case 'pulse.in': {
20
- // Wait for the pin to reach `value`, then measure until it changes.
21
- // Edge-poll with k_uptime_get() (ms granularity — coarse but correct,
22
- // and 64-bit so it cannot wrap mid-measurement over ~49 days). The wait
23
- // for the start edge is bounded by the timeout; the measurement of the
24
- // pulse itself is intentionally unbounded (that IS the pulse length).
25
- // Returns -1 (0) if the start edge never arrives within the timeout.
26
- const pin = controllerRawPinForPin(chip, o.pin);
27
- const want = o.value;
28
- const dev = devForPin(chip, o.pin);
29
- const timeout = o.timeout ?? 1_000_000; // default 1s in us
30
- return {
31
- expression: `({ int64_t __max = static_cast<int64_t>(${timeout} / 1000); int64_t __t0 = k_uptime_get(); bool __ok = true; while (gpio_pin_get_raw(${dev}, ${pin}) != ${want}) { if ((k_uptime_get() - __t0) > __max) { __ok = false; break; } } int32_t __ret = 0; if (__ok) { int64_t __start = k_uptime_get(); while (gpio_pin_get_raw(${dev}, ${pin}) == ${want}) { } __ret = static_cast<int32_t>((k_uptime_get() - __start) * 1000); } __ret; })`,
32
- };
33
- }
34
- case 'pulse.in_long': {
35
- // Same as pulse.in but for long pulses. Previously this spun forever
36
- // with NO timeout (the comment claimed "no overflow concern" but the
37
- // real risk was hanging the thread on a stuck pin). Apply the same
38
- // timeout-bounded start-edge wait as pulse.in (bug Q5).
39
- const pin = controllerRawPinForPin(chip, o.pin);
40
- const want = o.value;
41
- const dev = devForPin(chip, o.pin);
42
- const timeout = o.timeout ?? 3_000_000; // default 3s in us (long pulses)
43
- return {
44
- expression: `({ int64_t __max = static_cast<int64_t>(${timeout} / 1000); int64_t __t0 = k_uptime_get(); bool __ok = true; while (gpio_pin_get_raw(${dev}, ${pin}) != ${want}) { if ((k_uptime_get() - __t0) > __max) { __ok = false; break; } } int32_t __ret = 0; if (__ok) { int64_t __start = k_uptime_get(); while (gpio_pin_get_raw(${dev}, ${pin}) == ${want}) { } __ret = static_cast<int32_t>((k_uptime_get() - __start) * 1000); } __ret; })`,
45
- };
46
- }
47
- default:
48
- throw new Error(`framework-zephyr does not yet support HAL op \`${op.operation}\`. ` +
49
- `Open an issue or use rawCpp() to emit it manually.`);
50
- }
51
- }
@@ -1,10 +0,0 @@
1
- import type { HALOpIR } from '@typecad/cuttlefish/api/shared';
2
- import type { ZephyrChipDescriptor } from '../chips/types.js';
3
- /**
4
- * Resolve a HAL tone.* op to Zephyr C++ via PWM.
5
- * Returns `{ code }` for statement ops, `{ expression }` for value-returning ops.
6
- */
7
- export declare function lowerTone(op: HALOpIR, chip: ZephyrChipDescriptor): {
8
- code?: string;
9
- expression?: string;
10
- };