@typecad/framework-zephyr 1.0.0-alpha.16 → 1.0.0-alpha.19

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 (210) 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/audit.d.ts +111 -0
  6. package/dist/audit.js +416 -0
  7. package/dist/boardgen.d.ts +1 -9
  8. package/dist/boardgen.js +288 -47
  9. package/dist/chips/resolve.js +20 -0
  10. package/dist/chips/types.d.ts +22 -1
  11. package/dist/debug-codegen.js +1 -1
  12. package/dist/display/bindings.d.ts +55 -0
  13. package/dist/display/bindings.js +316 -0
  14. package/dist/display/gfx.d.ts +2 -3
  15. package/dist/display/gfx.js +166 -154
  16. package/dist/display/index.js +20 -1
  17. package/dist/display/mipi-dbi-host.d.ts +9 -0
  18. package/dist/display/mipi-dbi-host.js +174 -0
  19. package/dist/display/profiles.d.ts +109 -4
  20. package/dist/display/profiles.js +270 -7
  21. package/dist/display/touch-adapter.js +119 -49
  22. package/dist/display/ui-adapter-eink.d.ts +2 -0
  23. package/dist/display/ui-adapter-eink.js +4 -0
  24. package/dist/display/ui-adapter-gray.d.ts +8 -0
  25. package/dist/display/ui-adapter-gray.js +170 -0
  26. package/dist/display/ui-adapter-mono.d.ts +13 -0
  27. package/dist/display/ui-adapter-mono.js +230 -0
  28. package/dist/display/ui-adapter-native.d.ts +10 -0
  29. package/dist/display/ui-adapter-native.js +295 -0
  30. package/dist/display/ui-adapter-shared.d.ts +11 -0
  31. package/dist/display/ui-adapter-shared.js +122 -0
  32. package/dist/display/ui-adapter.js +510 -558
  33. package/dist/doctor.js +4 -4
  34. package/dist/dt-config/custom-board.js +2 -2
  35. package/dist/dt-config/kconfig.d.ts +62 -1
  36. package/dist/dt-config/kconfig.js +141 -38
  37. package/dist/dt-config/overlay.d.ts +15 -2
  38. package/dist/dt-config/overlay.js +433 -18
  39. package/dist/framework.manifest.d.ts +10 -4
  40. package/dist/framework.manifest.js +133 -17
  41. package/dist/index.d.ts +2 -0
  42. package/dist/index.js +14 -6
  43. package/dist/licenses.d.ts +2 -2
  44. package/dist/licenses.js +13 -92
  45. package/dist/lowering/can.d.ts +25 -0
  46. package/dist/lowering/can.js +97 -0
  47. package/dist/lowering/clock.d.ts +17 -0
  48. package/dist/lowering/clock.js +58 -0
  49. package/dist/lowering/fs.js +1 -1
  50. package/dist/lowering/gpio.js +0 -32
  51. package/dist/lowering/hid.d.ts +27 -0
  52. package/dist/lowering/hid.js +244 -0
  53. package/dist/lowering/http.js +264 -32
  54. package/dist/lowering/i2c.d.ts +8 -0
  55. package/dist/lowering/i2c.js +137 -5
  56. package/dist/lowering/i2s.d.ts +27 -0
  57. package/dist/lowering/i2s.js +98 -0
  58. package/dist/lowering/index.d.ts +9 -1
  59. package/dist/lowering/index.js +25 -1
  60. package/dist/lowering/interrupts.js +6 -0
  61. package/dist/lowering/matrix.d.ts +15 -0
  62. package/dist/lowering/matrix.js +63 -0
  63. package/dist/lowering/mqtt.js +110 -8
  64. package/dist/lowering/power.d.ts +3 -2
  65. package/dist/lowering/power.js +20 -45
  66. package/dist/lowering/pwm.js +25 -0
  67. package/dist/lowering/sensor.d.ts +2 -2
  68. package/dist/lowering/sensor.js +8 -4
  69. package/dist/lowering/strip.d.ts +16 -0
  70. package/dist/lowering/strip.js +70 -0
  71. package/dist/lowering/thread.js +5 -1
  72. package/dist/lowering/trace.d.ts +44 -0
  73. package/dist/lowering/trace.js +239 -0
  74. package/dist/lowering/uart.js +6 -1
  75. package/dist/lowering/usb.d.ts +3 -1
  76. package/dist/lowering/usb.js +16 -13
  77. package/dist/lowering/wdt.js +2 -29
  78. package/dist/sbom.d.ts +181 -0
  79. package/dist/sbom.js +901 -0
  80. package/dist/sdk/board-catalog-sync.d.ts +1 -3
  81. package/dist/sdk/board-catalog-sync.js +4 -10
  82. package/dist/strategy.d.ts +82 -46
  83. package/dist/strategy.js +639 -182
  84. package/dist/tmp-probe.d.ts +2 -0
  85. package/dist/tmp-probe.js +9 -0
  86. package/dist/toolchain/debug-config.d.ts +50 -90
  87. package/dist/toolchain/debug-config.js +239 -510
  88. package/dist/toolchain/env-check.d.ts +1 -3
  89. package/dist/toolchain/env-check.js +2 -7
  90. package/dist/toolchain/index.d.ts +28 -3
  91. package/dist/toolchain/index.js +498 -62
  92. package/dist/toolchain/runners.d.ts +16 -0
  93. package/dist/toolchain/runners.js +75 -0
  94. package/dist/toolchain/scaffold.d.ts +5 -2
  95. package/dist/toolchain/scaffold.js +79 -15
  96. package/dist/toolchain/west-discover.d.ts +6 -0
  97. package/dist/toolchain/west-discover.js +36 -13
  98. package/dist/toolchain/west-spawn.js +8 -2
  99. package/dist/west-inventory.d.ts +25 -0
  100. package/dist/west-inventory.js +97 -0
  101. package/installer/README.md +328 -328
  102. package/installer/install.sh +2 -2
  103. package/installer/templates/project/.typecad/activate-zephyr.ps1 +1 -1
  104. package/installer/templates/project/.typecad/activate-zephyr.sh +1 -1
  105. package/installer/templates/project/.vscode/settings.json +1 -1
  106. package/installer/templates/project/README.md +2 -2
  107. package/package.json +5 -5
  108. package/src/as-built.ts +206 -206
  109. package/src/audit.ts +529 -0
  110. package/src/boardgen.ts +265 -50
  111. package/src/chips/resolve.ts +21 -0
  112. package/src/chips/types.ts +10 -1
  113. package/src/display/bindings.ts +347 -0
  114. package/src/display/gfx.ts +318 -306
  115. package/src/display/index.ts +87 -70
  116. package/src/display/mipi-dbi-host.ts +183 -0
  117. package/src/display/profiles.ts +458 -139
  118. package/src/display/touch-adapter.ts +119 -49
  119. package/src/display/ui-adapter-eink.ts +13 -0
  120. package/src/display/ui-adapter-gray.ts +178 -0
  121. package/src/display/ui-adapter-mono.ts +238 -0
  122. package/src/display/ui-adapter-native.ts +304 -0
  123. package/src/display/ui-adapter-shared.ts +125 -0
  124. package/src/display/ui-adapter.ts +732 -781
  125. package/src/doctor.ts +4 -4
  126. package/src/dt-config/custom-board.ts +2 -2
  127. package/src/dt-config/kconfig.ts +647 -505
  128. package/src/dt-config/overlay.ts +1475 -1058
  129. package/src/framework.manifest.ts +659 -535
  130. package/src/index.ts +16 -6
  131. package/src/licenses.ts +346 -425
  132. package/src/lowering/can.ts +140 -0
  133. package/src/lowering/clock.ts +91 -0
  134. package/src/lowering/fs.ts +135 -135
  135. package/src/lowering/gpio.ts +0 -33
  136. package/src/lowering/hid.ts +261 -0
  137. package/src/lowering/http.ts +264 -32
  138. package/src/lowering/i2c.ts +142 -5
  139. package/src/lowering/i2s.ts +143 -0
  140. package/src/lowering/index.ts +18 -1
  141. package/src/lowering/interrupts.ts +6 -0
  142. package/src/lowering/matrix.ts +70 -0
  143. package/src/lowering/mqtt.ts +109 -8
  144. package/src/lowering/power.ts +41 -0
  145. package/src/lowering/pwm.ts +192 -167
  146. package/src/lowering/sensor.ts +159 -155
  147. package/src/lowering/strip.ts +81 -0
  148. package/src/lowering/thread.ts +5 -1
  149. package/src/lowering/trace.ts +270 -0
  150. package/src/lowering/uart.ts +6 -1
  151. package/src/lowering/usb.ts +16 -13
  152. package/src/lowering/wdt.ts +2 -25
  153. package/src/sbom.ts +1117 -0
  154. package/src/sdk/board-catalog-sync.ts +4 -25
  155. package/src/strategy.ts +2680 -2309
  156. package/src/toolchain/debug-config.ts +262 -522
  157. package/src/toolchain/env-check.ts +279 -285
  158. package/src/toolchain/index.ts +1792 -1359
  159. package/src/toolchain/runners.ts +80 -0
  160. package/src/toolchain/scaffold.ts +355 -296
  161. package/src/toolchain/west-discover.ts +35 -13
  162. package/src/toolchain/west-spawn.ts +174 -168
  163. package/src/west-inventory.ts +102 -0
  164. package/dist/async/timer-polyfill.d.ts +0 -10
  165. package/dist/async/timer-polyfill.js +0 -95
  166. package/dist/chips/board-overrides.d.ts +0 -7
  167. package/dist/chips/board-overrides.js +0 -11
  168. package/dist/chips/esp32.d.ts +0 -2
  169. package/dist/chips/esp32.js +0 -71
  170. package/dist/chips/esp32s3.d.ts +0 -2
  171. package/dist/chips/esp32s3.js +0 -103
  172. package/dist/chips/soc/.d.ts +0 -2
  173. package/dist/chips/soc/.js +0 -129
  174. package/dist/chips/soc/esp32.d.ts +0 -2
  175. package/dist/chips/soc/esp32.js +0 -120
  176. package/dist/chips/soc/esp32c3.d.ts +0 -2
  177. package/dist/chips/soc/esp32c3.js +0 -90
  178. package/dist/chips/soc/esp32c6.d.ts +0 -2
  179. package/dist/chips/soc/esp32c6.js +0 -109
  180. package/dist/chips/soc/esp32s3.d.ts +0 -2
  181. package/dist/chips/soc/esp32s3.js +0 -189
  182. package/dist/chips/soc/index.d.ts +0 -2
  183. package/dist/chips/soc/index.js +0 -23
  184. package/dist/chips/soc/nrf52840.d.ts +0 -2
  185. package/dist/chips/soc/nrf52840.js +0 -130
  186. package/dist/chips/soc/rp2040.d.ts +0 -2
  187. package/dist/chips/soc/rp2040.js +0 -141
  188. package/dist/chips/soc/rp2350a.d.ts +0 -2
  189. package/dist/chips/soc/rp2350a.js +0 -145
  190. package/dist/chips/soc/samd21g18a.d.ts +0 -2
  191. package/dist/chips/soc/samd21g18a.js +0 -143
  192. package/dist/chips/soc/stm32f411xe.d.ts +0 -2
  193. package/dist/chips/soc/stm32f411xe.js +0 -251
  194. package/dist/chips/xiao-ble.d.ts +0 -2
  195. package/dist/chips/xiao-ble.js +0 -100
  196. package/dist/lowering/pulse.d.ts +0 -7
  197. package/dist/lowering/pulse.js +0 -51
  198. package/dist/lowering/tone.d.ts +0 -10
  199. package/dist/lowering/tone.js +0 -63
  200. package/dist/lowering/worker-backing.d.ts +0 -14
  201. package/dist/lowering/worker-backing.js +0 -79
  202. package/dist/lowering/worker.d.ts +0 -6
  203. package/dist/lowering/worker.js +0 -14
  204. package/dist/sdk/board-data.generated.d.ts +0 -2
  205. package/dist/sdk/board-data.generated.js +0 -4
  206. package/dist/sdk/catalog-walker.d.ts +0 -90
  207. package/dist/sdk/catalog-walker.js +0 -682
  208. package/dist/sdk/dts-reader.d.ts +0 -83
  209. package/dist/sdk/dts-reader.js +0 -596
  210. 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,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
