MoonBit Microcontroller Hardware Abstraction Layer & Simulation Suite
| Package | Purpose |
|---|---|
| types, errors | Shared hardware types and error taxonomy |
| gpio, uart, spi, i2c | Core digital and serial peripherals |
| pwm, adc, timer, rtc, dma | Timing, analog, and transfer peripherals |
| lock, rtos | Resource protection and cooperative scheduling |
| sim, bsp | Deterministic virtual hardware and board support |
| stm32, rp2040, esp32 | Vendor-family register adapters |
| dts, registers | Device-tree descriptors and register transactions |
| codec, protocol, collections | Binary transport and embedded data structures |
| sensors, display, control, telemetry | Application-facing embedded building blocks |
| storage, flash, memory | Persistence, flash behavior, and predictable allocation |
| power, diagnostics, boot, security | Reliability and product lifecycle services |
| board, network, usb, time, utils | Integration and low-level helpers |
moon version
moon check --deny-warn
moon test --deny-warn
moon run src/mainlet clock = @clock_delay.HalClock::default_clock()
let delay = @clock_delay.HalDelay::new(clock)
delay.delay_ms(10)
let pin = @types.PinSpec::default_pin(@types.PortId::PortA, 5)
let gpio = @gpio.GpioPin::new(@gpio.GpioConfig::default_output(pin))
let _ = gpio.set_high()
let eeprom = @sim.At24c02Eeprom::attach(
@i2c.I2cMaster::new(@i2c.I2cConfig::default_config()),
@i2c.I2cAddress::Addr7Bit(0x50),
)
let _ = eeprom.write_byte(0x10, (0x77 : Byte))
let value = eeprom.read_byte(0x10).unwrap()
println(value.to_int().to_string())moon fmt --check
moon check --deny-warn
moon info
git diff --exit-code
moon test --deny-warn
moon test --target native --deny-warn
moon test --enable-coverage --deny-warn
moon coverage report -f summary
moon coverage analyzemoon run src/benchiterations=1000 payload_bytes=256
crc16_elapsed_us=0 checksum=0
cobs_elapsed_us=0 encoded_bytes=257000
queue_elapsed_us=0 remaining=0$source = Get-ChildItem -Recurse src -Filter *.mbt |
Where-Object { $_.Name -notlike '*_test.mbt' }
$source | Get-Content | Measure-Object -Linemoon publishMoonBit Microcontroller Hardware Abstraction Layer & Simulation Suite