Expand description
Minimal hardware abstraction for IoT hosts.
Host firmware implements these traits and registers matching FFI callbacks. The simulated implementation below is used for desktop demos and tests.
Structs§
- Simulated
Hal - Desktop/simulator HAL: 32 virtual GPIO pins + a tick counter for delay. PWM duty/freq tables, UART loopback buffers, and I2C/SPI echo devices.
Traits§
Functions§
- builtin_
adc_ read adc_read(channel)鈫?int raw- builtin_
delay_ ms delay_ms(ms)鈥?simulated; advances the HAL clock only.- builtin_
gpio_ read gpio_read(pin)鈫?bool- builtin_
gpio_ write gpio_write(pin, high)鈥?pin: int, high: bool- builtin_
i2c_ xfer i2c_xfer(addr, hexdata, rlen)鈫?hex string ofrlenresponse bytes.- builtin_
pwm_ freq pwm_freq(pin, hz)- builtin_
pwm_ write pwm_write(pin, duty)鈥?duty is 16-bit (0..=65535).- builtin_
spi_ xfer spi_xfer(addr, hexdata, rxlen)鈫?hex string ofrxlenresponse bytes.- builtin_
uart_ read uart_read(port, n)鈫?string of up tonbytes (UTF-8 lossy).- builtin_
uart_ write uart_write(port, s)鈥?writes UTF-8 bytes ofs(looped back in sim).- sim_
drive_ pin - Test/demo helper: force an external pin level.
- sim_
elapsed_ ms - Test/demo helper: read simulated elapsed ms.
- sim_
i2c_ last_ write - Test/demo helper: last I2C write payload for
addr. - sim_
pwm_ duty - Test/demo helper: PWM duty currently programmed on
pin. - sim_
pwm_ freq - Test/demo helper: PWM frequency currently programmed on
pin. - sim_
set_ adc - Test/demo helper: inject a simulated ADC reading.