Skip to main content

Crate embassy_neorv32

Crate embassy_neorv32 

Source
Expand description

§Embassy NEORV32 HAL

HALs implement safe, idiomatic Rust APIs to use the hardware capabilities, so raw register manipulation is not needed.

The embassy-neorv32 HAL targets the open-source NEORV32 RISC-V microcontroller and implements both blocking and async APIs/drivers for most of the peripherals. Additionally, async and blocking traits from embedded-hal are implemented where appropriate.

§Support

The HAL currently supports the following peripherals and features:

§Peripherals

  • SPI
  • TWI
  • GPIO
  • UART
  • DMA
  • PWM
  • TRNG
  • WDT
  • SYSINFO

§Additional Features

  • Dual-hart support
  • Embassy time-driver via CLINT mtimer

Additional peripheral support and features may be added if there is community interest!

§Usage

Please see the examples folder for ideas on how to use this HAL in your own projects.
To run these examples, follow these steps:

  • Install cargo-binutils
  • Modify build target in examples/.cargo/config.toml to match your configuration
  • Modify examples/memory.x to match the size of your configured DMEM and IMEM
  • Modify examples/Cargo.toml features sim and fpga such that the tick-hz feature for embassy-time matches your configuration
  • Modify UART_BAUD in examples/src/lib.rs to match your host UART
  • Clone neorv32 v1.12.8
  • In the cloned neorv32 folder, run cd sw/image_gen && gcc image_gen.c -o image_gen
  • Continue with one of the series of steps below depending on if running in simulation or on FPGA

§Simulation

  • Modify BASE in examples/run-sim to your neorv32 repo path (default in $HOME folder)
  • Install GHDL simulator
  • From examples folder, run cargo run-sim --release --bin hello-world
  • For more help, see simulating the processor

§FPGA over UART bootloader

  • Modify BASE in examples/run-fpga to your neorv32 repo path (default in $HOME folder)
  • Install picocom (or modify run-fpga to use your preferred tool)
  • From the examples folder, run cargo run-fpga --release --bin hello-world
  • Press reset button on FPGA
  • If using picocom, manually follow these steps within host terminal:
  • Type: Any key
  • Type: u (Upload)
  • Type: <Ctrl+A> <Ctrl+S> (send file)
  • Type: hello-world-fpga <Enter>
  • Wait for upload to complete (should see *** exit status: 0 *** OK)
  • Type: e (Execute)
  • For more help, see bootloader

§Version

This HAL targets NEORV32 v1.12.8. There is no guarantee it will work for different versions.

§References

Re-exports§

pub use neorv32_pac as pac;

Modules§

dma
Direct Memory Access (DMA)
gpio
General-Purpose Input/Output (GPIO)
interrupt
Interrupt definitions.
interrupts
Peripheral Interrupts
peripherals
Types for the peripheral singletons.
pwm
Pulse Width Modulation (PWM)
spi
Serial Peripheral Interface (SPI)
sysinfo
SysInfo
trng
True Random-Number Generator (TRNG)
twi
Two-Wire Interface (TWI)
uart
Universal Asynchronous Receiver and Transmitter (UART)
wdt
Watchdog Timer (WDT)

Macros§

bind_interrupts
Macro to bind interrupts to handlers.
interrupt_mod
Generate a standard mod interrupt for a RISC-V HAL.

Structs§

Peripherals
Struct containing all the peripheral singletons.

Functions§

init
Initialize the HAL. This must only be called from hart 0.