- };
@@ -1,63 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Tone lowering — PWM-based square-wave generation
3
- //
4
- // tone is a convenience wrapper around PWM: a square wave at `frequency` Hz with
5
- // a 50% duty cycle. The lowering maps frequency → period (ns) and sets the PWM
6
- // channel to a 50% pulse. stop turns the output off (0% duty). The PWM spec is
7
- // resolved from the chip descriptor (pwm-led0 on the XIAO).
8
- //
9
- // An optional duration is honored by scheduling a stop via k_sleep in a detached
10
- // fashion — but the simple lowering is blocking (k_msleep(duration) then stop),
11
- // matching the synchronous Arduino tone() semantics. For non-blocking tone,
12
- // a workqueue would be needed (deferred).
13
- // ---------------------------------------------------------------------------
14
- import { findPwmSpec, pwmDtAliasToken } from './pwm.js';
15
- /**
16
- * The PWM spec a tone op drives: the op's own pin when it maps to a spec
17
- * (matrix chips — ESP32 LEDC — resolve any driven pad), else the board's
18
- * first spec (the aliased LED channel, e.g. pwm-led0 on the XIAO).
19
- */
20
- function toneSpec(chip, pin) {
21
- return (typeof pin === 'number' ? findPwmSpec(chip, pin) : undefined)
22
- ?? chip.pwm?.specs[0];
23
- }
24
- /**
25
- * Resolve a HAL tone.* op to Zephyr C++ via PWM.
26
- * Returns `{ code }` for statement ops, `{ expression }` for value-returning ops.
27
- */
28
- export function lowerTone(op, chip) {
29
- const o = op;
30
- switch (op.operation) {
31
- case 'tone.play': {
32
- // period_ns = 1e9 / freq; pulse_ns = period / 2 (50% duty).
33
- // Build a fake pwm.write would need the spec var directly; emit the
34
- // pwm_set_dt call against the same spec var the PWM lowering uses.
35
- const spec = toneSpec(chip, o.pin);
36
- if (!spec) {
37
- return { code: `/* tone.play(${o.frequency}): no PWM spec in chip descriptor */` };
38
- }
39
- const v = `__tc_pwm_${pwmDtAliasToken(spec)}`;
40
- const freq = o.frequency;
41
- const duration = o.duration;
42
- // Braced: two tone ops in one statement-scope (e.g. tone(440).for(50)
43
- // lowers tone.play + tone.play_for back-to-back) would otherwise
44
- // redeclare __period.
45
- const setTone = `{ uint32_t __period = (${freq} > 0) ? (1000000000ULL / static_cast<uint64_t>(${freq})) : 0; pwm_set_dt(&${v}, __period, __period / 2); }`;
46
- if (duration !== undefined) {
47
- // Blocking tone for the requested duration, then stop.
48
- return { code: `${setTone} k_msleep(${duration}); pwm_set_pulse_dt(&${v}, 0);` };
49
- }
50
- return { code: setTone };
51
- }
52
- case 'tone.stop': {
53
- const spec = toneSpec(chip, o.pin);
54
- if (!spec)
55
- return { code: `/* tone.stop: no PWM spec */` };
56
- const v = `__tc_pwm_${pwmDtAliasToken(spec)}`;
57
- return { code: `pwm_set_pulse_dt(&${v}, 0);` };
58
- }
59
- default:
60
- throw new Error(`framework-zephyr does not yet support HAL op \`${op.operation}\`. ` +
61
- `Open an issue or use rawCpp() to emit it manually.`);
62
- }
63
- }
@@ -1,14 +0,0 @@
1
- import type { WorkerBacking } from "@typecad/cuttlefish/api/shared";
2
- export interface ZephyrWorkerBackingOptions {
3
- /** Initial count of each per-slot semaphore. Default 0 (empty). */
4
- initialSemCount?: number;
5
- }
6
- /**
7
- * Build the Zephyr (k_work + k_sem) worker backing.
8
- *
9
- * Per slot: a `struct k_work _work_<i>` and a `struct k_sem _done_sem_<i>`.
10
- * submit resets the semaphore and submits the work to the system workqueue;
11
- * the work handler runs the trampoline; the trampoline signals completion via
12
- * k_sem_give; done polls via k_sem_take(K_NO_WAIT).
13
- */
14
- export declare function buildZephyrWorkerBacking(_options?: ZephyrWorkerBackingOptions): WorkerBacking;