aboutsummaryrefslogtreecommitdiff
path: root/examples/spiblink
diff options
context:
space:
mode:
Diffstat (limited to 'examples/spiblink')
-rw-r--r--examples/spiblink/Makefile66
-rw-r--r--examples/spiblink/config23
-rw-r--r--examples/spiblink/config.orig23
-rw-r--r--examples/spiblink/master.c20
-rw-r--r--examples/spiblink/master/.config35
-rw-r--r--examples/spiblink/master/Kconfig20
-rw-r--r--examples/spiblink/master/Makefile6
-rw-r--r--examples/spiblink/master/master.c17
-rw-r--r--examples/spiblink/slave.c21
-rw-r--r--examples/spiblink/slave/.config44
-rw-r--r--examples/spiblink/slave/Kconfig15
-rw-r--r--examples/spiblink/slave/Makefile6
-rw-r--r--examples/spiblink/slave/slave.c19
13 files changed, 162 insertions, 153 deletions
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);
+}