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
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)

V2N-specific examples

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

ExampleWhat it shows
GD32 Bridge PingPING + GET_VERSION on both SPI + I²C transports
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

AEN-specific examples

ExampleWhat it shows
EdgeAI Vision (AEN)Camera → Ethos-U inference → OLED overlay

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)

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

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

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 v2, 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