Created
September 7, 2015 10:46
-
-
Save vdemay/516e7dd7075781bbef0b to your computer and use it in GitHub Desktop.
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
#include <asf.h> | |
static void config_led(void) | |
{ | |
struct port_config pin_conf; | |
port_get_config_defaults(&pin_conf); | |
//BUTTON | |
pin_conf.direction = PORT_PIN_DIR_INPUT; | |
pin_conf.input_pull = PORT_PIN_PULL_UP; | |
port_pin_set_config(BUTTON_0_PIN, &pin_conf); | |
//LED | |
pin_conf.direction = PORT_PIN_DIR_OUTPUT; | |
port_pin_set_config(LED_0_PIN, &pin_conf); | |
// TURN OFF | |
port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE); | |
} | |
int main(void) | |
{ | |
system_init(); | |
config_led(); | |
while(true) | |
{ | |
bool button_state = port_pin_get_input_level(BUTTON_0_PIN); | |
port_pin_set_output_level(LED_0_PIN, !button_state); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment