Ports and Pins
In computer programming a port is a communication endpoint. It completes the destination or origination network address of a message. Specific port numbers are reserved to identify specific services so that an arriving packet can be easily forwarded to a running application.
Every microcontroller has pins in it to attach power connections, input and output connections, and communications connections. Every microcontroller has different configurations for its pins, and often one pin will have more than one function.
Pins are grouped into ports, and all of a pin’s settings are controlled from the port’s register block. We’d like each pin to be a self-contained struct, so that ownership of it can be passed from one software module to another, and only the owning module can mutate its pins. This follows Rust’s one-owner rule for pins, but would require that each pin be able to mutate its settings in the Port register block.
#
Struct DefinitionsPort represents a struct containing the register definition for a Port.
Pin represents struct corresponding to a pin
#
Trait Implementationsnew
for Port
#
Impl Return a struct containing register definition of the Port.
set_pin_mode
for Port
#
Impl Sets the pin mode, given the pin and requested mode.
pin
for Port
#
Impl Returns a pin struct for given pin.
name
for Port
#
Impl Returns Port struct with the corresponding port address.
make_gpio
for Pin
#
Impl Sets pin to GPIO mode