Hi,
for some embedded code I am trying to create a macro that returns the correct register depending on a pin number. The register has different type. Is there a way to create a macro that returns a different "symbol" or instance depending on a range? In my non-working macro I am trying to do:
match $id {
0..=31 => (*pac::GPIO::ptr()).int0en.write(|p| p.[< gpio $id >]().bit(f)),
32..49= => (*pac::GPIO::ptr()).int1en.write(|p| p.[< gpio $id >]().bit(f)),
}
int0en and int1en are different types. Can I make a macro, e.g:
macro_rules! intreg {
($id:literal) => {
match $id {
0..=31 => 0
32..49 => 1
}
};
}
so that the match returns 0 or 1, and I can build the register string in the original macro?