Crate avr_tester

Source
Expand description

Framework for testing AVR binaries, powered by simavr:

use avr_tester::*;

// Assuming `firmware` implements a ROT-13 encoder:

#[test]
fn test() {
    let mut avr = AvrTester::atmega328p()
        .with_clock_of_16_mhz()
        .load("../../firmware/target/avr-none/release/firmware.elf");

    // Let's give our firmware a moment to initialize:
    avr.run_for_ms(1);

    // Now, let's send the string:
    avr.uart0().write("Hello, World!");

    // ... give the AVR a moment to retrieve it & send back, encoded:
    avr.run_for_ms(1);

    // ... and, finally, let's assert the outcome:
    assert_eq!("Uryyb, Jbeyq!", avr.uart0().read::<String>());
}

See more: <../tests/examples>.

Structs§

AnalogPin
Provides access to an analog pin, e.g. ADC1.
AnalogPinAsync
Asynchronous equivalent of AnalogPin.
AvrDuration
Like std::time::Duration, but in AVR cycles; somewhat approximate¹.
AvrTester
The Tester; use AvrTester::atmega328p() etc. to construct it.
AvrTesterAsync
Asynchronous equivalent of AvrTester.
AvrTesterBuilder
ComponentHandle
Components
Manages components.
DigitalPin
Provides access to a digital pin, e.g. PD4.
DigitalPinAsync
Asynchronous equivalent of DigitalPin.
Pins
Provides access to analog and digital pins.
PinsAsync
Asynchronous equivalent of Pins.
Spi
Provides access to the SPI.
SpiAsync
Asynchronous equivalent of Spi.
Twi
Provides access to the TWI (aka I2C).
TwiPacket
TwiSlaveId
Uart
Provides access to the UART.
UartAsync
Asynchronous equivalent of Uart.

Enums§

ComponentState

Traits§

AvrDurationExt
IntoCycles
Readable
Value that can be retrieved from a Reader.
Reader
Object that can be read from, e.g. crate::Uart.
ReaderHelper
TwiSlave
Writable
Value that can be transmitted through a Writer.
Writer
Object that can be written to, e.g. crate::Uart.
WriterHelper

Functions§

avr_rt
Returns AvrTesterAsync for usage inside components.