aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-03-08 22:16:16 +0100
committerKarel Kočí <cynerd@email.cz>2017-03-08 22:16:16 +0100
commit171e8e92686ac65e8f9a2962a975e6863c791a4f (patch)
tree42c8ba7caee8d1e6c67eca533350dd003d47d14f /examples
parentfbe0e4d00ba7e026b8b848cfcd0ed583a71f8069 (diff)
downloadavr-ioe-171e8e92686ac65e8f9a2962a975e6863c791a4f.tar.gz
avr-ioe-171e8e92686ac65e8f9a2962a975e6863c791a4f.tar.bz2
avr-ioe-171e8e92686ac65e8f9a2962a975e6863c791a4f.zip
Shakeout of makefiles and Kconfigs
Diffstat (limited to 'examples')
-rw-r--r--examples/blink/.config27
-rw-r--r--examples/blink/Kconfig9
-rw-r--r--examples/blink/Makefile69
-rw-r--r--examples/blink/blink.c2
-rw-r--r--examples/examples.mk74
-rw-r--r--examples/usartecho/.config42
-rw-r--r--examples/usartecho/Kconfig11
-rw-r--r--examples/usartecho/Makefile69
8 files changed, 99 insertions, 204 deletions
diff --git a/examples/blink/.config b/examples/blink/.config
deleted file mode 100644
index 9023cfc..0000000
--- a/examples/blink/.config
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Automatically generated file; DO NOT EDIT.
-# AVR-IOE configuration
-#
-MMCU="atmega328p"
-ATMEGA328P=y
-# ATTINY85 is not set
-# ATTINY4313 is not set
-F_CPU=16000
-
-#
-# Compilation options
-#
-GNUTOOLCHAIN_PREFIX="avr-"
-CONFCFLAGS="-Os -ffunction-sections -fdata-sections -fshort-enums -Wall"
-# CONFIG_ERRORS is not set
-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
-# CONFIG_TIMERS is not set
diff --git a/examples/blink/Kconfig b/examples/blink/Kconfig
new file mode 100644
index 0000000..9c3a502
--- /dev/null
+++ b/examples/blink/Kconfig
@@ -0,0 +1,9 @@
+mainmenu "AVR-IOE blink configuration"
+
+# We need CONFIG_IOPORTS, but we don't care about anything else.
+config BLINK_DEFAULTS
+ bool
+ default y
+ select CONFIG_IOPORTS
+
+source "../../ioe.Kconfig"
diff --git a/examples/blink/Makefile b/examples/blink/Makefile
index f2cc133..c70ed33 100644
--- a/examples/blink/Makefile
+++ b/examples/blink/Makefile
@@ -1,69 +1,4 @@
-MAKEFLAGS += --no-builtin-rules
-PROJNAME = blink
-
+EXAMPLE_NAME = blink
SRC = blink.c
-OBJ = $(patsubst %.c,%.o,$(SRC)) # This creates list of *.o files from *.c
-Q ?= @ # This can be overwritten to show commands
-
-.PHONY: all
-ifneq ("$(wildcard .config)","") # Checking if configuration exists
-all: $(PROJNAME).hex
- @echo Now you can flash $< to your chip.
-else
-all: .config
-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"
- $(Q)$(RM) $(OBJ)
- @echo " CLEAN $(PROJNAME).elf $(PROJNAME).hex"
- $(Q)$(RM) $(PROJNAME).elf $(PROJNAME).hex
- $(Q)$(MAKE) -C ../.. clean O=examples/$(PROJNAME)
-
-# 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 build/config.h \
- $(shell echo $(CONFCFLAGS)) $(shell echo -DF_CPU=$(F_CPU)000L)
-
-$(PROJNAME).elf: libioe.a
-$(PROJNAME).elf: $(OBJ)
- @echo " LD $@"
- $(Q)avr-gcc -Os -mmcu=$(MMCU) $(filter %.o,$^) -o $@ -L. -lioe
-
-$(PROJNAME).hex: $(PROJNAME).elf
- @echo " OBJCOPY $@"
- $(Q)avr-objcopy -O ihex -R .eeprom $< $@
-
-$(OBJ): %.o: %.c libioe.a
- @echo " CC $@"
- $(Q)avr-gcc $(CFLAGS) -c -o $@ $<
-
-libioe.a: .config
- $(Q)$(MAKE) -C ../.. examples/$(PROJNAME)/libioe.a O=examples/$(PROJNAME)
-endif
-
-.config:
- @echo Configuration for this example is missing. Probably deleted...
- @exit 1
-
-config:
- $(Q)$(MAKE) -C ../.. config O=examples/$(PROJNAME)
-
-.PHONY: menuconfig
-menuconfig:
- $(Q)$(MAKE) -C ../.. menuconfig O=examples/$(PROJNAME)
+include ../examples.mk
diff --git a/examples/blink/blink.c b/examples/blink/blink.c
index 912ce80..a1411e6 100644
--- a/examples/blink/blink.c
+++ b/examples/blink/blink.c
@@ -6,7 +6,7 @@ int main() {
io_setout(IO_B0);
while (1) {
- io_hight(IO_B0);
+ io_high(IO_B0);
_delay_ms(500);
io_low(IO_B0);
_delay_ms(500);
diff --git a/examples/examples.mk b/examples/examples.mk
new file mode 100644
index 0000000..f6b0acb
--- /dev/null
+++ b/examples/examples.mk
@@ -0,0 +1,74 @@
+# vim:ts=4:sw=4:sts=4:noexpandtab
+MAKEFLAGS += --no-builtin-rules
+# Note this file is included to Makefiles in lower directories so all paths here
+# are like thy would be from lower directory.
+
+# You have to define EXAMPLE_NAME variable
+ifndef EXAMPLE_NAME
+$(error Before including examples.mk define EXAMPLE_NAME)
+endif
+ifndef SRC
+$(error Before including examples.mk define SRC)
+endif
+
+OBJ = $(patsubst %.c,%.o,$(SRC)) # This creates list of *.o files from *.c
+Q ?= @ # This can be overwritten to show commands
+
+CONFIG = .config
+
+.PHONY: all
+ifneq ("$(wildcard $(CONFIG))","") # Checking if configuration exists
+all: $(EXAMPLE_NAME).hex
+ @echo Now you can flash $< to your chip.
+else
+all: $(CONFIG)
+endif
+
+# Edit here help like you ever want
+.PHONY: help
+help:
+ @echo "AVR-IOE $(EXAMPLE_NAME) 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"
+ $(Q)$(RM) $(OBJ)
+ @echo " CLEAN $(EXAMPLE_NAME).elf $(EXAMPLE_NAME).hex"
+ $(Q)$(RM) $(EXAMPLE_NAME).elf $(EXAMPLE_NAME).hex
+ $(Q)$(MAKE) -C ../.. clean O=examples/$(EXAMPLE_NAME)
+
+# 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 build/config.h \
+ $(shell echo $(CCFLAGS)) $(shell echo -DF_CPU=$(F_CPU)000L)
+CC = $(CHOST)gcc
+OBJCOPY = $(CHOST)objcopy
+
+$(EXAMPLE_NAME).elf: libioe.a
+$(EXAMPLE_NAME).elf: $(OBJ)
+ @echo " LD $@"
+ $(Q)$(CC) -Os -mmcu=$(MMCU) $(filter %.o,$^) -o $@ -L. -lioe
+
+$(EXAMPLE_NAME).hex: $(EXAMPLE_NAME).elf
+ @echo " OBJCOPY $@"
+ $(Q)$(OBJCOPY) -O ihex -R .eeprom $< $@
+
+$(OBJ): %.o: %.c libioe.a
+ @echo " CC $@"
+ $(Q)$(CC) $(CFLAGS) -c -o $@ $<
+
+libioe.a: $(CONFIG)
+ $(Q)$(MAKE) -C ../.. examples/$(EXAMPLE_NAME)/libioe.a O=examples/$(EXAMPLE_NAME)
+endif
+
+TOOL_PATH=../../tools
+IOEROOT=../../
+include ../../tools/kconfig.mk
diff --git a/examples/usartecho/.config b/examples/usartecho/.config
deleted file mode 100644
index 48ae310..0000000
--- a/examples/usartecho/.config
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Automatically generated file; DO NOT EDIT.
-# AVR-IOE configuration
-#
-MMCU="atmega328p"
-ATMEGA328P=y
-# ATTINY85 is not set
-# ATTINY4313 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 is not set
-MCUSUPPORT_PCINT0=y
-MCUSUPPORT_PCINT1=y
-MCUSUPPORT_PCINT2=y
-MCUSUPPORT_SPI=y
-# CONFIG_SPI is not set
-MCUSUPPORT_USART=y
-CONFIG_USART=y
-CONFIG_USART_BAUD=115200
-USART_PARITY_C_NONE=y
-# USART_PARITY_C_ODD is not set
-# USART_PARITY_C_EVEN is not set
-CONFIG_USART_PARITY="USART_PARITY_NONE"
-CONFIG_USART_DATABITS=8
-USART_STOPBIT_C_SINGLE=y
-# USART_STOPBIT_C_DOUBLE is not set
-CONFIG_USART_STOPBIT="USART_STOPBIT_SINGLE"
-CONFIG_USART_OUTPUT_BUFFER=y
-CONFIG_USART_OUTBUFFER_SIZE=64
-USART_OUTBUFFER_MODE_C_BLOCK=y
-# USART_OUTBUFFER_MODE_C_OVERWRITE is not set
-# USART_OUTBUFFER_MODE_C_DROP is not set
-CONFIG_USART_OUTBUFFER_MODE=0
-# CONFIG_USART_INPUT_BUFFER is not set
-CONFIG_USART_INBUFFER_SIZE=32
-CONFIG_USART_INBUFFER_MODE=0
diff --git a/examples/usartecho/Kconfig b/examples/usartecho/Kconfig
new file mode 100644
index 0000000..3bfde28
--- /dev/null
+++ b/examples/usartecho/Kconfig
@@ -0,0 +1,11 @@
+mainmenu "AVR-IOE usartecho configuration"
+
+# We need CONFIG_IOPORTS, but we don't care about anything else.
+config USART_ECHO_DEFAULTS
+ bool
+ default y
+ select CONFIG_USART
+ select CONFIG_USART_OUTPUT_BUFFER
+ depends on ! CONFIG_USART_INPUT_BUFFER
+
+source "../../ioe.Kconfig"
diff --git a/examples/usartecho/Makefile b/examples/usartecho/Makefile
index 6e4e9d5..93a2783 100644
--- a/examples/usartecho/Makefile
+++ b/examples/usartecho/Makefile
@@ -1,69 +1,4 @@
-MAKEFLAGS += --no-builtin-rules
-PROJNAME = usartecho
-
+EXAMPLE_NAME = usartecho
SRC = echo.c
-OBJ = $(patsubst %.c,%.o,$(SRC)) # This creates list of *.o files from *.c
-Q ?= @ # This can be overwritten to show commands
-
-.PHONY: all
-ifneq ("$(wildcard .config)","") # Checking if configuration exists
-all: $(PROJNAME).hex
- @echo Now you can flash $< to your chip.
-else
-all: .config
-endif
-
-# Edit here help like you ever want
-.PHONY: help
-help:
- @echo "AVR-IOE USART echo 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"
- $(Q)$(RM) $(OBJ)
- @echo " CLEAN $(PROJNAME).elf $(PROJNAME).hex"
- $(Q)$(RM) $(PROJNAME).elf $(PROJNAME).hex
- $(Q)$(MAKE) -C ../.. clean O=examples/$(PROJNAME)
-
-# 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 build/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) $(filter %.o,$^) -o $@ -L. -lioe
-
-$(PROJNAME).hex: $(PROJNAME).elf
- @echo " OBJCOPY $@"
- $(Q)avr-objcopy -O ihex -R .eeprom $< $@
-
-$(OBJ): %.o: %.c libioe.a
- @echo " CC $@"
- $(Q)avr-gcc $(CFLAGS) -c -o $@ $<
-
-libioe.a: .config
- $(Q)$(MAKE) -C ../.. examples/$(PROJNAME)/libioe.a O=examples/$(PROJNAME)
-endif
-
-.config:
- @echo Configuration for this example is missing. Probably deleted...
- @exit 1
-
-config:
- $(Q)$(MAKE) -C ../.. config O=examples/$(PROJNAME)
-
-.PHONY: menuconfig
-menuconfig:
- $(Q)$(MAKE) -C ../.. menuconfig O=examples/$(PROJNAME)
+include ../examples.mk