pub struct Peripherals {Show 32 fields
pub display: Display,
pub primary_controller: Controller,
pub partner_controller: Controller,
pub port_1: SmartPort,
pub port_2: SmartPort,
pub port_3: SmartPort,
pub port_4: SmartPort,
pub port_5: SmartPort,
pub port_6: SmartPort,
pub port_7: SmartPort,
pub port_8: SmartPort,
pub port_9: SmartPort,
pub port_10: SmartPort,
pub port_11: SmartPort,
pub port_12: SmartPort,
pub port_13: SmartPort,
pub port_14: SmartPort,
pub port_15: SmartPort,
pub port_16: SmartPort,
pub port_17: SmartPort,
pub port_18: SmartPort,
pub port_19: SmartPort,
pub port_20: SmartPort,
pub port_21: SmartPort,
pub adi_a: AdiPort,
pub adi_b: AdiPort,
pub adi_c: AdiPort,
pub adi_d: AdiPort,
pub adi_e: AdiPort,
pub adi_f: AdiPort,
pub adi_g: AdiPort,
pub adi_h: AdiPort,
}
Expand description
Singleton Peripheral Access
Contains an instance of a Brain’s available I/O, including ports, hardware, and devices.
A Brain often has many external devices attached to it. We call these devices peripherals, and this
struct is the “gateway” to all of these. Peripherals
is intended to be used as a singleton, and you
will typically only get one of these in your program’s execution. This guarantees at compile time that
each port is only used once.
Because of the fact that this checks at compile time, it cannot be copied, cloned, or moved once it has been used to create a device.
If you need to store a peripherals struct for use in multiple functions, use DynamicPeripherals
instead.
This struct is always preferrable to DynamicPeripherals
when possible.
Fields§
§display: Display
Brain display
primary_controller: Controller
Primary (“Master”) Controller
partner_controller: Controller
Partner Controller
port_1: SmartPort
Smart Port 1 on the Brain
port_2: SmartPort
Smart Port 2 on the Brain
port_3: SmartPort
Smart Port 3 on the Brain
port_4: SmartPort
Smart Port 4 on the Brain
port_5: SmartPort
Smart Port 5 on the Brain
port_6: SmartPort
Smart Port 6 on the Brain
port_7: SmartPort
Smart Port 7 on the Brain
port_8: SmartPort
Smart Port 8 on the Brain
port_9: SmartPort
Smart Port 9 on the Brain
port_10: SmartPort
Smart Port 10 on the Brain
port_11: SmartPort
Smart Port 11 on the Brain
port_12: SmartPort
Smart Port 12 on the Brain
port_13: SmartPort
Smart Port 13 on the Brain
port_14: SmartPort
Smart Port 14 on the Brain
port_15: SmartPort
Smart Port 15 on the Brain
port_16: SmartPort
Smart Port 16 on the Brain
port_17: SmartPort
Smart Port 17 on the Brain
port_18: SmartPort
Smart Port 18 on the Brain
port_19: SmartPort
Smart Port 19 on the Brain
port_20: SmartPort
Smart Port 20 on the Brain
port_21: SmartPort
Smart Port 21 on the Brain
adi_a: AdiPort
Adi port A on the Brain.
adi_b: AdiPort
Adi port B on the Brain.
adi_c: AdiPort
Adi port C on the Brain.
adi_d: AdiPort
Adi port D on the Brain.
adi_e: AdiPort
Adi port E on the Brain.
adi_f: AdiPort
Adi port F on the Brain.
adi_g: AdiPort
Adi port G on the Brain.
adi_h: AdiPort
Adi port H on the Brain.
Implementations§
Source§impl Peripherals
impl Peripherals
Sourcepub fn take() -> Option<Self>
pub fn take() -> Option<Self>
Attempts to create a new Peripherals
struct, returning None
if one has already been created.
After calling this function, future calls to Peripherals::take
will return None
.
Sourcepub unsafe fn steal() -> Self
pub unsafe fn steal() -> Self
Creates a new Peripherals
struct without ensuring that is the only unique instance.
After calling this function, future calls to Peripherals::take
will return None
.
§Safety
Creating new SmartPort
s and Peripherals
instances is unsafe due to the possibility of constructing
more than one device on the same port index.
The caller must ensure that a given peripheral is not mutated concurrently as a result of more than one instance existing.