Skip to content

Instantly share code, notes, and snippets.

@2garryn
Last active February 20, 2017 00:35
Show Gist options
  • Save 2garryn/6c7e550c78087d51aaa1404e4fcaaca0 to your computer and use it in GitHub Desktop.
Save 2garryn/6c7e550c78087d51aaa1404e4fcaaca0 to your computer and use it in GitHub Desktop.
void btn_loop(void) {
uint16_t port0 = GPIO_ReadInputData(BTN_PORT_0);
uint16_t port1 = GPIO_ReadInputData(BTN_PORT_1);
if(port0 & (BTN_PORT_0_PINS)) {
if(port0 & BTN_PORT_0_PIN_0) btn_callback_clicked_0_0()
else if(port0 & BTN_PORT_0_PIN_1) btn_callback_clicked_0_1()
else if(port0 & BTN_PORT_0_PIN_2) btn_callback_clicked_0_2()
else if(port0 & BTN_PORT_0_PIN_3) btn_callback_clicked_0_3();
} else if(port1 & (BTN_PORT_1_PINS)) {
if(port1 & BTN_PORT_1_PIN_0) btn_callback_clicked_1_0()
else if(port1 & BTN_PORT_1_PIN_1) btn_callback_clicked_1_1()
else if(port1 & BTN_PORT_1_PIN_2) btn_callback_clicked_1_2()
else if(port1 & BTN_PORT_1_PIN_3) btn_callback_clicked_1_3();
} else {
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment