Created
June 7, 2020 00:00
-
-
Save thalesfragoso/701cd875a0229e98d87ab627e8549469 to your computer and use it in GitHub Desktop.
PPI macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! ppi { | |
( | |
not_fixed: [ $( | |
$(#[$attr:meta])? | |
($ppix:ident, $PpixType:ident, $ch:expr),)+ | |
], | |
fixed: [$(($ppix_fixed:ident, $PpixTypeFixed:ident, $ch_fixed:expr),)+], | |
) => { | |
$( | |
$(#[$attrs])? | |
pub struct $PpixType { | |
_private: (), | |
} | |
$(#[$attrs])? | |
impl Channel for $PpixType { | |
const CH: usize = $ch; | |
} | |
$(#[$attrs])? | |
impl NotFixed for $PpixType {} | |
)+ | |
$( | |
pub struct $PpixTypeFixed { | |
_private: (), | |
} | |
impl Channel for $PpixTypeFixed { | |
const CH: usize = $ch_fixed; | |
} | |
)+ | |
pub struct Parts { | |
$( | |
$(#[$attrs])? | |
pub $ppix: $PpixType, | |
)+ | |
$( | |
pub $ppix_fixed: $PpixTypeFixed, | |
)+ | |
} | |
impl Parts { | |
pub fn new(_regs: PPI) -> Self { | |
Self { | |
$( | |
$(#[$attrs])? | |
$ppix: $PpixType { | |
_private: (), | |
}, | |
)+ | |
$( | |
$ppix_fixed: $PpixTypeFixed { | |
_private: (), | |
}, | |
)+ | |
} | |
} | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment