diff options
author | Karel Kočí <cynerd@email.cz> | 2017-03-09 07:04:55 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-03-09 07:04:55 +0100 |
commit | dfc471c4f68eba0c054e61dbb3567ee89e3a036f (patch) | |
tree | 69b6ee6b5be7da3087d782397cb0ec04734f23a9 /examples | |
parent | 171e8e92686ac65e8f9a2962a975e6863c791a4f (diff) | |
download | avr-ioe-dfc471c4f68eba0c054e61dbb3567ee89e3a036f.tar.gz avr-ioe-dfc471c4f68eba0c054e61dbb3567ee89e3a036f.tar.bz2 avr-ioe-dfc471c4f68eba0c054e61dbb3567ee89e3a036f.zip |
Update spiblink example to use examples.mk
Diffstat (limited to 'examples')
-rw-r--r-- | examples/blink/Kconfig | 5 | ||||
-rw-r--r-- | examples/blink/Makefile | 1 | ||||
-rw-r--r-- | examples/blink/blink.c | 6 | ||||
-rw-r--r-- | examples/examples.mk | 16 | ||||
-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/master.c | 20 | ||||
-rw-r--r-- | examples/spiblink/master/.config | 35 | ||||
-rw-r--r-- | examples/spiblink/master/Kconfig | 20 | ||||
-rw-r--r-- | examples/spiblink/master/Makefile | 6 | ||||
-rw-r--r-- | examples/spiblink/master/master.c | 17 | ||||
-rw-r--r-- | examples/spiblink/slave.c | 21 | ||||
-rw-r--r-- | examples/spiblink/slave/.config | 44 | ||||
-rw-r--r-- | examples/spiblink/slave/Kconfig | 15 | ||||
-rw-r--r-- | examples/spiblink/slave/Makefile | 6 | ||||
-rw-r--r-- | examples/spiblink/slave/slave.c | 19 | ||||
-rw-r--r-- | examples/usartecho/Makefile | 1 |
18 files changed, 181 insertions, 163 deletions
diff --git a/examples/blink/Kconfig b/examples/blink/Kconfig index 9c3a502..ba7889c 100644 --- a/examples/blink/Kconfig +++ b/examples/blink/Kconfig @@ -6,4 +6,9 @@ config BLINK_DEFAULTS default y select CONFIG_IOPORTS +config CONFIG_BLINK_IO + string "Output pin used to connect led" + depends on BLINK_DEFAULTS + default "IO_B0" + source "../../ioe.Kconfig" diff --git a/examples/blink/Makefile b/examples/blink/Makefile index c70ed33..4e4f81e 100644 --- a/examples/blink/Makefile +++ b/examples/blink/Makefile @@ -1,4 +1,5 @@ EXAMPLE_NAME = blink SRC = blink.c +IOEROOT=../../ include ../examples.mk diff --git a/examples/blink/blink.c b/examples/blink/blink.c index a1411e6..adc215b 100644 --- a/examples/blink/blink.c +++ b/examples/blink/blink.c @@ -3,12 +3,12 @@ #include <ioport.h> int main() { - io_setout(IO_B0); + io_setout(CONFIG_BLINK_IO); while (1) { - io_high(IO_B0); + io_high(CONFIG_BLINK_IO); _delay_ms(500); - io_low(IO_B0); + io_low(CONFIG_BLINK_IO); _delay_ms(500); } } diff --git a/examples/examples.mk b/examples/examples.mk index f6b0acb..3d838e7 100644 --- a/examples/examples.mk +++ b/examples/examples.mk @@ -3,13 +3,16 @@ 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 IOEROOT +$(error Before including examples.mk define IOEROOT) +endif ifndef EXAMPLE_NAME $(error Before including examples.mk define EXAMPLE_NAME) endif ifndef SRC $(error Before including examples.mk define SRC) endif +EXAMPLE_PATH ?= $(EXAMPLE_NAME) OBJ = $(patsubst %.c,%.o,$(SRC)) # This creates list of *.o files from *.c Q ?= @ # This can be overwritten to show commands @@ -40,14 +43,14 @@ clean: $(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) + $(Q)$(MAKE) -C "$(IOEROOT)" clean O=examples/$(EXAMPLE_PATH) # 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 \ +CFLAGS = -I"$(IOEROOT)/include" -mmcu=$(MMCU) -imacros build/config.h \ $(shell echo $(CCFLAGS)) $(shell echo -DF_CPU=$(F_CPU)000L) CC = $(CHOST)gcc OBJCOPY = $(CHOST)objcopy @@ -66,9 +69,8 @@ $(OBJ): %.o: %.c libioe.a $(Q)$(CC) $(CFLAGS) -c -o $@ $< libioe.a: $(CONFIG) - $(Q)$(MAKE) -C ../.. examples/$(EXAMPLE_NAME)/libioe.a O=examples/$(EXAMPLE_NAME) + $(Q)$(MAKE) -C "$(IOEROOT)" examples/$(EXAMPLE_PATH)/libioe.a O=examples/$(EXAMPLE_PATH) endif -TOOL_PATH=../../tools -IOEROOT=../../ -include ../../tools/kconfig.mk +TOOL_PATH="$(IOEROOT)/tools" +include $(IOEROOT)/tools/kconfig.mk diff --git a/examples/spiblink/Makefile b/examples/spiblink/Makefile deleted file mode 100644 index 621f237..0000000 --- a/examples/spiblink/Makefile +++ /dev/null @@ -1,66 +0,0 @@ -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 deleted file mode 100644 index 7455947..0000000 --- a/examples/spiblink/config +++ /dev/null @@ -1,23 +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=y -MCUSUPPORT_USART=y -# CONFIG_USART is not set diff --git a/examples/spiblink/config.orig b/examples/spiblink/config.orig deleted file mode 100644 index af7b0a5..0000000 --- a/examples/spiblink/config.orig +++ /dev/null @@ -1,23 +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=y -MCUSUPPORT_USART=y -# CONFIG_USART is not set diff --git a/examples/spiblink/master.c b/examples/spiblink/master.c deleted file mode 100644 index 1cc4289..0000000 --- a/examples/spiblink/master.c +++ /dev/null @@ -1,20 +0,0 @@ -#include <avr/io.h> -#include <util/delay.h> -#include <spi.h> - -int main() { - DDRB |= _BV(DDB1) | _BV(DDB2); - PORTC |= _BV(PORTC1); - spi_init(SPI_MODE_MASTER); - SREG |= _BV(7); - while (1) { - if (PINC & _BV(PINC1)) { - PORTB &= ~_BV(PORTB1); - } else { - PORTB |= _BV(PORTB1); - } - PORTB &= ~_BV(PORTB2); - spi_send(!(PINC & _BV(PINC1))); - PORTB |= _BV(PORTB2); - } -} diff --git a/examples/spiblink/master/.config b/examples/spiblink/master/.config new file mode 100644 index 0000000..08e8924 --- /dev/null +++ b/examples/spiblink/master/.config @@ -0,0 +1,35 @@ +# +# Automatically generated file; DO NOT EDIT. +# AVR-IOE spiblink master configuration +# +SPIBLINK_MASTER_DEFAULTS=y +CONFIG_BUTTON_IO="IO_C1" +CONFIG_LED_IO="IO_B0" +MMCU="atmega328p" +ATMEGA328P=y +# ATMEGA168A is not set +# ATTINY85 is not set +# ATTINY4313 is not set +F_CPU=16000 + +# +# Compilation options +# +CHOST="avr-" +CCFLAGS="-Os -ffunction-sections -fdata-sections -fshort-enums -Wall" +CLDFLAGS="" +CBUILD="" +BUILD_CFLAGS="-Wall" +BUILD_LDFLAGS="" +# 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=y +MCUSUPPORT_USART=y +# CONFIG_USART is not set +# CONFIG_TIMERS is not set diff --git a/examples/spiblink/master/Kconfig b/examples/spiblink/master/Kconfig new file mode 100644 index 0000000..dc9e8b5 --- /dev/null +++ b/examples/spiblink/master/Kconfig @@ -0,0 +1,20 @@ +mainmenu "AVR-IOE spiblink master configuration" + +# We need CONFIG_IOPORTS, but we don't care about anything else. +config SPIBLINK_MASTER_DEFAULTS + bool + default y + select CONFIG_SPI + select CONFIG_IOPORTS + +config CONFIG_BUTTON_IO + string "Input pin used to connect button" + depends on SPIBLINK_MASTER_DEFAULTS + default "IO_C1" + +config CONFIG_LED_IO + string "Output pin used to connect test led" + depends on SPIBLINK_MASTER_DEFAULTS + default "IO_B0" + +source "../../../ioe.Kconfig" diff --git a/examples/spiblink/master/Makefile b/examples/spiblink/master/Makefile new file mode 100644 index 0000000..d412e92 --- /dev/null +++ b/examples/spiblink/master/Makefile @@ -0,0 +1,6 @@ +EXAMPLE_NAME = spiblink_master +EXAMPLE_PATH = spiblink/master +SRC = master.c + +IOEROOT=../../../ +include ../../examples.mk diff --git a/examples/spiblink/master/master.c b/examples/spiblink/master/master.c new file mode 100644 index 0000000..73a8aa9 --- /dev/null +++ b/examples/spiblink/master/master.c @@ -0,0 +1,17 @@ +#include <avr/io.h> +#include <util/delay.h> +#include <ioport.h> +#include <spi.h> + +int main() { + io_setin(CONFIG_BUTTON_IO, IO_PULLUP); + io_setout(CONFIG_LED_IO); + + spi_init(SPI_MODE_MASTER); + // SREG |= _BV(7); // Enable interrupts TODO I don't think that we need this + + while (1) { + io_set(CONFIG_LED_IO, io_get(CONFIG_BUTTON_IO)); + spi_send(io_get(CONFIG_BUTTON_IO)); + } +} diff --git a/examples/spiblink/slave.c b/examples/spiblink/slave.c deleted file mode 100644 index 91a8237..0000000 --- a/examples/spiblink/slave.c +++ /dev/null @@ -1,21 +0,0 @@ -#include <avr/io.h> -#include <util/delay.h> -#include <spi.h> - -void receive(uint8_t data); - -int main() { - DDRB |= _BV(DDB1); - spi_receive = receive; - spi_init(SPI_MODE_SLAVE); - SREG |= _BV(7); - while (1) { - } -} - -void receive(uint8_t data) { - if (data) - PORTB |= _BV(PORTB1); - else - PORTB &= ~_BV(PORTB1); -} diff --git a/examples/spiblink/slave/.config b/examples/spiblink/slave/.config new file mode 100644 index 0000000..31c10ea --- /dev/null +++ b/examples/spiblink/slave/.config @@ -0,0 +1,44 @@ +# +# Automatically generated file; DO NOT EDIT. +# AVR-IOE spiblink slave configuration +# +SPIBLINK_SLAVE_DEFAULTS=y +CONFIG_BLINK_IO="IO_B0" +MMCU="atmega328p" +ATMEGA328P=y +# ATMEGA168A is not set +# ATTINY85 is not set +# ATTINY4313 is not set +F_CPU=16000 + +# +# Compilation options +# +CHOST="avr-" +CCFLAGS="-Os -ffunction-sections -fdata-sections -fshort-enums -Wall" +CLDFLAGS="" +CBUILD="" +BUILD_CFLAGS="-Wall" +BUILD_LDFLAGS="" +CONFIG_ERRORS=y + +# +# Errors handling +# +# CONFIG_EH_RESTART is not set +# CONFIG_EH_HANG is not set +# CONFIG_EH_LED is not set +# CONFIG_ERROR_MESSAGES is not set +# CONFIG_ERROR_CALLBACK is not set +# CONFIG_CHECK_ARGUMENTS 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=y +MCUSUPPORT_USART=y +# CONFIG_USART is not set +# CONFIG_TIMERS is not set diff --git a/examples/spiblink/slave/Kconfig b/examples/spiblink/slave/Kconfig new file mode 100644 index 0000000..c264b9f --- /dev/null +++ b/examples/spiblink/slave/Kconfig @@ -0,0 +1,15 @@ +mainmenu "AVR-IOE spiblink slave configuration" + +# We need CONFIG_IOPORTS, but we don't care about anything else. +config SPIBLINK_SLAVE_DEFAULTS + bool + default y + select CONFIG_SPI + select CONFIG_IOPORTS + +config CONFIG_BLINK_IO + string "Output pin used to connect led" + depends on SPIBLINK_SLAVE_DEFAULTS + default "IO_B0" + +source "../../../ioe.Kconfig" diff --git a/examples/spiblink/slave/Makefile b/examples/spiblink/slave/Makefile new file mode 100644 index 0000000..7410058 --- /dev/null +++ b/examples/spiblink/slave/Makefile @@ -0,0 +1,6 @@ +EXAMPLE_NAME = spiblink_slave +EXAMPLE_PATH = spiblink/slave +SRC = slave.c + +IOEROOT=../../../ +include ../../examples.mk diff --git a/examples/spiblink/slave/slave.c b/examples/spiblink/slave/slave.c new file mode 100644 index 0000000..2a65323 --- /dev/null +++ b/examples/spiblink/slave/slave.c @@ -0,0 +1,19 @@ +#include <avr/io.h> +#include <util/delay.h> +#include <ioport.h> +#include <spi.h> + +void receive(uint8_t data); + +int main() { + io_setout(CONFIG_BLINK_IO); + + spi_receive = receive; + spi_init(SPI_MODE_SLAVE); + SREG |= _BV(7); // Enable global interrupts + while (1); // Busy loop +} + +void receive(uint8_t data) { + io_set(CONFIG_BLINK_IO, data); +} diff --git a/examples/usartecho/Makefile b/examples/usartecho/Makefile index 93a2783..c910843 100644 --- a/examples/usartecho/Makefile +++ b/examples/usartecho/Makefile @@ -1,4 +1,5 @@ EXAMPLE_NAME = usartecho SRC = echo.c +IOEROOT=../../ include ../examples.mk |