From 81701220aa5bb96ef7cfa6961fc3e763a27234ab Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Sun, 28 Jan 2018 19:40:50 +0000 Subject: [PATCH] Add simple LED driver --- blink.c | 11 +++++++++++ drivers/led.c | 10 ++++++++++ drivers/led.h | 3 +++ 3 files changed, 24 insertions(+) create mode 100644 blink.c create mode 100644 drivers/led.c create mode 100644 drivers/led.h diff --git a/blink.c b/blink.c new file mode 100644 index 0000000..d01ecdc --- /dev/null +++ b/blink.c @@ -0,0 +1,11 @@ +#include +#include "drivers/led.h" + +int main(void) { + while(1) { + led(1); + _delay_ms(500); + led(0); + _delay_ms(500); + } +} diff --git a/drivers/led.c b/drivers/led.c new file mode 100644 index 0000000..0a01e9c --- /dev/null +++ b/drivers/led.c @@ -0,0 +1,10 @@ +#include "led.h" +#include + +void led(uint8_t on) { + if (on) { + LED_PORT |= (1 << LED_PIN); + } else { + LED_PORT &= ~(1 << LED_PIN); + } +} diff --git a/drivers/led.h b/drivers/led.h new file mode 100644 index 0000000..475ba23 --- /dev/null +++ b/drivers/led.h @@ -0,0 +1,3 @@ +#include + +void led(uint8_t on);