Created
April 14, 2014 13:24
-
-
Save pczarn/10647559 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
enum GPIO { | |
GPIO0, | |
GPIO1, | |
} | |
static GPIO0_ADDR: *mut Regs = 0xDEADBEEF as *mut Regs; | |
static GPIO1_ADDR: *mut Regs = 0xBEEFDEAD as *mut Regs; | |
impl GPIO { | |
fn get_addr(self) -> *mut Regs { | |
match self { | |
GPIO0 => GPIO0_ADDR, | |
GPIO1 => GPIO1_ADDR, | |
} | |
} | |
fn FIODIR(self) -> u32 { (*self.get_addr()).FIODIR() } | |
} | |
//usage | |
fn main(){ | |
GPIO0.FIODIR(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment