Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/embedded/hal/fake"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
hal |
std/embedded/hal |
fake.dodo |
option |
core/option |
fake.dodo |
Pin
Struct · Source
An output and input pin. It starts low.
pub struct Pin {
// Private implementation fields omitted.
}
Pin.new
Function · Source
pub fn new() -> Pin
Pin.set_high
Function · Source
pub fn set_high(&mut self)
Pin.set_low
Function · Source
pub fn set_low(&mut self)
Pin.is_high
Function · Source
pub fn is_high(&self) -> bool
Pin.changes
Function · Source
Number of level changes so far, for example 2 per blink.
pub fn changes(&self) -> u32
Delay
Struct · Source
A delay that returns immediately and adds up the requested time.
pub struct Delay {
// Private implementation fields omitted.
}
Delay.new
Function · Source
pub fn new() -> Delay
Delay.delay_us
Function · Source
pub fn delay_us(&mut self, microseconds: u32)
Delay.elapsed_us
Function · Source
pub fn elapsed_us(&self) -> u64
I2c
Struct · Source
One I2C device with 256 numbered 8-bit registers, the layout used by most sensors. A write sets the register pointer from its first byte and stores any following bytes at successive registers; a read continues from the pointer. Other addresses report NoAcknowledge.
pub struct I2c {
// Private implementation fields omitted.
}
I2c.new
Function · Source
pub fn new(address: u8) -> I2c
I2c.register
Function · Source
pub fn register(&self, index: u8) -> u8
I2c.set_register
Function · Source
pub fn set_register(&mut self, index: u8, value: u8)
I2c.fail_next
Function · Source
Make the next transaction fail with
error, for testing error paths.
pub fn fail_next(&mut self, error: hal.Error)
I2c.write
Function · Source
pub fn write(&mut self, address: u8, bytes: &[u8]) -> void!hal.Error
I2c.read
Function · Source
pub fn read(&mut self, address: u8, buffer: &mut[u8]) -> void!hal.Error
I2c.write_read
Function · Source
pub fn write_read(&mut self, address: u8, bytes: &[u8], buffer: &mut[u8]) -> void!hal.Error
Spi
Struct · Source
An SPI bus that records the most recent 64 bytes sent and answers each byte from a programmed reply, then with zeros.
pub struct Spi {
// Private implementation fields omitted.
}
Spi.new
Function · Source
pub fn new() -> Spi
Spi.reply_with
Function · Source
Bytes the device answers with, in order. At most 64.
pub fn reply_with(&mut self, bytes: &[u8])
Spi.sent
Function · Source
Bytes sent since the last call to
clear, up to the first 64.
pub fn sent(&self) -> &[u8]
Spi.clear
Function · Source
pub fn clear(&mut self)
Spi.transfer
Function · Source
pub fn transfer(&mut self, bytes: &mut[u8]) -> void!hal.Error
Spi.write
Function · Source
pub fn write(&mut self, bytes: &[u8]) -> void!hal.Error