|
|
|
#include "gpio.h"
|
|
|
|
|
|
|
|
#define GPIO_LED_PORT PORT_0
|
|
|
|
#define GPIO_LED_PIN PIN_13
|
|
|
|
|
|
|
|
#define GPIO_BUTTON_PORT PORT_0
|
|
|
|
#define GPIO_BUTTON_PIN PIN_12
|
|
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
gpio_cfg_t gpio_led;
|
|
|
|
gpio_cfg_t gpio_button;
|
|
|
|
|
|
|
|
/* Setup output pin. */
|
|
|
|
gpio_led.port = GPIO_LED_PORT;
|
|
|
|
gpio_led.mask = GPIO_LED_PIN;
|
|
|
|
gpio_led.pad = GPIO_PAD_NONE;
|
|
|
|
gpio_led.func = GPIO_FUNC_OUT;
|
|
|
|
GPIO_Config(&gpio_led);
|
|
|
|
|
|
|
|
GPIO_OutClr(&gpio_led);
|
|
|
|
|
|
|
|
|
|
|
|
/* Setup output pin. */
|
|
|
|
gpio_button.port = GPIO_BUTTON_PORT;
|
|
|
|
gpio_button.mask = GPIO_BUTTON_PIN;
|
|
|
|
gpio_button.pad = GPIO_PAD_PULL_UP;
|
|
|
|
gpio_button.func = GPIO_FUNC_IN;
|
|
|
|
GPIO_Config(&gpio_button);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
/* Read state of the input pin. */
|
|
|
|
if (GPIO_InGet(&gpio_button)) {
|
|
|
|
/* Input pin was high, set the output pin. */
|
|
|
|
GPIO_OutSet(&gpio_led);
|
|
|
|
} else {
|
|
|
|
/* Input pin was low, clear the output pin. */
|
|
|
|
GPIO_OutClr(&gpio_led);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|