From 3d53f303314461517b8d9fa7851257c881eaadb8 Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Sun, 28 Jan 2018 20:10:26 +0000 Subject: [PATCH] Fix missing DDR initialisation for led driver --- boards/nano.mk | 3 ++- drivers/led.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/boards/nano.mk b/boards/nano.mk index d3d0873..6458dd4 100644 --- a/boards/nano.mk +++ b/boards/nano.mk @@ -1,6 +1,7 @@ MCU_TARGET = atmega328p MCU_FREQ = 16000000UL -CPPFLAGS += -DLED_PORT=PORTB -DLED_PIN=5 + +CPPFLAGS += -DLED_DDR=DDRB -DLED_PORT=PORTB -DLED_PIN=5 AVRDUDE_TYPE = arduino AVRDUDE_TTY = /dev/ttyUSB0 diff --git a/drivers/led.c b/drivers/led.c index 0a01e9c..b8f6668 100644 --- a/drivers/led.c +++ b/drivers/led.c @@ -1,6 +1,10 @@ #include "led.h" #include +void __attribute__ ((naked)) __attribute__ ((section (".init5"))) led_init() { + LED_DDR |= (1 << LED_PIN); +} + void led(uint8_t on) { if (on) { LED_PORT |= (1 << LED_PIN);