From 1ac3026c039cb15dd8c110c84215096854c3c804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 20 Mar 2016 16:36:04 +0100 Subject: Some chages in configuration build --- Kconfig | 5 +- Makefile | 188 ++++++++++++++++++++--------------------- examples/blink/.config | 25 ++++++ examples/blink/Makefile | 39 +++++---- examples/blink/config | 24 ------ examples/blink/config.orig | 24 ------ examples/usartecho/.config | 42 +++++++++ examples/usartecho/Makefile | 39 +++++---- examples/usartecho/config | 41 --------- examples/usartecho/config.orig | 41 --------- include/mcu/Kconfig | 6 +- include/mcu/atmega328p.h | 6 +- template/Makefile | 33 ++++---- 13 files changed, 231 insertions(+), 282 deletions(-) create mode 100644 examples/blink/.config delete mode 100644 examples/blink/config delete mode 100644 examples/blink/config.orig create mode 100644 examples/usartecho/.config delete mode 100644 examples/usartecho/config delete mode 100644 examples/usartecho/config.orig diff --git a/Kconfig b/Kconfig index 55d10f3..b748514 100644 --- a/Kconfig +++ b/Kconfig @@ -1,6 +1,9 @@ mainmenu "AVR-IOE configuration" -source "include/mcu/Kconfig" +config IOEROOT + string + option env="IOEROOT" +source "$IOEROOT/include/mcu/Kconfig" config F_CPU int "CPU frequency in kHz (F_CPU)" diff --git a/Makefile b/Makefile index 03cc786..0ddb6d8 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,13 @@ MAKEFLAGS += --no-builtin-rules -SRC = src/spi.c \ - src/usart.c \ - src/timer.c \ - src/tasks.c \ - src/ioport.c \ - src/sensors/dht22.c \ - -OBJ = $(patsubst %.c,%.o,$(SRC)) -DEP = $(patsubst %.c,%.d,$(SRC)) - -# default configuration path. Can be changed by enviroment to build with -# separate configuration files. -CONFIG ?= .config +# Default output path. Can be changed by enviroment to compile to different folder +# than default. +O ?= . +# This variable can be overwritten to show executed commands +Q ?= @ +# This variable can be used if you want to have configuration file for you project +# in different location than default. You should use absolute path. +CONFIG ?= $(O)/.config .PHONY: all # Check if we have configuration" @@ -22,131 +17,97 @@ else all: help $(CONFIG) endif -$(CONFIG): - @echo Please generate configuration first using config or menuconfig target - @exit 1 +ifneq ("$(wildcard $(CONFIG))","") # Check if we have configuration +ifeq (,$(filter clean help docs serve-docs clean-docs config oldconfig \ + allyesconfig menuconfig, \ + $(MAKECMDGOALS))) # Ignore build targets if goal is not building -.PHONY: oldconfig -oldconfig: - @[ ! -f "$(CONFIG)" ] || [ ! -f "$(CONFIG).orig" ] || mv "$(CONFIG).orig" config - @$(MAKE) -f kconfig/GNUmakefile --no-print-directory \ - TOPDIR=. SRCDIR=kconfig oldconfig - @[ ! -f config ] || sed 's/="\(.*\)"/=\1/' config > "$(CONFIG)" - @[ ! -f config ] || mv config "$(CONFIG).orig" - @[ ! -f config.old ] || mv config.old "$(CONFIG).old" +-include $(O)/build/config.mk # include configuration -.PHONY: config -config: - @[ ! -f "$(CONFIG)" ] || [ ! -f "$(CONFIG).orig" ] || mv "$(CONFIG).orig" config - @$(MAKE) -f kconfig/GNUmakefile --no-print-directory \ - TOPDIR=. SRCDIR=kconfig config - @[ ! -f config ] || sed 's/="\(.*\)"/=\1/' config > "$(CONFIG)" - @[ ! -f config ] || mv config "$(CONFIG).orig" - @[ ! -f config.old ] || mv config.old "$(CONFIG).old" - -.PHONY: menuconfig -menuconfig: - @[ ! -f "$(CONFIG)" ] || [ ! -f "$(CONFIG).orig" ] || mv "$(CONFIG).orig" config - @$(MAKE) -f kconfig/GNUmakefile --no-print-directory \ - TOPDIR=. SRCDIR=kconfig menuconfig - @[ ! -f config ] || sed 's/="\(.*\)"/=\1/' config > "$(CONFIG)" - @[ ! -f config ] || mv config "$(CONFIG).orig" - @[ ! -f config.old ] || mv config.old "$(CONFIG).old" +### Source files list ########################### +SRC = base.c +ifeq (y,$(CONFIG_IOPORTS)) +SRC += ioport.c +endif +ifeq (y,$(CONFIG_SPI)) +SRC += spi.c +endif +ifeq (y,$(CONFIG_USART)) +SRC += usart.c +endif +### End of source files list #################### -.PHONY: allyesconfig -allyesconfig: - @[ ! -f "$(CONFIG)" ] || [ ! -f "$(CONFIG).orig" ] || mv "$(CONFIG).orig" config - @$(MAKE) -f kconfig/GNUmakefile --no-print-directory \ - TOPDIR=. SRCDIR=kconfig allyesconfig - @[ ! -f config ] || sed 's/="\(.*\)"/=\1/' config > "$(CONFIG)" - @[ ! -f config ] || mv config "$(CONFIG).orig" - @[ ! -f config.old ] || mv config.old "$(CONFIG).old" -# Note about this file moving madness: -# avr-ioe is using Kconfig for configuration and it is not prepared too well for -# nested projects (at least I don't know way). This unfortunately means that to -# have configuration in parent project, We have to move it every time we are -# generating it. Also upper projects can't use Kconfig for its self configuration. +OBJ = $(patsubst %.c,$(O)/build/%.o,$(SRC)) +DEP = $(patsubst %.c,$(O)/build/%.d,$(SRC)) -# Check if we have configuration" -ifneq ("$(wildcard $(CONFIG))","") -ifeq (,$(findstring clean,$(MAKECMDGOALS))) -ifeq (,$(findstring help,$(MAKECMDGOALS))) -ifeq (,$(findstring docs,$(MAKECMDGOALS))) -ifeq (,$(findstring serve-docs,$(MAKECMDGOALS))) -ifeq (,$(findstring clean-docs,$(MAKECMDGOALS))) -ifeq (,$(findstring config,$(MAKECMDGOALS))) -ifeq (,$(findstring oldconfig,$(MAKECMDGOALS))) -ifeq (,$(findstring menuconfig,$(MAKECMDGOALS))) - -include $(CONFIG) -include $(DEP) CFLAGS = $(shell echo $(CONFCFLAGS)) $(shell echo -DF_CPU=$(F_CPU)000L) \ - -mmcu=$(MMCU) -Iinclude -imacros .config.h + -mmcu=$(MMCU) -Iinclude -imacros $(O)/build/config.h GCC = $(GNUTOOLCHAIN_PREFIX)gcc AR = $(GNUTOOLCHAIN_PREFIX)ar -libioe.a: $(OBJ) +$(O)/libioe.a: $(OBJ) @echo " AR $@" - @$(AR) -crs $@ $^ + $(Q)$(AR) -crs $@ $^ -$(OBJ): %.o: %.c .config.h +$(OBJ): $(O)/build/%.o: src/%.c + $(Q)mkdir -p "$(@D)" @echo " CC $@" - @$(GCC) $(CFLAGS) -c -o $@ $< + $(Q)$(GCC) $(CFLAGS) -c -o $@ $< -$(DEP): %.d: %.c .config.h +$(DEP): $(O)/build/%.d: src/%.c $(O)/build/config.mk + $(Q)mkdir -p "$(@D)" @echo " DEP $@" - @$(GCC) -MM -MG -MT '$*.o $@' $(CFLAGS) -c -o $@ $< + $(Q)$(GCC) -MM -MG -MT '$*.o $@' $(CFLAGS) -c -o $@ $< + +$(O)/build/config.mk: $(CONFIG) + $(Q)mkdir -p "$(@D)" + @echo " GEN $(CONFIG).mk" + $(Q)sed 's/="\(.*\)"/=\1/' $(CONFIG) > "$@" -.config.h: $(CONFIG) - @echo " GEN .config.h" - @grep -v "^#" $(CONFIG) | grep "CONFIG_" | sed 's/=/ /;s/^/#define /' > $@ +$(O)/build/config.h: $(CONFIG) + $(Q)mkdir -p "$(@D)" + @echo " GEN $(CONFIG).h" + $(Q)grep -v "^#" $(CONFIG) | grep "CONFIG_" | sed 's/=/ /;s/^/#define /' > $@ # This is not optimal because configuration change results to complete project # rebuild instead of only rebuilding required files. -endif -endif -endif -endif -endif -endif -endif +else +$(O)/libioe.a: + @echo Please execute non-building target separate from building ones + @exit 1 endif else - -libioe.a: - @echo Please generate configuration first using config or menuconfig target - +$(O)/libioe.a: $(CONFIG) # Print error message for missing config file endif .PHONY: clean clean: - @echo " CLEAN OBJ" - @$(RM) $(OBJ) - @echo " CLEAN DEP" - @$(RM) $(DEP) .config.h + @echo " CLEAN BUILD" + $(Q)$(RM) -r $(O)/build @echo " CLEAN libioe.a" - @$(RM) libioe.a + $(Q)$(RM) $(O)/libioe.a .PHONY: docs docs: @echo " DOC $@" - @mkdocs build + $(Q)mkdocs build .PHONY: serve-docs serve-docs: - @mkdocs serve + $(Q)mkdocs serve .PHONY: clean-docs clean-docs: @echo " CLEAN docs" - @$(RM) -r site + $(Q)$(RM) -r site .PHONY: distclean distclean: clean clean-docs @echo " CLEAN CONFIG" - @$(RM) $(CONFIG) $(CONFIG).orig + $(Q)$(RM) $(CONFIG) $(CONFIG).orig .PHONY: help help: @@ -158,3 +119,38 @@ help: @echo "help - Prints this text" @echo "clean - Removing all object files generated from source files" @echo "clean-docs - Remove generated documentation" + +$(CONFIG): + @echo Please generate configuration first using config or menuconfig target + @exit 1 + +# We don't wont pass any variable to Kconfig. This is workaround for that. +MAKEOVERRIDES = + +callconfig = $(Q)\ + [ ! -f "$(CONFIG)" ] || mv "$(CONFIG)" config; \ + IOEROOT=. $(MAKE) -f kconfig/GNUmakefile --no-print-directory \ + TOPDIR=. SRCDIR=kconfig $(1); \ + [ ! -f config ] || mv config "$(CONFIG)"; \ + [ ! -f config.old ] || mv config.old "$(CONFIG).old" +# Note about this file moving madness: +# avr-ioe is using Kconfig for configuration and it is not prepared too well for +# nested projects (at least I don't know way). This unfortunately means that to +# have configuration in parent project, We have to move it every time we are +# generating it. Also upper projects can't use Kconfig for its self configuration. + +.PHONY: oldconfig +oldconfig: + $(call callconfig, oldconfig) + +.PHONY: config +config: + $(call callconfig, config) + +.PHONY: menuconfig +menuconfig: + $(call callconfig, menuconfig) + +.PHONY: allyesconfig +allyesconfig: + $(call callconfig, allyesconfig) diff --git a/examples/blink/.config b/examples/blink/.config new file mode 100644 index 0000000..52dfc53 --- /dev/null +++ b/examples/blink/.config @@ -0,0 +1,25 @@ +# +# 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=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/Makefile b/examples/blink/Makefile index 43941b6..ef7e205 100644 --- a/examples/blink/Makefile +++ b/examples/blink/Makefile @@ -4,13 +4,14 @@ PROJNAME = 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 +ifneq ("$(wildcard .config)","") # Checking if configuration exists all: $(PROJNAME).hex @echo Now you can flash $< to your chip. else -all: help +all: .config endif # Edit here help like you ever want @@ -26,39 +27,43 @@ help: .PHONY: clean clean: @echo " CLEAN OBJ" - @$(RM) $(OBJ) + $(Q)$(RM) $(OBJ) @echo " CLEAN $(PROJNAME).elf $(PROJNAME).hex" - @$(RM) $(PROJNAME).elf $(PROJNAME).hex - @$(MAKE) -C ../.. clean + $(Q)$(RM) $(PROJNAME).elf $(PROJNAME).hex + $(Q)$(MAKE) -C ../.. clean O=examples/blink # Building targets are available only if configuration is generated -ifneq ("$(wildcard config)","") --include config +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 \ +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: libioe.a $(PROJNAME).elf: $(OBJ) @echo " LD $@" - @avr-gcc -Os -mmcu=$(MMCU) $^ -o $@ -L../.. -lioe + $(Q)avr-gcc -Os -mmcu=$(MMCU) $(filter %.o,$^) -o $@ -L. -lioe $(PROJNAME).hex: $(PROJNAME).elf @echo " OBJCOPY $@" - @avr-objcopy -O ihex -R .eeprom $< $@ + $(Q)avr-objcopy -O ihex -R .eeprom $< $@ -$(OBJ): %.o: %.c ../../libioe.a +$(OBJ): %.o: %.c libioe.a @echo " CC $@" - @avr-gcc $(CFLAGS) -c -o $@ $< + $(Q)avr-gcc $(CFLAGS) -c -o $@ $< -../../libioe.a: config - @CONFIG=$$(readlink -f config) $(MAKE) -C ../.. libioe.a +libioe.a: .config + $(Q)$(MAKE) -C ../.. examples/blink/libioe.a O=examples/blink endif +.config: + @echo Configuration for this example is missing. Probably deleted... + @exit 1 + config: - @CONFIG=$$(readlink -f config) $(MAKE) -C ../.. config + $(Q)$(MAKE) -C ../.. config O=examples/blink .PHONY: menuconfig menuconfig: - @CONFIG=$$(readlink -f config) $(MAKE) -C ../.. menuconfig + $(Q)$(MAKE) -C ../.. menuconfig O=examples/blink diff --git a/examples/blink/config b/examples/blink/config deleted file mode 100644 index 09169d4..0000000 --- a/examples/blink/config +++ /dev/null @@ -1,24 +0,0 @@ -# -# 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 deleted file mode 100644 index 529a7d3..0000000 --- a/examples/blink/config.orig +++ /dev/null @@ -1,24 +0,0 @@ -# -# 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/usartecho/.config b/examples/usartecho/.config new file mode 100644 index 0000000..48ae310 --- /dev/null +++ b/examples/usartecho/.config @@ -0,0 +1,42 @@ +# +# 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/Makefile b/examples/usartecho/Makefile index 900fe09..6e4e9d5 100644 --- a/examples/usartecho/Makefile +++ b/examples/usartecho/Makefile @@ -4,13 +4,14 @@ PROJNAME = 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 +ifneq ("$(wildcard .config)","") # Checking if configuration exists all: $(PROJNAME).hex @echo Now you can flash $< to your chip. else -all: help +all: .config endif # Edit here help like you ever want @@ -26,39 +27,43 @@ help: .PHONY: clean clean: @echo " CLEAN OBJ" - @$(RM) $(OBJ) + $(Q)$(RM) $(OBJ) @echo " CLEAN $(PROJNAME).elf $(PROJNAME).hex" - @$(RM) $(PROJNAME).elf $(PROJNAME).hex - @$(MAKE) -C ../.. clean + $(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 +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 \ +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: libioe.a $(PROJNAME).elf: $(OBJ) @echo " LD $@" - @avr-gcc -Os -mmcu=$(MMCU) $^ -o $@ -L../.. -lioe + @avr-gcc -Os -mmcu=$(MMCU) $(filter %.o,$^) -o $@ -L. -lioe $(PROJNAME).hex: $(PROJNAME).elf @echo " OBJCOPY $@" - @avr-objcopy -O ihex -R .eeprom $< $@ + $(Q)avr-objcopy -O ihex -R .eeprom $< $@ -$(OBJ): %.o: %.c ../../libioe.a +$(OBJ): %.o: %.c libioe.a @echo " CC $@" - @avr-gcc $(CFLAGS) -c -o $@ $< + $(Q)avr-gcc $(CFLAGS) -c -o $@ $< -../../libioe.a: config - @CONFIG=$$(readlink -f config) $(MAKE) -C ../.. libioe.a +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: - @CONFIG=$$(readlink -f config) $(MAKE) -C ../.. config + $(Q)$(MAKE) -C ../.. config O=examples/$(PROJNAME) .PHONY: menuconfig menuconfig: - @CONFIG=$$(readlink -f config) $(MAKE) -C ../.. menuconfig + $(Q)$(MAKE) -C ../.. menuconfig O=examples/$(PROJNAME) diff --git a/examples/usartecho/config b/examples/usartecho/config deleted file mode 100644 index 052a5c4..0000000 --- a/examples/usartecho/config +++ /dev/null @@ -1,41 +0,0 @@ -# -# 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 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/config.orig b/examples/usartecho/config.orig deleted file mode 100644 index 8bc1db9..0000000 --- a/examples/usartecho/config.orig +++ /dev/null @@ -1,41 +0,0 @@ -# -# 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 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/include/mcu/Kconfig b/include/mcu/Kconfig index ef99dbd..cecefdf 100644 --- a/include/mcu/Kconfig +++ b/include/mcu/Kconfig @@ -7,8 +7,8 @@ config MMCU choice MCU prompt "Microcontroller (MMCU)" -source include/mcu/atmega328p.Kconfig -source include/mcu/attiny85.Kconfig -source include/mcu/attiny4313.Kconfig +source "$IOEROOT/include/mcu/atmega328p.Kconfig" +source "$IOEROOT/include/mcu/attiny85.Kconfig" +source "$IOEROOT/include/mcu/attiny4313.Kconfig" endchoice diff --git a/include/mcu/atmega328p.h b/include/mcu/atmega328p.h index 994e9e6..38615bd 100644 --- a/include/mcu/atmega328p.h +++ b/include/mcu/atmega328p.h @@ -9,9 +9,9 @@ #define IO_B 0 #define IO_C 1 #define IO_D 2 -#define IO_PIN(GROUP) (* (volatile uint8_t *)(PINB + 0x3*GROUP)) -#define IO_DDR(GROUP) (* (volatile uint8_t *)(DDRB + 0x3*GROUP)) -#define IO_PORT(GROUP) (* (volatile uint8_t *)(PORTB + 0x3*GROUP)) +#define IO_PIN(GROUP) _SFR_IO8(0x03 * (1 + GROUP)) +#define IO_DDR(GROUP) _SFR_IO8(0x04 * (1 + GROUP)) +#define IO_PORT(GROUP) _SFR_IO8(0x05 * (1 + GROUP)) #define IO_B0 IO_B, (1 << 0) #define IO_B1 IO_B, (1 << 1) #define IO_B2 IO_B, (1 << 2) diff --git a/template/Makefile b/template/Makefile index f67d0c2..bc0643f 100644 --- a/template/Makefile +++ b/template/Makefile @@ -7,9 +7,10 @@ PROJNAME = template SRC = main.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 +ifneq ("$(wildcard ioeconfig)","") # Checking if configuration exists all: $(PROJNAME).hex @echo Now you can flash $< to your chip. else @@ -29,34 +30,36 @@ help: .PHONY: clean clean: @echo " CLEAN OBJ" - @$(RM) $(OBJ) + $(Q)$(RM) $(OBJ) @echo " CLEAN $(PROJNAME).elf $(PROJNAME).hex" - @$(RM) $(PROJNAME).elf $(PROJNAME).hex - @$(MAKE) -C avr-ioe clean + $(Q)$(RM) $(PROJNAME).elf $(PROJNAME).hex + $(Q)$(MAKE) -C avr-ioe clean CONFIG="$$( readlink -f ioeconfig )" # Building targets are available only if configuration is generated -ifneq ("$(wildcard .config)","") --include .config +ifneq ("$(wildcard ioeconfig)","") +include ioeconfig # 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 = -Iavr-ioe/include -mmcu=$(MMCU) -imacros avr-ioe/.config.h \ +CFLAGS = -Iavr-ioe/include -mmcu=$(MMCU) -imacros avr-ioe/build/config.h \ $(shell echo $(CONFCFLAGS)) $(shell echo -DF_CPU=$(F_CPU)000L) $(PROJNAME).elf: avr-ioe/libioe.a $(PROJNAME).elf: $(OBJ) @echo " LD $@" - @avr-gcc -Os -mmcu=$(MMCU) $^ -o $@ -Lavr-ioe -lioe + $(Q)avr-gcc -Os -mmcu=$(MMCU) $^ -o $@ -Lavr-ioe -lioe $(PROJNAME).hex: $(PROJNAME).elf @echo " OBJCOPY $@" - @avr-objcopy -O ihex -R .eeprom $< $@ + $(Q)avr-objcopy -O ihex -R .eeprom $< $@ -$(OBJ): %.o: %.c avr-ioe/libioe.a +$(OBJ): %.o: %.c avr-ioe/build/config.h @echo " CC $@" - @avr-gcc $(CFLAGS) -c -o $@ $< + $(Q)avr-gcc $(CFLAGS) -c -o $@ $< -avr-ioe/libioe.a: .config - @CONFIG=$$(readlink -f .config) $(MAKE) -C avr-ioe libioe.a +avr-ioe/libioe.a: ioeconfig + $(Q)$(MAKE) -C avr-ioe libioe.a CONFIG="$$( readlink -f ioeconfig )" +avr-ioe/build/config.h: ioeconfig + $(Q)$(MAKE) -C avr-ioe build/config.h CONFIG="$$( readlink -f ioeconfig )" endif .config: @@ -65,8 +68,8 @@ endif .PHONY: config config: - @CONFIG=$$(readlink -f .config) $(MAKE) -C avr-ioe menuconfig + $(Q)$(MAKE) -C avr-ioe menuconfig CONFIG="$$( readlink -f ioeconfig )" .PHONY: menuconfig menuconfig: - @CONFIG=$$(readlink -f .config) $(MAKE) -C avr-ioe menuconfig + $(Q)$(MAKE) -C avr-ioe menuconfig CONFIG="$$( readlink -f ioeconfig )" -- cgit v1.2.3