aboutsummaryrefslogtreecommitdiff
path: root/examples/blink
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-03-08 16:10:33 +0100
committerKarel Kočí <cynerd@email.cz>2016-03-08 16:10:33 +0100
commit5d29fe79d30f430ae326d9dc57ccfaed6fe61328 (patch)
tree8341804d561c0060176cbebc3f9a57c7c07f7816 /examples/blink
parent4e773191d447ac434536262a6f204dd991d4ad77 (diff)
downloadavr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.tar.gz
avr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.tar.bz2
avr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.zip
Another full update of current work
Diffstat (limited to 'examples/blink')
-rw-r--r--examples/blink/Makefile64
-rw-r--r--examples/blink/README.md0
-rw-r--r--examples/blink/blink.c14
-rw-r--r--examples/blink/config24
-rw-r--r--examples/blink/config.orig24
5 files changed, 126 insertions, 0 deletions
diff --git a/examples/blink/Makefile b/examples/blink/Makefile
new file mode 100644
index 0000000..43941b6
--- /dev/null
+++ b/examples/blink/Makefile
@@ -0,0 +1,64 @@
+MAKEFLAGS += --no-builtin-rules
+PROJNAME = blink
+
+SRC = blink.c
+
+OBJ = $(patsubst %.c,%.o,$(SRC)) # This creates list of *.o files from *.c
+
+.PHONY: all
+ifneq ("$(wildcard config)","") # Checking if configuration exists
+all: $(PROJNAME).hex
+ @echo Now you can flash $< to your chip.
+else
+all: help
+endif
+
+# Edit here help like you ever want
+.PHONY: help
+help:
+ @echo "AVR-IOE blink example"
+ @echo " all - Build example"
+ @echo " config - Start configuration program"
+ @echo " menuconfig - NCurses based configuration program"
+ @echo " help - Prints this text"
+ @echo " clean - Removing all object files generated from source files"
+
+.PHONY: clean
+clean:
+ @echo " CLEAN OBJ"
+ @$(RM) $(OBJ)
+ @echo " CLEAN $(PROJNAME).elf $(PROJNAME).hex"
+ @$(RM) $(PROJNAME).elf $(PROJNAME).hex
+ @$(MAKE) -C ../.. clean
+
+# Building targets are available only if configuration is generated
+ifneq ("$(wildcard config)","")
+-include config
+# If you want change some standard CFLAGS, change them in configuration not here.
+# Add here only options that should not be applied to avr-ioe also.
+CFLAGS = -I../../include -mmcu=$(MMCU) -imacros ../../.config.h \
+ $(shell echo $(CONFCFLAGS)) $(shell echo -DF_CPU=$(F_CPU)000L)
+
+$(PROJNAME).elf: ../../libioe.a
+$(PROJNAME).elf: $(OBJ)
+ @echo " LD $@"
+ @avr-gcc -Os -mmcu=$(MMCU) $^ -o $@ -L../.. -lioe
+
+$(PROJNAME).hex: $(PROJNAME).elf
+ @echo " OBJCOPY $@"
+ @avr-objcopy -O ihex -R .eeprom $< $@
+
+$(OBJ): %.o: %.c ../../libioe.a
+ @echo " CC $@"
+ @avr-gcc $(CFLAGS) -c -o $@ $<
+
+../../libioe.a: config
+ @CONFIG=$$(readlink -f config) $(MAKE) -C ../.. libioe.a
+endif
+
+config:
+ @CONFIG=$$(readlink -f config) $(MAKE) -C ../.. config
+
+.PHONY: menuconfig
+menuconfig:
+ @CONFIG=$$(readlink -f config) $(MAKE) -C ../.. menuconfig
diff --git a/examples/blink/README.md b/examples/blink/README.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/blink/README.md
diff --git a/examples/blink/blink.c b/examples/blink/blink.c
new file mode 100644
index 0000000..8386d4b
--- /dev/null
+++ b/examples/blink/blink.c
@@ -0,0 +1,14 @@
+#include <avr/io.h>
+#include <util/delay.h>
+#include <ioport.h>
+
+int main() {
+ io_setout(IO_B3);
+
+ while (1) {
+ io_hight(IO_B3);
+ _delay_ms(500);
+ io_low(IO_B3);
+ _delay_ms(500);
+ }
+}
diff --git a/examples/blink/config b/examples/blink/config
new file mode 100644
index 0000000..09169d4
--- /dev/null
+++ b/examples/blink/config
@@ -0,0 +1,24 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# AVR-IOE configuration
+#
+MMCU=atmega328p
+ATMEGA328P=y
+# ATTINY85 is not set
+F_CPU=16000
+
+#
+# Compilation options
+#
+GNUTOOLCHAIN_PREFIX=avr-
+CONFCFLAGS=-Os -ffunction-sections -fdata-sections -fshort-enums -Wall
+MCUSUPPORT_IOPORTS=y
+CONFIG_IOPORTS=y
+MCUSUPPORT_PCINT0=y
+MCUSUPPORT_PCINT1=y
+MCUSUPPORT_PCINT2=y
+# CONFIG_IOPORTS_PCINT is not set
+MCUSUPPORT_SPI=y
+# CONFIG_SPI is not set
+MCUSUPPORT_USART=y
+# CONFIG_USART is not set
diff --git a/examples/blink/config.orig b/examples/blink/config.orig
new file mode 100644
index 0000000..529a7d3
--- /dev/null
+++ b/examples/blink/config.orig
@@ -0,0 +1,24 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# AVR-IOE configuration
+#
+MMCU="atmega328p"
+ATMEGA328P=y
+# ATTINY85 is not set
+F_CPU=16000
+
+#
+# Compilation options
+#
+GNUTOOLCHAIN_PREFIX="avr-"
+CONFCFLAGS="-Os -ffunction-sections -fdata-sections -fshort-enums -Wall"
+MCUSUPPORT_IOPORTS=y
+CONFIG_IOPORTS=y
+MCUSUPPORT_PCINT0=y
+MCUSUPPORT_PCINT1=y
+MCUSUPPORT_PCINT2=y
+# CONFIG_IOPORTS_PCINT is not set
+MCUSUPPORT_SPI=y
+# CONFIG_SPI is not set
+MCUSUPPORT_USART=y
+# CONFIG_USART is not set