Expand description
Peripherals implementations.
Peripherals are the best way to create devices because they allow you to do it safely.
Both kinds of peripherals, Peripherals and DynamicPeripherals, guarantee that a given port is only used to create one device.
This is important because creating multiple devices on the same port can cause bugs and unexpected behavior.
Devices can still be created unsafely without using peripherals, but it isn’t recommended.
§Examples
§Using Peripherals
let mut peripherals = Peripherals::take().unwrap();
let motor = Motor::new(peripherals.port_1);
let adi_digital_in = AdiDigitalIn::new(peripherals.adi_d);§Using DynamicPeripherals
let mut peripherals = DynamicPeripherals::new(Peripherals::take().unwrap());
let motor = peripherals.take_smart_port(1).unwrap();
let adi_digital_in = peripherals.take_adi_port(4).unwrap();Structs§
- Guarantees that ports are only used once at runtime This is useful for when you want to store a peripherals struct for use in multiple functions. When possible, use
Peripheralsinstead. - Contains an instance of a brain’s available I/O, including ports, hardware, and devices.