You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.0 KiB

#include "gpio.h"
4 months ago
#define GPIO_LED_PORT PORT_0
#define GPIO_LED_PIN PIN_13
4 months ago
#define GPIO_BUTTON_PORT PORT_0
#define GPIO_BUTTON_PIN PIN_12
4 months ago
int main(void)
{
gpio_cfg_t gpio_led;
gpio_cfg_t gpio_button;
4 months ago
/* 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;
4 months ago
}