pub struct AvrTesterBuilder { /* private fields */ }
Implementations§
Source§impl AvrTesterBuilder
impl AvrTesterBuilder
Sourcepub fn new(mcu: impl ToString) -> Self
pub fn new(mcu: impl ToString) -> Self
Creates AvrTesterBuilder
.
To avoid typos, it’s preferred that you use helper functions such as
AvrTester::atmega328p()
- this constructor is provided just in case.
Sourcepub fn with_clock(self, clock: u32) -> Self
pub fn with_clock(self, clock: u32) -> Self
Specifies AVR’s clock.
This value doesn’t affect how fast the simulation is run - it’s used
mostly so that AvrTester::run_for_s()
and similar functions know how
long a second, a millisecond etc. should be.
See:
Sourcepub fn with_clock_of_1_mhz(self) -> Self
pub fn with_clock_of_1_mhz(self) -> Self
See: Self::with_clock()
.
Sourcepub fn with_clock_of_4_mhz(self) -> Self
pub fn with_clock_of_4_mhz(self) -> Self
See: Self::with_clock()
.
Sourcepub fn with_clock_of_8_mhz(self) -> Self
pub fn with_clock_of_8_mhz(self) -> Self
See: Self::with_clock()
.
Sourcepub fn with_clock_of_12_mhz(self) -> Self
pub fn with_clock_of_12_mhz(self) -> Self
See: Self::with_clock()
.
Sourcepub fn with_clock_of_16_mhz(self) -> Self
pub fn with_clock_of_16_mhz(self) -> Self
See: Self::with_clock()
.
Sourcepub fn with_clock_of_20_mhz(self) -> Self
pub fn with_clock_of_20_mhz(self) -> Self
See: Self::with_clock()
.
Sourcepub fn with_clock_of_24_mhz(self) -> Self
pub fn with_clock_of_24_mhz(self) -> Self
See: Self::with_clock()
.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Specifies a timeout (in AVR’s time¹) after which calling
AvrTester::run()
(or a similar function) will panic, aborting the
test to signal that it has timed out.
This might come handy in tests that wait for AVR to do something:
let mut avr = AvrTester::atmega328p()
.with_clock_of_16_mhz()
.with_timeout_of_s(1)
.load("...");
while avr.pins().pb1().is_low() {
avr.run_for_ms(1);
}
/* do something else later */
… as otherwise, without specifying the timeout, if the tested firmware misbehaves (and e.g. doesn’t toggle the expected pin), the test would be running in an infinite loop (instead of failing).
¹ using AVR’s time instead of the host’s time allows to assert this reliably - whatever timeout you set here will be consistent across all machines.
Sourcepub fn with_timeout_of_s(self, s: u64) -> Self
pub fn with_timeout_of_s(self, s: u64) -> Self
Specifies a timeout in seconds (of AVR’s time).
See: Self::with_timeout()
.
Sourcepub fn with_timeout_of_ms(self, ms: u64) -> Self
pub fn with_timeout_of_ms(self, ms: u64) -> Self
Specifies a timeout in milliseconds (of AVR’s time).
See: Self::with_timeout()
.
Sourcepub fn with_timeout_of_us(self, us: u64) -> Self
pub fn with_timeout_of_us(self, us: u64) -> Self
Specifies a timeout in microseconds (of AVR’s time).
See: Self::with_timeout()
.