Macro feather_m0::periph_alias
source · macro_rules! periph_alias { ($peripherals:ident . uart_sercom) => { ... }; ($peripherals:ident . i2c_sercom) => { ... }; ($peripherals:ident . spi_sercom) => { ... }; }
Expand description
Refer to fields of the Peripherals
struct by alternate names
This macro can be used to access fields of the Peripherals
struct by alternate names. The available aliases are:
SERCOM0
can be refered to with the type aliasUartSercom
and accessed as the field nameuart_sercom
SERCOM3
can be refered to with the type aliasI2cSercom
and accessed as the field namei2c_sercom
SERCOM4
can be refered to with the type aliasSpiSercom
and accessed as the field namespi_sercom
For example. suppose display_spi
were an alternate name for
the SERCOM4
peripheral. You could use the periph_alias!
macro to access it like this:
let mut peripherals = pac::Peripherals::take().unwrap();
// Replace this
let display_spi = peripherals.SERCOM4;
// With this
let display_spi = periph_alias!(peripherals.display_spi);