Macro feather_m4::periph_alias

source ·
macro_rules! periph_alias {
    ($peripherals:ident . spi_sercom) => { ... };
    ($peripherals:ident . i2c_sercom) => { ... };
    ($peripherals:ident . uart_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:

  • SERCOM1 can be refered to with the type alias SpiSercom and accessed as the field name spi_sercom
  • SERCOM2 can be refered to with the type alias I2cSercom and accessed as the field name i2c_sercom
  • SERCOM5 can be refered to with the type alias UartSercom and accessed as the field name uart_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);