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 alias UartSercom and accessed as the field name uart_sercom
  • SERCOM3 can be refered to with the type alias I2cSercom and accessed as the field name i2c_sercom
  • SERCOM4 can be refered to with the type alias SpiSercom and accessed as the field name spi_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);