Macro grand_central_m4::periph_alias
source · macro_rules! periph_alias { ($peripherals:ident . uart_sercom) => { ... }; ($peripherals:ident . uart_sercom2) => { ... }; ($peripherals:ident . uart_sercom3) => { ... }; ($peripherals:ident . i2c_sercom) => { ... }; ($peripherals:ident . i2c_sercom2) => { ... }; ($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
SERCOM1
can be refered to with the type aliasUartSercom2
and accessed as the field nameuart_sercom2
SERCOM5
can be refered to with the type aliasUartSercom3
and accessed as the field nameuart_sercom3
SERCOM3
can be refered to with the type aliasI2cSercom
and accessed as the field namei2c_sercom
SERCOM6
can be refered to with the type aliasI2cSercom2
and accessed as the field namei2c_sercom2
SERCOM7
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);