Skip to content

Instantly share code, notes, and snippets.

@yamanetoshi
Created April 25, 2014 08:38
Show Gist options
  • Save yamanetoshi/11282290 to your computer and use it in GitHub Desktop.
Save yamanetoshi/11282290 to your computer and use it in GitHub Desktop.
init_gpio function
void init_gpio(void){
int i;
// pullup all
*GPPUD = 0x02;
// wait 150 cycle
for(i=0;i<150;i++){
// nop
asm("mov r0,r0");
}
*GPPUDCLK0 = 0xffffffff;
*GPPUDCLK1 = 0xffffffff;
// wait 150 cycle
for(i=0;i<150;i++){
// nop
asm("mov r0,r0");
}
*GPPUDCLK0 = 0;
*GPPUDCLK1 = 0;
*GPFSEL0 = 0;
*GPFSEL1 = 0;
*GPFSEL2 = 0;
*GPFSEL3 = 0;
*GPFSEL4 = 0;
*GPFSEL5 = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment