Macro for_each_analog_function

Source
macro_rules! for_each_analog_function {
    ($($pattern:tt => $code:tt;)*) => { ... };
}
Available on crate feature _device-selected only.
Expand description

This macro can be used to generate code for each analog function of each GPIO.

For an explanation on the general syntax, as well as usage of individual/repeated matchers, refer to the crate-level documentation.

This macro has two options for its “Individual matcher” case:

  • all: ($signal:ident, $gpio:ident) - simple case where you only need identifiers
  • all_expanded: (($signal:ident, $group:ident $(, $number:literal)+), $gpio:ident) - expanded signal case, where you need the number(s) of a signal, or the general group to which the signal belongs. For example, in case of ADC2_CH3 the expanded form looks like (ADC2_CH3, ADCn_CHm, 2, 3).

Macro fragments:

  • $signal: the name of the signal.
  • $group: the name of the signal, with numbers replaced by placeholders. For ADC2_CH3 this is ADCn_CHm.
  • $number: the numbers extracted from $signal.
  • $gpio: the name of the GPIO.

Example data:

  • (ADC2_CH5, GPIO12)
  • ((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12)

The expanded syntax is only available when the signal has at least one numbered component.