diff options
author | Karel Kočí <cynerd@email.cz> | 2016-03-08 16:10:33 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2016-03-08 16:10:33 +0100 |
commit | 5d29fe79d30f430ae326d9dc57ccfaed6fe61328 (patch) | |
tree | 8341804d561c0060176cbebc3f9a57c7c07f7816 /examples | |
parent | 4e773191d447ac434536262a6f204dd991d4ad77 (diff) | |
download | avr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.tar.gz avr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.tar.bz2 avr-ioe-5d29fe79d30f430ae326d9dc57ccfaed6fe61328.zip |
Another full update of current work
Diffstat (limited to 'examples')
-rw-r--r-- | examples/blink/Makefile | 64 | ||||
-rw-r--r-- | examples/blink/README.md | 0 | ||||
-rw-r--r-- | examples/blink/blink.c | 14 | ||||
-rw-r--r-- | examples/blink/config | 24 | ||||
-rw-r--r-- | examples/blink/config.orig | 24 | ||||
-rw-r--r-- | examples/spiblink/Makefile | 66 | ||||
-rw-r--r-- | examples/spiblink/config | 23 | ||||
-rw-r--r-- | examples/spiblink/config.orig | 23 | ||||
-rw-r--r-- | examples/spiblink/makefile | 32 | ||||
-rw-r--r-- | examples/spiblink/master.c | 2 | ||||
-rw-r--r-- | examples/spiblink/slave.c | 2 | ||||
-rw-r--r-- | examples/usartecho/Makefile | 64 | ||||
-rw-r--r-- | examples/usartecho/config | 41 | ||||
-rw-r--r-- | examples/usartecho/config.orig | 41 | ||||
-rw-r--r-- | examples/usartecho/echo.c | 2 | ||||
-rw-r--r-- | examples/usartecho/makefile | 36 |
16 files changed, 387 insertions, 71 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 diff --git a/examples/spiblink/Makefile b/examples/spiblink/Makefile new file mode 100644 index 0000000..621f237 --- /dev/null +++ b/examples/spiblink/Makefile @@ -0,0 +1,66 @@ +MAKEFLAGS += --no-builtin-rules +PROJNAME = spiblink + +MSRC = master.c +SSRC = slave.c + +MOBJ = $(patsubst %.c,%.o,$(MSRC)) +SOBJ = $(patsubst %.c,%.o,$(SSRC)) + +.PHONY: all +ifneq ("$(wildcard config)","") # Checking if configuration exists +all: master.hex slave.hex + @echo Now you can flash $^ to your chips. +else +all: help +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" + @$(RM) $(MOBJ) $(SOBJ) + @echo " CLEAN master and slave *.hex, *.elf" + @$(RM) master.elf master.hex + @$(RM) slave.elf slave.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) + +master.elf slave.elf: %.elf: ../../libioe.a %.o + @echo " LD $@" + @avr-gcc -Os -mmcu=$(MMCU) $^ -o $@ -L../.. -lioe + +master.hex slave.hex: %.hex: %.elf + @echo " OBJCOPY $@" + @avr-objcopy -O ihex -R .eeprom $< $@ + +$(MOBJ) $(SOBJ): %.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/spiblink/config b/examples/spiblink/config new file mode 100644 index 0000000..7455947 --- /dev/null +++ b/examples/spiblink/config @@ -0,0 +1,23 @@ +# +# 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=y +MCUSUPPORT_USART=y +# CONFIG_USART is not set diff --git a/examples/spiblink/config.orig b/examples/spiblink/config.orig new file mode 100644 index 0000000..af7b0a5 --- /dev/null +++ b/examples/spiblink/config.orig @@ -0,0 +1,23 @@ +# +# 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=y +MCUSUPPORT_USART=y +# CONFIG_USART is not set diff --git a/examples/spiblink/makefile b/examples/spiblink/makefile deleted file mode 100644 index 60ba9c9..0000000 --- a/examples/spiblink/makefile +++ /dev/null @@ -1,32 +0,0 @@ -MAKEFLAGS += --no-builtin-rules - -MMCU = atmega328p -F_CPU = 16000000L -IOE_PREFIX = ../.. -IOE_CFLAGS ?= -Os -ffunction-sections -fdata-sections -fshort-enums -g -Wall \ - -DF_CPU=$(F_CPU) -mmcu=$(MMCU) \ - -DCONFIG_IOE_SPI - -.PHONY: all -all: master.hex slave.hex - @echo - @echo Flash master.hex and slave.hex to two chips and... TODO - -.PHONY: all -clean: ioeclean - $(RM) master.o slave.o - $(RM) master.elf master.hex - $(RM) slave.elf slave.hex - -include ../../avr-ioe.mk - -master.elf: master.o -slave.elf: slave.o -master.elf slave.elf: %.elf: $(IOE_OBJ_SPI) - avr-gcc -Os -mmcu=$(MMCU) $^ -o $@ - -master.hex slave.hex: %.hex: %.elf - avr-objcopy -O ihex -R .eeprom $< $@ - -master.o slave.o: %.o: %.c - avr-gcc $(IOE_CFLAGS) -c -o $@ $< diff --git a/examples/spiblink/master.c b/examples/spiblink/master.c index 267d7b2..1cc4289 100644 --- a/examples/spiblink/master.c +++ b/examples/spiblink/master.c @@ -1,6 +1,6 @@ #include <avr/io.h> #include <util/delay.h> -#include "../../spi.h" +#include <spi.h> int main() { DDRB |= _BV(DDB1) | _BV(DDB2); diff --git a/examples/spiblink/slave.c b/examples/spiblink/slave.c index cf14408..91a8237 100644 --- a/examples/spiblink/slave.c +++ b/examples/spiblink/slave.c @@ -1,6 +1,6 @@ #include <avr/io.h> #include <util/delay.h> -#include "../../spi.h" +#include <spi.h> void receive(uint8_t data); diff --git a/examples/usartecho/Makefile b/examples/usartecho/Makefile new file mode 100644 index 0000000..900fe09 --- /dev/null +++ b/examples/usartecho/Makefile @@ -0,0 +1,64 @@ +MAKEFLAGS += --no-builtin-rules +PROJNAME = usartecho + +SRC = echo.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 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" + @$(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/usartecho/config b/examples/usartecho/config new file mode 100644 index 0000000..052a5c4 --- /dev/null +++ b/examples/usartecho/config @@ -0,0 +1,41 @@ +# +# 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 new file mode 100644 index 0000000..8bc1db9 --- /dev/null +++ b/examples/usartecho/config.orig @@ -0,0 +1,41 @@ +# +# 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/echo.c b/examples/usartecho/echo.c index 12b88f6..d685750 100644 --- a/examples/usartecho/echo.c +++ b/examples/usartecho/echo.c @@ -1,7 +1,7 @@ #include <avr/io.h> #include <util/delay.h> #include <string.h> -#include "../../usart.h" +#include <usart.h> void rec(uint8_t data) { if (data == '\r') { diff --git a/examples/usartecho/makefile b/examples/usartecho/makefile deleted file mode 100644 index 15254c6..0000000 --- a/examples/usartecho/makefile +++ /dev/null @@ -1,36 +0,0 @@ -MAKEFLAGS += --no-builtin-rules - -MMCU = atmega328p -F_CPU = 16000000L -IOE_PREFIX = ../.. -IOE_SHORTOUTPUT=y -IOE_CFLAGS = -Os -fshort-enums -Wall \ - -DF_CPU=$(F_CPU) -mmcu=$(MMCU) \ - -DCONFIG_IOE_USART \ - -DCONFIG_IOE_USART_OUTBUFFER_SIZE=64 \ - -DCONFIG_IOE_USART_OUTBUFFER_MODE=0 \ - -DCONFIG_IOE_USART_BAUD=115200 \ - -DCONFIG_IOE_USART_PARITY=USART_PARITY_NONE \ - -DCONFIG_IOE_USART_STOPBIT=USART_STOPBIT_SINGLE \ - -DCONFIG_IOE_USART_DATABITS=8 - -all: usart.hex - @echo Now you can flash usart.hex to your chip. - -clean: ioeclean - $(RM) echo.o - $(RM) usart.elf usart.hex - -include ../../avr-ioe.mk - -usart.elf: %.elf: $(IOE_OBJ) echo.o - @echo " LD $@" - @avr-gcc -Os -mmcu=$(MMCU) $^ -o $@ - -usart.hex: %.hex: %.elf - @echo " OBJCOPY $@" - @avr-objcopy -O ihex -R .eeprom $< $@ - -echo.o: %.o: %.c - @echo " CC $@" - @avr-gcc $(IOE_CFLAGS) -c -o $@ $< |