Disasm / avatar-rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

avatar-rs

A proof-of-concept project aimed at prototyping embedded applications on a host.

Running the examples

You will need a NUCLEO-F042K6 board to run the examples for it.

Clone the repository:

git clone --recursive https://github.com/Disasm/avatar-rs
cd avatar-rs

Connect your NUCLEO-F042K6 with a USB cable.

Run the blinky example:

cd examples-nucleo-f042k6
cargo run --example blinky

See also serial_hello and i2c_bme280 examples.

Porting to the different families

Peripheral access crates don't require any changes if generated with svd2rust 0.16.1

HAL crates require changes if they use the following constructions.

volatile_read/volatile_write

All the volatile memory accesses should be replaced with calls to the VolatileCell methods.

For example,

unsafe { ptr::read_volatile(&self.spi.dr as *const _ as *const u8) }

should be replaced with

unsafe { (*(&self.spi.dr as *const _ as *const vcell::VolatileCell<u8>)).get() }

and

unsafe { ptr::write_volatile(&self.spi.dr as *const _ as *mut u8, byte) }

should be replaced with

unsafe { (*(&self.spi.dr as *const _ as *const vcell::VolatileCell<u8>)).set(byte) }

About


Languages

Language:Rust 98.8%Language:GDB 0.7%Language:RPC 0.5%