Skip to content

Instantly share code, notes, and snippets.

@pczarn
Created April 14, 2014 13:24
Show Gist options
  • Save pczarn/10647559 to your computer and use it in GitHub Desktop.
Save pczarn/10647559 to your computer and use it in GitHub Desktop.
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