Skip to main content

Examples

Every wrapped peripheral has a minimal reference example. Each example carries a board.yaml, an annotated src/main.c, and a boards/ overlay directory — they double as tutorials. Comment density is ~50 % so the source teaches by itself.

Browse the full tree at alp-sdk/examples.

Build any example

cd alp-workspace
west alp-build -b native_sim/native/64 alp-sdk/examples/<name>
west build -d build -t run # native_sim
# or:
west flash # real silicon

On native_sim most peripherals don't have emul controllers (only I²C / SPI / GPIO / UART do). Examples that target unwrapped peripherals exit after printing alp_last_error() — that's expected and proves the wrapper plumbing compiles + links cleanly.

Cross-family examples

Work on any conformant SoM. Pick som.sku to match your hardware.

ExampleWhat it shows
GPIO Button + LEDGPIO open + input/output basics
I²C ScannerWalk an I²C bus, report ACK'ing devices
PWM LED FadePWM channel open + duty sweep
ADC VoltmeterADC sample + millivolt conversion
DAC WaveformDAC sine generation (native DAC12 / GD32-bridged DAC0)
SPI LoopbackSPI master TX/RX loopback
UART EchoUART TX + RX echo
UART RX Ring BufferInterrupt-driven UART RX with byte-granular ring buffer
Counter + AlarmCounter open + alarm callback
Quadrature Encoder ReadoutQuadrature-encoder position read
RTC ClockSet + read SoC RTC
Watchdog FeedWatchdog open + feed cadence
CAN LoopbackCAN frame send + receive in loopback
I²S ToneI²S sine-tone playback
Audio LoopbackPDM mic in → I²S speaker out
Multi-Proc MailboxM55-HP / M55-HE mailbox round-trip on AEN (both peer images ship)
USB Host StorageUSB mass-storage host via <alp/usb.h> — build-verified on AEN401, xHCI bring-up bench-gated

V2N-specific examples

Exercise the V2N's on-module GD32 bridge + dual Ethernet + secure element.

ExampleWhat it shows
GD32 Bridge PingContinuous PING + GET_VERSION liveness over the 25 MHz SPI fast path
Board ID ReadoutRead SoM EEPROM manifest + assert SKU
EEPROM Manifest DumpHexdump + decode the 128-byte EEPROM manifest
Dual Ethernet Bring-upBring up both RTL8211FDI PHYs; WoL configuration
RTC Multi-AlarmMulti-source callbacks on the RV-3028-C7 dispatcher
Temperature SensorTMP112 read loop
PWM Fan ControlRamp a GD32-side PWM channel along a fan curve
Secure-Element SignOPTIGA Trust M ECDSA-P256 sign via raw APDU
xSPI NOR Read/WriteErase + write + verify on the on-module xSPI NOR
eMMC Block StatRead on-module eMMC geometry
GD32 SWD FlashHost-driven SWD bit-bang — bridge firmware recovery
GD32 Bridge HIL SoakFull-command-set pass/fail soak of the bridge (silicon-validated)
BRD_I2C Bring-upRead-only scan + probe of all 8 management-bus ICs
Power MonitorLive per-rail power table from the EVK's INA236 monitors (A55/Yocto user space, EVK-only)

AEN-specific examples

The v0.7 on-silicon bring-up of the E1M-AEN801 (Alif Ensemble E8) shipped a full bench suite — 15/17 aen-* apps PASS on real hardware. See E1M-AEN bench status.

ExampleWhat it shows
EdgeAI Vision (AEN)Camera → ISP → Ethos-U inference → OLED overlay
NPU Inference (Ethos-U85)Vela int8 model on the Ethos-U85; real person_detect MobileNet from MRAM (PASS)
CC3501E Bring-upPower + PING the TI CC3501E Wi-Fi/BLE bridge over inter-chip SPI
Ethernet LinkE8 GMAC up + DHCP lease (bench-verified; DMA buffers in SRAM0)
Analog ValidateDAC0 → ADC loopback with corrected E8 references (PASS)
EEPROM ManifestRead + decode the 128-byte SoM manifest over SoC I²C2
Dual-Core Boot & IPCBoot both M55 cores; HE↔HP doorbell + shared-memory round-trips
Dual-Core RPC / RPMsgOpenAMP RPMsg pingpong over MHUv2 (16/16 PASS)
Secure-Element SignOPTIGA Trust M ECDSA-P256 sign over LPI2C0
Peripheral RegchecksOn-silicon CRC / DMA / HWSEM / CMP / LPTIMER / LPRTC driver smoke tests

More AEN bench apps live in the SDK tree at examples/aen/ — audio (aen-pdm-mic-alif, aen-i2s-amp-alif), aen-sdcard-readout, aen-qenc-readout, aen-rtc-calendar, aen-mcuboot-smoke, aen-aipm-read, and the dual-core probes.

Application demos (v0.5 showcase, [UNTESTED])

End-to-end demos that combine multiple chip drivers + library knobs + LVGL UIs. All marked [UNTESTED] — they compile and pass smoke tests, HiL bring-up arrives in v0.6 / v0.8.

Edge AI

DemoWhat it shows
AI Camera ViewerOV5640 → Ethos-U person-detect → LVGL bbox overlay (AEN)
Realtime Object DetectionOV5640 → DEEPX DX-M1 YOLOv8-tiny → LVGL overlay (V2N-M1)
Vibration Anomaly DetectionLSM6DSO vibration window → 1D-CNN anomaly score (AEN)

Edge AI — sensing & predictive maintenance (v0.9)

New verticals added in v0.9. Each ships DSP feature cores host-unit-tested on native_sim, a model stub with a deterministic fallback (no trained model shipped), and HiL bench-gated. Same source flips som.sku to E1M-V2M101 for the DEEPX DX-M1 path.

DemoWhat it shows
Visual Defect DetectionCSI camera → autoencoder reconstruction-error surface anomaly → PASS/FAIL (AEN)
Cold-Chain MonitorBME280 → MKT / dewpoint / excursion metrics → 4-state integrity classifier
Multimodal Fusion PdMVibration + current + temperature fused → cross-modal fault hypothesis
Motor Current SignatureINA236 DC current window → 5-state motor classifier (OFF/NORMAL/INRUSH/OVERLOAD/STALL)
Wearable Activity + FallICM-42670 IMU → activity classifier + rule-based 3-phase fall detector
Rail Predictive MaintenanceICM-42670 vibration + NEO-M9N GNSS → geotagged rail-defect survey, one CSV/25 m

Audio AI

DemoWhat it shows
Wake-Word ("Hey Alp")Always-on KWS on AEN's low-power AI subsystem; ~1 mW continuous
Noise SuppressionReal-time spectral denoise (V2N) — headset / hearable / conferencing
Acoustic Safety EventsPDM mic → per-frame DSP → 4-class event classifier (AMBIENT/GLASS_BREAK/ALARM/SCREAM)
Acoustic Anomaly (Wind Turbine)Nacelle mic → rotor-order normalised anomaly score at blade-pass harmonics

Drone

DemoWhat it shows
Drone HUDIMU + GNSS + battery + ST7789 attitude HUD with LVGL
Drone AutopilotPID-stabilised quadcopter flight controller (cascaded 1 kHz / 250 Hz / 25 Hz loops)

IoT

DemoWhat it shows
IoT DashboardBME280 → MQTT/TLS publish + local LVGL dashboard
IoT Fleet OTAMender + MCUboot + OPTIGA-pinned ECDSA-P256 signed updates
Firmware Update LogTamper-evident, hash-chained firmware-update audit log (portable)

LVGL UI

DemoWhat it shows
LVGL Widgets DemoHeadline LVGL widget showcase on ST7789
LVGL BenchmarkPer-scene FPS comparison across SoMs — reveals what GPU2D / DMA2D buy you per SKU
LVGL Music PlayerLVGL UI + WM8960 codec + minimp3 decoder

Heterogeneous-compute (v0.6 flagships)

One board.yaml, one orchestrator pass, two OSes — A-class Yocto + M-class Zephyr on the same SoM, talking through framed RPMsg via <alp/rpc.h>. Walkthrough at Heterogeneous Builds.

DemoWhat it shows
rpmsg-v2nV2N101 A55 (Yocto) ↔ M33-SM (Zephyr) pub/sub over RPMsg
rpmsg-aenAEN701 A32 (Yocto) ↔ M55-HP (Zephyr) with cacheable carve-out
rpmsg-imx93iMX93 A55 (Yocto) ↔ M33 (Zephyr)
heterogeneous-offloadA55 delegates FFT to the M33-SM peer via synchronous alp_rpc_call

End-to-end reference applications

ApplicationStack
EdgeAI Vision (AEN)Camera capture → ISP → Ethos-U inference → on-board OLED
IoT Connected CameraCamera capture → DRP-AI inference → MQTT/TLS publish + LVGL UI
Production DeploymentThe v1.0 integration flagship — factory provisioning → secure boot → OTA → remote attestation

All three follow the same board.yaml workflow at a larger scale.

See also

Questions about this page? Discuss in Community Forum