@typecad/hal 1.0.0-alpha.14 → 1.0.0-alpha.16
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 +145 -87
- package/dist/adc-pin.d.ts +53 -0
- package/dist/adc-pin.js +69 -0
- package/dist/async.d.ts +3 -11
- package/dist/async.js +3 -15
- package/dist/ble.d.ts +42 -78
- package/dist/ble.js +79 -98
- package/dist/counter.d.ts +16 -0
- package/dist/counter.js +32 -0
- package/dist/dac-pin.d.ts +13 -0
- package/dist/dac-pin.js +21 -0
- package/dist/emit.d.ts +123 -196
- package/dist/emit.js +146 -208
- package/dist/fs.d.ts +12 -31
- package/dist/fs.js +30 -40
- package/dist/gpio-pin.d.ts +46 -0
- package/dist/gpio-pin.js +77 -0
- package/dist/gpio.d.ts +0 -103
- package/dist/gpio.js +16 -227
- package/dist/http.d.ts +38 -39
- package/dist/http.js +53 -78
- package/dist/i2c-target.d.ts +28 -0
- package/dist/i2c-target.js +52 -0
- package/dist/i2c.d.ts +5 -43
- package/dist/i2c.js +17 -130
- package/dist/index.d.ts +30 -42
- package/dist/index.js +27 -39
- package/dist/math.d.ts +0 -13
- package/dist/math.js +9 -13
- package/dist/mqtt.d.ts +15 -25
- package/dist/mqtt.js +32 -28
- package/dist/power.d.ts +9 -17
- package/dist/power.js +22 -20
- package/dist/preferences.d.ts +17 -25
- package/dist/preferences.js +54 -52
- package/dist/pulse.d.ts +4 -4
- package/dist/pulse.js +6 -2
- package/dist/pwm-pin.d.ts +24 -0
- package/dist/pwm-pin.js +38 -0
- package/dist/random.d.ts +0 -2
- package/dist/random.js +14 -20
- package/dist/sensor-catalog.generated.d.ts +997 -0
- package/dist/sensor-catalog.generated.js +764 -0
- package/dist/sensor.d.ts +46 -0
- package/dist/sensor.js +52 -0
- package/dist/shift-pin.d.ts +2 -0
- package/dist/shift-pin.js +13 -0
- package/dist/spi-target.d.ts +25 -0
- package/dist/spi-target.js +42 -0
- package/dist/spi.d.ts +8 -26
- package/dist/spi.js +15 -87
- package/dist/thread.d.ts +18 -0
- package/dist/thread.js +36 -0
- package/dist/time.d.ts +23 -0
- package/dist/time.js +43 -0
- package/dist/timing.d.ts +17 -7
- package/dist/timing.js +17 -7
- package/dist/types.d.ts +4 -34
- package/dist/types.js +5 -47
- package/dist/uart-port.d.ts +26 -0
- package/dist/uart-port.js +52 -0
- package/dist/uart.d.ts +0 -17
- package/dist/uart.js +10 -53
- package/dist/usb.d.ts +26 -0
- package/dist/usb.js +66 -0
- package/dist/watchdog.d.ts +12 -0
- package/dist/watchdog.js +28 -0
- package/dist/wifi.d.ts +88 -64
- package/dist/wifi.js +112 -126
- package/dist/zephyr-tokens.generated.d.ts +8 -0
- package/dist/zephyr-tokens.generated.js +73 -0
- package/package.json +6 -7
- package/src/adc-pin.ts +89 -0
- package/src/async.ts +3 -16
- package/src/ble.ts +84 -111
- package/src/counter.ts +40 -0
- package/src/dac-pin.ts +28 -0
- package/src/emit.ts +157 -238
- package/src/fs.ts +47 -54
- package/src/gpio-pin.ts +91 -0
- package/src/gpio.ts +49 -320
- package/src/http.ts +75 -95
- package/src/i2c-target.ts +63 -0
- package/src/i2c.ts +29 -167
- package/src/index.ts +32 -46
- package/src/math.ts +9 -14
- package/src/mqtt.ts +39 -31
- package/src/preferences.ts +52 -61
- package/src/pwm-pin.ts +54 -0
- package/src/random.ts +14 -21
- package/src/sensor-catalog.generated.ts +1238 -0
- package/src/sensor.ts +80 -0
- package/src/shift-pin.ts +16 -0
- package/src/spi-target.ts +53 -0
- package/src/spi.ts +27 -121
- package/src/thread.ts +44 -0
- package/src/time.ts +50 -0
- package/src/types.ts +14 -89
- package/src/uart-port.ts +64 -0
- package/src/usb.ts +82 -0
- package/src/watchdog.ts +35 -0
- package/src/wifi.ts +147 -179
- package/src/zephyr-tokens.generated.ts +77 -0
- package/src/adc.ts +0 -30
- package/src/capacitive.ts +0 -31
- package/src/constants.ts +0 -23
- package/src/dac.ts +0 -21
- package/src/eeprom.ts +0 -26
- package/src/interrupts.ts +0 -35
- package/src/mdns.ts +0 -50
- package/src/ota.ts +0 -44
- package/src/power.ts +0 -36
- package/src/pulse.ts +0 -63
- package/src/rmt.ts +0 -125
- package/src/shift.ts +0 -88
- package/src/temperature.ts +0 -20
- package/src/timer.ts +0 -58
- package/src/timing.ts +0 -67
- package/src/uart.ts +0 -77
- package/src/utils.ts +0 -17
- package/src/wdt.ts +0 -17
package/dist/emit.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// framework-specific C++ at code generation time.
|
|
7
7
|
//
|
|
8
8
|
// EMIT BOUNDARY: This file is a canonical entry point of the HAL lowering
|
|
9
|
-
// surface (A) — its C++ output lands in user
|
|
9
|
+
// surface (A) — its C++ output lands in user programs. The emitted bytes are
|
|
10
10
|
// covered by the TypeCAD Runtime Exception (see RUNTIME_EXCEPTION.md at the
|
|
11
11
|
// repository root) and are not subject to the license of this tool source.
|
|
12
12
|
//
|
|
@@ -23,264 +23,190 @@ export function gpioWrite(pin, value) { }
|
|
|
23
23
|
export function gpioRead(pin) { return 0; }
|
|
24
24
|
/** Toggle a digital pin. */
|
|
25
25
|
export function gpioToggle(pin) { }
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/** Thin GPIO (hal/gpio-pin.ts): configure with Zephyr flag tokens
|
|
27
|
+
* ("GPIO.OUTPUT | GPIO.PULL_UP"). The lowering maps token names to the
|
|
28
|
+
* GPIO_* macros; the emitted configure is guarded per pin (first use wins). */
|
|
29
|
+
export function gpioConfigure(pin, flags) { }
|
|
30
|
+
/** GPIO.shiftOut/shiftIn: bit-banged shift via two pins (one op each). */
|
|
31
|
+
export function gpioShiftOut(dataPin, clockPin, value, msbFirst) { }
|
|
32
|
+
export function gpioShiftIn(dataPin, clockPin, msbFirst) { return 0; }
|
|
33
|
+
/** Thin GPIO read with FUSED guarded configure — one op, one statement-
|
|
34
|
+
* expression: correct in any expression position (if-conditions drop a
|
|
35
|
+
* method's leading side-effect ops, so get() must not rely on a separate
|
|
36
|
+
* configure op). */
|
|
37
|
+
export function gpioReadCfg(pin, flags) { return 0; }
|
|
28
38
|
// ---------------------------------------------------------------------------
|
|
29
39
|
// PWM — pulse-width modulation
|
|
30
40
|
// ---------------------------------------------------------------------------
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export function
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export function rmtTxWaitDone(pin, timeoutMs) { }
|
|
42
|
-
/** Tear down the TX channel and release its slot. */
|
|
43
|
-
export function rmtTxDeinit(pin) { }
|
|
44
|
-
/** Positional semantic primitive — use rmtRxInit() from hal/rmt.ts. */
|
|
45
|
-
export function rmtRxInit(pin, resolutionHz) { }
|
|
46
|
-
/** Register a callback-by-name invoked when an RX burst completes. */
|
|
47
|
-
export function rmtRxOnReceived(pin, handler) { }
|
|
48
|
-
/** Start receiving. */
|
|
49
|
-
export function rmtRxStart(pin) { }
|
|
50
|
-
/** Stop receiving. */
|
|
51
|
-
export function rmtRxStop(pin) { }
|
|
52
|
-
/** Blocking read — returns flattened symbols [d0,l0,d1,l1,…] in ticks. */
|
|
53
|
-
export function rmtRxRead(pin, maxCount) { return []; }
|
|
54
|
-
/** Tear down the RX channel and release its slot. */
|
|
55
|
-
export function rmtRxDeinit(pin) { }
|
|
41
|
+
/** Thin PWM (hal/pwm-pin.ts): set pulse width in ns against the constructed
|
|
42
|
+
* period. The first use also applies the construction period
|
|
43
|
+
* (pwm_set_dt with an idle pulse), then pwm_set_pulse_dt. */
|
|
44
|
+
export function pwmSetPulse(pin, periodNs, pulseNs, controller = '', channel = -1) { }
|
|
45
|
+
/** Thin PWM duty sugar: pulse = duty(0.0–1.0) × periodNs — one
|
|
46
|
+
* pwm_set_pulse_dt call, no 0–255 scaling. */
|
|
47
|
+
export function pwmSetDuty(pin, periodNs, duty, controller = '', channel = -1) { }
|
|
48
|
+
/** Thin PWM: change the period at runtime (pwm_set_dt; the pulse resets to
|
|
49
|
+
* idle — Zephyr 4.4 has no period-only setter). */
|
|
50
|
+
export function pwmSetPeriod(pin, periodNs, controller = '', channel = -1) { }
|
|
56
51
|
// ---------------------------------------------------------------------------
|
|
57
52
|
// ADC — analog-to-digital conversion
|
|
58
53
|
// ---------------------------------------------------------------------------
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
export function
|
|
63
|
-
/**
|
|
64
|
-
|
|
54
|
+
/** Thin ADC (hal/adc-pin.ts): raw read with construction-time gain/reference
|
|
55
|
+
* tokens ("ADC.GAIN_1_4" / "ADC.REF_INTERNAL"); empty strings
|
|
56
|
+
* mean "use the chip descriptor's defaults". */
|
|
57
|
+
export function adcReadRaw(pin, gain, reference, channel = -1, device = '', pinctrl = '') { return 0; }
|
|
58
|
+
/** Thin ADC: millivolts read (adc_raw_to_millivolts) with the same
|
|
59
|
+
* construction-time gain/reference tokens. */
|
|
60
|
+
export function adcReadMv(pin, gain, reference, channel = -1, device = '', pinctrl = '') { return 0; }
|
|
65
61
|
// ---------------------------------------------------------------------------
|
|
66
62
|
// Interrupts
|
|
67
63
|
// ---------------------------------------------------------------------------
|
|
68
|
-
/**
|
|
69
|
-
|
|
64
|
+
/** Thin GPIO interrupts (hal/gpio-pin.ts onInterrupt): attach with Zephyr
|
|
65
|
+
* INT_* tokens ("GPIO.INT_EDGE_FALLING") instead of mode strings. */
|
|
66
|
+
export function interruptAttachFlags(pin, handler, intFlags) { }
|
|
70
67
|
/** Detach an interrupt from a pin. */
|
|
71
68
|
export function interruptDetach(pin) { }
|
|
72
69
|
// ---------------------------------------------------------------------------
|
|
73
|
-
// Tone / audio output
|
|
74
|
-
// ---------------------------------------------------------------------------
|
|
75
|
-
/** Play a tone on a pin at the given frequency, optionally for a duration. */
|
|
76
|
-
export function tonePlay(pin, frequency, duration) { }
|
|
77
|
-
/** Stop tone playback on a pin. */
|
|
78
|
-
export function toneStop(pin) { }
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
70
|
// Timing
|
|
81
71
|
// ---------------------------------------------------------------------------
|
|
82
|
-
/**
|
|
83
|
-
export function
|
|
84
|
-
/**
|
|
85
|
-
export function
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
* symbol per target (ESP.getFreeHeap() on ESP32, __heap_start trick on AVR). */
|
|
92
|
-
export function getFreeHeap() { return 0; }
|
|
72
|
+
/** Time.sleep — yielding sleep in milliseconds (Zephyr: k_msleep). */
|
|
73
|
+
export function timeSleep(ms) { }
|
|
74
|
+
/** Time.now — milliseconds since boot as a double (Zephyr: k_uptime_get). */
|
|
75
|
+
export function timeNow() { return 0; }
|
|
76
|
+
/** Time.nowUs — microseconds since boot as a double, uptime-derived
|
|
77
|
+
* (k_uptime_get() * 1000) on every board — uniform, monotonic. */
|
|
78
|
+
export function timeNowUs() { return 0; }
|
|
79
|
+
/** Time.busyWaitUs — spin-wait the given microseconds, no yield (Zephyr: k_busy_wait). */
|
|
80
|
+
export function timeBusyWaitUs(us) { }
|
|
93
81
|
// ---------------------------------------------------------------------------
|
|
94
82
|
// I2C — inter-integrated circuit bus
|
|
95
83
|
// ---------------------------------------------------------------------------
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
export function
|
|
100
|
-
|
|
101
|
-
export function
|
|
102
|
-
|
|
103
|
-
export function i2cBeginTx(bus, address) { }
|
|
104
|
-
/** Write data to I2C bus. */
|
|
105
|
-
export function i2cWrite(bus, data) { }
|
|
106
|
-
/** Write a byte buffer to I2C bus (expands array literals to per-byte writes). */
|
|
107
|
-
export function i2cWriteBuffer(bus, data) { }
|
|
108
|
-
/** End I2C transmission. Returns status. */
|
|
109
|
-
export function i2cEndTx(bus, stop) { return 0; }
|
|
110
|
-
/** Request bytes from I2C slave. */
|
|
111
|
-
export function i2cRequestFrom(bus, address, quantity, stop) { return 0; }
|
|
112
|
-
/** Check if bytes are available from I2C. */
|
|
113
|
-
export function i2cAvailable(bus) { return 0; }
|
|
114
|
-
/** Read a byte from I2C. */
|
|
115
|
-
export function i2cRead(bus) { return 0; }
|
|
116
|
-
/**
|
|
117
|
-
* Drain `count` bytes requested from the I2C bus into a caller-provided buffer.
|
|
118
|
-
* Semantic primitive: lowers to the `i2c.read_buffer` HAL op. The `buffer`
|
|
119
|
-
* argument is emitted as a placeholder (`__HAL_READ_BUF__`) that the var-init
|
|
120
|
-
* transformer rewrites to the caller's own buffer variable, so bytes land in
|
|
121
|
-
* the `uint8_t data[N]` declared in user scope — NOT an internal temp that
|
|
122
|
-
* decays to a pointer on return. Keeps `data.length` / `data[i]` valid.
|
|
123
|
-
*/
|
|
124
|
-
export function i2cReadBuffer(bus, count, buffer) { }
|
|
84
|
+
// Thin I2C device (hal/i2c-target.ts): Zephyr register verbs. `hz` (0 =
|
|
85
|
+
// leave the bus at its current speed) applies once via a guarded
|
|
86
|
+
// i2c_configure on first use.
|
|
87
|
+
export function i2cRegWrite(bus, address, hz, reg, value) { }
|
|
88
|
+
export function i2cRegRead(bus, address, hz, reg) { return 0; }
|
|
89
|
+
export function i2cRegUpdate(bus, address, hz, reg, mask, value) { }
|
|
90
|
+
export function i2cDevWrite(bus, address, hz, data) { }
|
|
125
91
|
// ---------------------------------------------------------------------------
|
|
126
92
|
// SPI — serial peripheral interface
|
|
127
93
|
// ---------------------------------------------------------------------------
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
* responsible for asserting/de-asserting chip-select around it.
|
|
148
|
-
*/
|
|
149
|
-
export function spiReadBuffer(bus, count, buffer) { }
|
|
150
|
-
/** Set SPI data mode. */
|
|
151
|
-
export function spiSetMode(bus, mode) { }
|
|
152
|
-
/** Set SPI bit order. */
|
|
153
|
-
export function spiSetBitOrder(bus, order) { }
|
|
154
|
-
// ---------------------------------------------------------------------------
|
|
155
|
-
// UART — serial communication
|
|
156
|
-
// ---------------------------------------------------------------------------
|
|
157
|
-
/** Initialize serial port with baud rate. */
|
|
158
|
-
export function uartBegin(port, baud) { }
|
|
159
|
-
/** Disable serial port. */
|
|
160
|
-
export function uartEnd(port) { }
|
|
161
|
-
/** Print value to serial. */
|
|
162
|
-
export function uartPrint(port, value) { }
|
|
163
|
-
/** Print value with newline to serial. */
|
|
164
|
-
export function uartPrintln(port, value) { }
|
|
165
|
-
/** printf-style formatted print to serial. */
|
|
166
|
-
export function uartPrintf(port, format, args) { }
|
|
167
|
-
/** Write raw data to serial. */
|
|
168
|
-
export function uartWrite(port, data) { }
|
|
169
|
-
/** Read a byte from serial. */
|
|
170
|
-
export function uartRead(port) { return 0; }
|
|
171
|
-
/** Peek at next byte from serial without consuming. */
|
|
172
|
-
export function uartPeek(port) { return 0; }
|
|
173
|
-
/** Check if bytes are available from serial. */
|
|
174
|
-
export function uartAvailable(port) { return 0; }
|
|
175
|
-
/** Flush serial output. */
|
|
176
|
-
export function uartFlush(port) { }
|
|
177
|
-
// ---------------------------------------------------------------------------
|
|
178
|
-
// Pulse measurement
|
|
179
|
-
// ---------------------------------------------------------------------------
|
|
180
|
-
/** Measure pulse duration on a pin. */
|
|
181
|
-
export function pulseIn_(pin, value, timeout) { return 0; }
|
|
182
|
-
/** Measure long pulse using high-precision timer. */
|
|
183
|
-
export function pulseInLong_(pin, value) { return 0; }
|
|
184
|
-
// ---------------------------------------------------------------------------
|
|
185
|
-
// Shift register
|
|
186
|
-
// ---------------------------------------------------------------------------
|
|
187
|
-
/** Shift a byte out to a pin. */
|
|
188
|
-
export function shiftOut_(dataPin, clockPin, bitOrder, value) { }
|
|
189
|
-
/** Shift a byte in from a pin. */
|
|
190
|
-
export function shiftIn_(dataPin, clockPin, bitOrder) { return 0; }
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
// USB — CDC-ACM serial over the USB connector (device stack)
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
/** Enable the USB device + open the CDC serial port with a baud hint. */
|
|
98
|
+
export function usbBegin(port) { }
|
|
99
|
+
/** Disable the CDC serial port. */
|
|
100
|
+
export function usbEnd(port) { }
|
|
101
|
+
/** Print value to the USB serial port. */
|
|
102
|
+
export function usbPrint(port, value) { }
|
|
103
|
+
/** Print value with newline to the USB serial port. */
|
|
104
|
+
export function usbPrintln(port, value) { }
|
|
105
|
+
/** Read a byte from the USB serial port (-1 if none). */
|
|
106
|
+
export function usbRead(port) { return 0; }
|
|
107
|
+
/** Check if bytes are available from the USB serial port. */
|
|
108
|
+
export function usbAvailable(port) { return 0; }
|
|
109
|
+
/** True when the host has opened the port (DTR asserted). */
|
|
110
|
+
export function usbConnected(port) { return false; }
|
|
111
|
+
/** Thin waitLinked(): bounded DTR poll in the shim. */
|
|
112
|
+
export function usbWaitReady(port, timeoutMs) { return false; }
|
|
191
113
|
// ---------------------------------------------------------------------------
|
|
192
114
|
// Board constant resolution
|
|
193
115
|
// ---------------------------------------------------------------------------
|
|
194
|
-
/**
|
|
195
|
-
|
|
116
|
+
/** Thin DAC (hal/dac-pin.ts): raw dac_write_value with a construction-time
|
|
117
|
+
* resolution (0 = the chip descriptor's channel resolution). */
|
|
118
|
+
export function dacWriteValue(pin, value, resolution) { }
|
|
196
119
|
// ---------------------------------------------------------------------------
|
|
197
120
|
// Watchdog timer (WDT)
|
|
198
121
|
// ---------------------------------------------------------------------------
|
|
199
|
-
/** Enable the watchdog timer with the given timeout (string preset or number). */
|
|
200
|
-
export function wdtEnable(timeout) { }
|
|
201
|
-
/** Reset (kick) the watchdog timer. */
|
|
202
|
-
export function wdtReset() { }
|
|
203
122
|
/** Disable the watchdog timer. */
|
|
204
123
|
export function wdtDisable() { }
|
|
124
|
+
/** Thin Watchdog (hal/watchdog.ts): arm with the construction timeout in ms
|
|
125
|
+
* (wdt_install_timeout + wdt_setup). */
|
|
126
|
+
export function wdtSetup(timeoutMs) { }
|
|
127
|
+
/** Thin Watchdog: feed (wdt_feed). */
|
|
128
|
+
export function wdtFeed() { }
|
|
129
|
+
/** Thin Counter (hal/counter.ts): register the alarm handler. */
|
|
130
|
+
export function counterOnAlarm(instance, handler) { }
|
|
131
|
+
/** Thin Counter: apply hz as the top value and start (counter_start). */
|
|
132
|
+
export function counterStart(instance, hz) { }
|
|
133
|
+
/** Thin Counter: stop (counter_stop). */
|
|
134
|
+
export function counterStop(instance) { }
|
|
135
|
+
// Thin SPI device (hal/spi-target.ts): the op carries the construction facts
|
|
136
|
+
// (cs pin, hz, mode) so the shim state block and overlay child node derive
|
|
137
|
+
// from op facts alone (the sensor discipline). `rx` is the caller's buffer
|
|
138
|
+
// identifier ('' = write-only).
|
|
139
|
+
export function spiTransceiveDt(bus, cs, hz, mode, tx, rx) { }
|
|
140
|
+
export function spiWriteDt(bus, cs, hz, mode, tx) { }
|
|
141
|
+
/** SPITarget.readReg sugar: one-byte register read via spi_transceive_dt
|
|
142
|
+
* against an INTERNAL buffer — no caller array needed. */
|
|
143
|
+
export function spiReadReg(bus, cs, hz, mode, reg) { return 0; }
|
|
144
|
+
// Thin UART (hal/uart-port.ts): TX is poll-based with the construction baud
|
|
145
|
+
// applied once (guarded uart_configure); RX is interrupt-backed into a
|
|
146
|
+
// construction-sized ring (armed on first receive call). `ring` sizes the
|
|
147
|
+
// shim's static buffer and rides every RX op (self-contained-op discipline).
|
|
148
|
+
export function uartPollWrite(port, baud, data) { }
|
|
149
|
+
export function uartRxAvailable(port, ring) { return 0; }
|
|
150
|
+
export function uartRxPeek(port, ring) { return 0; }
|
|
151
|
+
export function uartRxRead(port, ring) { return 0; }
|
|
152
|
+
// Thin Thread (hal/thread.ts): create + schedule (k_thread_create, K_NO_WAIT).
|
|
153
|
+
// The handler is the callback-registered entry function name.
|
|
154
|
+
export function threadStart(index, stackBytes, priority, handler) { }
|
|
155
|
+
/** Thin Thread: block until exit (k_thread_join, K_FOREVER). */
|
|
156
|
+
export function threadJoin(index) { }
|
|
205
157
|
/** Resolve a board definition path to a compile-time constant. */
|
|
206
158
|
export function boardResolve(path) { return undefined; }
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
export function
|
|
214
|
-
|
|
215
|
-
export function
|
|
216
|
-
|
|
217
|
-
export function powerSetCpuFrequency(mhz) { }
|
|
218
|
-
/** Enter deep sleep until `pin` reaches `level` (pin wakeup). Architecture-aware:
|
|
219
|
-
* ext0 on Xtensa (RTC pins), gpio-wakeup on RISC-V. */
|
|
220
|
-
export function powerDeepSleepPin(pin, level) { }
|
|
159
|
+
export function fsReadText(path) { return ""; }
|
|
160
|
+
export function fsWriteText(path, content) { }
|
|
161
|
+
export function fsExists(path) { return false; }
|
|
162
|
+
export function fsRemove(path) { return false; }
|
|
163
|
+
export function mqttConnect(brokerUri, clientId) { return false; }
|
|
164
|
+
export function mqttOnMessage(handler) { }
|
|
165
|
+
export function mqttSubscribe(topic) { }
|
|
166
|
+
export function mqttPublish(topic, data) { }
|
|
167
|
+
export function mqttConnected() { return false; }
|
|
168
|
+
export function mqttDisconnect() { }
|
|
221
169
|
// ---------------------------------------------------------------------------
|
|
222
170
|
// Preferences (NVS-backed key/value store)
|
|
223
171
|
// ---------------------------------------------------------------------------
|
|
224
|
-
export function
|
|
225
|
-
export function
|
|
226
|
-
export function
|
|
227
|
-
export function
|
|
228
|
-
export function
|
|
229
|
-
export function
|
|
230
|
-
export function
|
|
231
|
-
export function
|
|
232
|
-
export function
|
|
233
|
-
export function
|
|
234
|
-
export function preferencesPutFloat(key, value) { }
|
|
235
|
-
export function preferencesGetFloat(key, defaultValue) { return 0; }
|
|
236
|
-
export function preferencesPutString(key, value) { }
|
|
237
|
-
export function preferencesGetString(key, defaultValue) { return ""; }
|
|
238
|
-
export function wifiConnect(ssid, password, timeoutMs) { return false; }
|
|
172
|
+
export function preferencesClear(ns) { }
|
|
173
|
+
export function preferencesRemove(ns, key) { }
|
|
174
|
+
export function preferencesPutInt(ns, key, value) { }
|
|
175
|
+
export function preferencesGetInt(ns, key, defaultValue) { return 0; }
|
|
176
|
+
export function preferencesPutBool(ns, key, value) { }
|
|
177
|
+
export function preferencesGetBool(ns, key, defaultValue) { return false; }
|
|
178
|
+
export function preferencesPutFloat(ns, key, value) { }
|
|
179
|
+
export function preferencesGetFloat(ns, key, defaultValue) { return 0; }
|
|
180
|
+
export function preferencesPutString(ns, key, value) { }
|
|
181
|
+
export function preferencesGetString(ns, key, defaultValue) { return ""; }
|
|
239
182
|
export function wifiConnectStart(ssid, password) { }
|
|
183
|
+
/** Join with the station's construction facts (the thin WiFi.join). */
|
|
184
|
+
export function wifiJoin(ssid, psk, security, channel, band, timeoutMs, ps, ipAddr, gateway, netmask) { return false; }
|
|
240
185
|
export function wifiDisconnect() { }
|
|
241
|
-
export function wifiStatus() { return 0; }
|
|
242
186
|
export function wifiIsConnected() { return false; }
|
|
243
187
|
export function wifiLocalIp() { return ""; }
|
|
244
188
|
export function wifiRssi() { return 0; }
|
|
245
|
-
export function wifiMac() { return
|
|
246
|
-
export function wifiSetHostname(name) { }
|
|
247
|
-
export function wifiSetStaticIp(ip, gateway, subnet, dns) { }
|
|
248
|
-
export function wifiSetAutoReconnect(enabled) { }
|
|
249
|
-
export function wifiSetPowerSave(mode) { }
|
|
250
|
-
export function wifiSetTxPower(dbm) { }
|
|
189
|
+
export function wifiMac() { return 0; }
|
|
251
190
|
export function wifiOnEvent(event, handler) { }
|
|
252
191
|
export function wifiApStart(ssid, password, channel, hidden, maxClients) { return false; }
|
|
253
192
|
export function wifiApStop() { }
|
|
254
|
-
export function wifiApClientCount() { return 0; }
|
|
255
|
-
export function wifiApIp() { return ""; }
|
|
256
|
-
export function wifiApSetChannel(channel) { }
|
|
257
|
-
export function wifiApSetHidden(hidden) { }
|
|
258
|
-
export function wifiApSetMaxClients(maxClients) { }
|
|
259
193
|
export function wifiScan() { return 0; }
|
|
260
|
-
export function wifiScanStart() { }
|
|
261
194
|
export function wifiScanCount() { return 0; }
|
|
262
195
|
export function wifiScanSsid(index) { return ""; }
|
|
263
196
|
export function wifiScanRssi(index) { return 0; }
|
|
264
|
-
export function wifiScanEncryption(index) { return
|
|
197
|
+
export function wifiScanEncryption(index) { return ""; }
|
|
265
198
|
export function wifiScanChannel(index) { return 0; }
|
|
266
|
-
export function wifiSaveCredentials(ssid, password) { }
|
|
267
|
-
export function wifiConnectSaved(timeoutMs) { return false; }
|
|
268
|
-
export function wifiClearCredentials() { }
|
|
269
|
-
export function wifiWaitConnected(timeoutMs) { return false; }
|
|
270
|
-
export function wifiWaitDisconnected() { }
|
|
271
199
|
// ---------------------------------------------------------------------------
|
|
272
200
|
// HTTP client
|
|
273
201
|
// ---------------------------------------------------------------------------
|
|
274
202
|
export function httpBegin(method, url) { }
|
|
275
|
-
export function httpReset() { }
|
|
276
203
|
export function httpSetHeader(name, value) { }
|
|
277
204
|
export function httpSetTimeout(ms) { }
|
|
278
205
|
export function httpSetMaxBody(bytes) { }
|
|
279
206
|
export function httpSetBody(data, json) { }
|
|
280
|
-
export function httpSetInsecure() { }
|
|
207
|
+
export function httpSetInsecure(insecure) { }
|
|
281
208
|
export function httpSetCaCert(pem) { }
|
|
282
209
|
export function httpSend() { return false; }
|
|
283
|
-
export function httpSendStart() { }
|
|
284
210
|
export function httpStatus() { return 0; }
|
|
285
211
|
export function httpOk() { return false; }
|
|
286
212
|
export function httpBody() { return ""; }
|
|
@@ -301,11 +227,6 @@ export function bleOnDisconnect(handler) { }
|
|
|
301
227
|
export function bleNotify(index, value) { }
|
|
302
228
|
export function bleIsConnected() { return false; }
|
|
303
229
|
export function bleClientCount() { return 0; }
|
|
304
|
-
export function bleSetName(name) { }
|
|
305
|
-
export function bleUntilConnected(timeoutMs) { return false; }
|
|
306
|
-
export function bleUntilConnectedStart() { }
|
|
307
|
-
export function bleSetTxPower(dbm) { }
|
|
308
|
-
export function bleStatus() { return 0; }
|
|
309
230
|
// ---------------------------------------------------------------------------
|
|
310
231
|
// Raw C++ escape hatch
|
|
311
232
|
// ---------------------------------------------------------------------------
|
|
@@ -327,3 +248,20 @@ export function rawCpp(code) { }
|
|
|
327
248
|
export function rawCppExpr(code) {
|
|
328
249
|
return undefined;
|
|
329
250
|
}
|
|
251
|
+
// ---------------------------------------------------------------------------
|
|
252
|
+
// Sensors — DT-bound peripheral parts (generic catalog)
|
|
253
|
+
//
|
|
254
|
+
// The part identity is a catalog token (SENSOR.<underscored-compatible> from
|
|
255
|
+
// sensor-catalog.generated.ts); the bus/address come from the I2CTarget the
|
|
256
|
+
// Sensor class was constructed with. Zephyr's uniform sensor API backs these —
|
|
257
|
+
// one code shape for every part in the catalog.
|
|
258
|
+
// ---------------------------------------------------------------------------
|
|
259
|
+
/** Fetch a fresh sample from a DT-bound sensor part. Args: part token, bus
|
|
260
|
+
* name, bus port (I2C address or SPI CS pin), bus kind ('i2c' | 'spi'),
|
|
261
|
+
* SPI clock Hz, SPI mode 0-3, alert pin (-1 = none). */
|
|
262
|
+
export function sensorFetch(part, bus, port, kind, spiHz, spiMode, alertPin) { }
|
|
263
|
+
/** Read one channel (a SENSOR_CHAN_* suffix, see CHAN) from the fetched sample.
|
|
264
|
+
* Returns the value as a double (Zephyr's sensor_value val1 + val2/1e6).
|
|
265
|
+
* Carries the same construction facts as sensorFetch so either op alone
|
|
266
|
+
* yields a complete device. */
|
|
267
|
+
export function sensorGet(part, bus, port, kind, spiHz, spiMode, alertPin, chan) { return 0; }
|
package/dist/fs.d.ts
CHANGED
|
@@ -1,33 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
* The semantic primitives (fsBegin / fsReadText / ...) are resolved to fs.*
|
|
10
|
-
* HAL ops by the transpiler's hal-plugins switch; this class is the
|
|
11
|
-
* ergonomic, type-checking surface.
|
|
12
|
-
*/
|
|
13
|
-
export declare class FSClass {
|
|
14
|
-
static readonly __instance_name = "FS";
|
|
15
|
-
/** Mount the filesystem. Returns true on success. */
|
|
16
|
-
begin(): boolean;
|
|
17
|
-
/** Read a UTF-8 text file into a string. Returns "" if the file is missing
|
|
18
|
-
* or unreadable. The returned buffer is caller-owned. */
|
|
19
|
-
readText(path: string): string;
|
|
20
|
-
/** Write a string to a file (overwrites). Silently no-ops if the file
|
|
1
|
+
export declare class File {
|
|
2
|
+
private readonly _path;
|
|
3
|
+
constructor(path: string);
|
|
4
|
+
/** Read the file as UTF-8 text. "" when missing/unreadable; the buffer is
|
|
5
|
+
* shim-owned until the next read. */
|
|
6
|
+
read(): string;
|
|
7
|
+
/** Overwrite the file with `content`. Silently no-ops when the file
|
|
21
8
|
* cannot be opened for writing. */
|
|
22
|
-
|
|
23
|
-
/** True if
|
|
24
|
-
exists(
|
|
25
|
-
/** Delete
|
|
26
|
-
remove(
|
|
9
|
+
write(content: string): void;
|
|
10
|
+
/** True if the file exists. */
|
|
11
|
+
exists(): boolean;
|
|
12
|
+
/** Delete the file. */
|
|
13
|
+
remove(): void;
|
|
27
14
|
}
|
|
28
|
-
export declare const FS: FSClass;
|
|
29
|
-
export declare function fsBegin(): void;
|
|
30
|
-
export declare function fsReadText(path: string): string;
|
|
31
|
-
export declare function fsWriteText(path: string, content: string): void;
|
|
32
|
-
export declare function fsExists(path: string): boolean;
|
|
33
|
-
export declare function fsRemove(path: string): boolean;
|
package/dist/fs.js
CHANGED
|
@@ -1,47 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// File — the thin persistent-file handle
|
|
3
|
+
//
|
|
4
|
+
// The path is the CONSTRUCTION fact; each verb maps 1:1 onto the Zephyr FS
|
|
5
|
+
// API (littlefs on the board's storage partition, mounted lazily on first
|
|
6
|
+
// use — there is no begin()/mount session):
|
|
7
|
+
//
|
|
8
|
+
// read() → the file's text ("" when missing/unreadable; the returned
|
|
9
|
+
// buffer lives in the shim until the next read)
|
|
10
|
+
// write(s) → overwrite the file (no-op when unwritable)
|
|
11
|
+
// exists() → the file is present
|
|
12
|
+
// remove() → delete the file
|
|
13
|
+
// ----------------------------------------------------------------------------
|
|
14
|
+
import { fsReadText, fsWriteText, fsExists, fsRemove, } from './emit.js';
|
|
15
|
+
export class File {
|
|
16
|
+
constructor(path) {
|
|
17
|
+
this._path = path;
|
|
18
18
|
}
|
|
19
|
-
/** Read
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
return fsReadText(
|
|
19
|
+
/** Read the file as UTF-8 text. "" when missing/unreadable; the buffer is
|
|
20
|
+
* shim-owned until the next read. */
|
|
21
|
+
read() {
|
|
22
|
+
return fsReadText(this._path);
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
24
|
+
/** Overwrite the file with `content`. Silently no-ops when the file
|
|
25
25
|
* cannot be opened for writing. */
|
|
26
|
-
|
|
27
|
-
fsWriteText(
|
|
26
|
+
write(content) {
|
|
27
|
+
fsWriteText(this._path, content);
|
|
28
28
|
}
|
|
29
|
-
/** True if
|
|
30
|
-
exists(
|
|
31
|
-
return fsExists(
|
|
29
|
+
/** True if the file exists. */
|
|
30
|
+
exists() {
|
|
31
|
+
return fsExists(this._path);
|
|
32
32
|
}
|
|
33
|
-
/** Delete
|
|
34
|
-
remove(
|
|
35
|
-
|
|
33
|
+
/** Delete the file. */
|
|
34
|
+
remove() {
|
|
35
|
+
fsRemove(this._path);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
FSClass.__instance_name = "FS";
|
|
39
|
-
export const FS = new FSClass();
|
|
40
|
-
// ── Semantic primitives (resolved to fs.* HAL ops by the transpiler) ──
|
|
41
|
-
// These are inert at runtime (tests, type-checking); the cuttlefish transpiler
|
|
42
|
-
// intercepts calls by name and lowers them to typed HAL op IR.
|
|
43
|
-
export function fsBegin() { }
|
|
44
|
-
export function fsReadText(path) { return ""; }
|
|
45
|
-
export function fsWriteText(path, content) { }
|
|
46
|
-
export function fsExists(path) { return false; }
|
|
47
|
-
export function fsRemove(path) { return false; }
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Pin } from './gpio.js';
|
|
2
|
+
export declare class GPIO {
|
|
3
|
+
static readonly INPUT = 1;
|
|
4
|
+
static readonly OUTPUT = 2;
|
|
5
|
+
/** Configure the output buffer's initial level atomically — no
|
|
6
|
+
* configure-then-write glitch window. */
|
|
7
|
+
static readonly OUTPUT_INIT_LOW = 4;
|
|
8
|
+
static readonly OUTPUT_INIT_HIGH = 8;
|
|
9
|
+
static readonly PULL_UP = 16;
|
|
10
|
+
static readonly PULL_DOWN = 32;
|
|
11
|
+
static readonly OPEN_DRAIN = 64;
|
|
12
|
+
static readonly OPEN_SOURCE = 128;
|
|
13
|
+
static readonly DISCONNECTED = 256;
|
|
14
|
+
static readonly INT_DISABLE = 1;
|
|
15
|
+
static readonly INT_EDGE_RISING = 2;
|
|
16
|
+
static readonly INT_EDGE_FALLING = 4;
|
|
17
|
+
static readonly INT_EDGE_BOTH = 8;
|
|
18
|
+
static readonly INT_LEVEL_LOW = 16;
|
|
19
|
+
static readonly INT_LEVEL_HIGH = 32;
|
|
20
|
+
private readonly _pin;
|
|
21
|
+
private readonly _flags;
|
|
22
|
+
/** Construct a configured pin. `flags` is a combination of the GPIO.*
|
|
23
|
+
* statics (the transpiler carries the token text; the values are for the
|
|
24
|
+
* editor only). The configure applies once, ahead of the first
|
|
25
|
+
* set/get/toggle/onInterrupt call. */
|
|
26
|
+
constructor(pin: number | Pin, flags: number);
|
|
27
|
+
/** Drive the pin (gpio_pin_set_dt / set_raw). Logical level: on a pin with
|
|
28
|
+
* a board dtSpec (LED, BUTTON), true means "active" — the DT node's
|
|
29
|
+
* GPIO_ACTIVE_LOW is honored. */
|
|
30
|
+
set(value: boolean): void;
|
|
31
|
+
/** Read the pin (gpio_pin_get_dt / get_raw). Logical level. The guarded
|
|
32
|
+
* configure is FUSED into the read's lowering (one statement-expression),
|
|
33
|
+
* so the pin is correctly configured even when the call sits in a pure
|
|
34
|
+
* expression position (if-conditions, comparisons) where a method's
|
|
35
|
+
* leading side-effect ops would otherwise be dropped. */
|
|
36
|
+
get(): boolean;
|
|
37
|
+
/** Toggle the pin (gpio_pin_toggle_dt — the driver's atomic toggle). */
|
|
38
|
+
toggle(): void;
|
|
39
|
+
/** Attach an interrupt (gpio_pin_interrupt_configure_dt +
|
|
40
|
+
* gpio_init_callback + gpio_add_callback). `intFlags` is one GPIO.INT_*
|
|
41
|
+
* token — Zephyr's names verbatim, covering the level modes the legacy
|
|
42
|
+
* onHigh/onLow strings could not express. */
|
|
43
|
+
onInterrupt(intFlags: number, handler: () => void): void;
|
|
44
|
+
/** Detach the interrupt (disable + remove callback). */
|
|
45
|
+
offInterrupt(): void;
|
|
46
|
+
}
|