aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-03-09 07:04:55 +0100
committerKarel Kočí <cynerd@email.cz>2017-03-09 07:04:55 +0100
commitdfc471c4f68eba0c054e61dbb3567ee89e3a036f (patch)
tree69b6ee6b5be7da3087d782397cb0ec04734f23a9
parent171e8e92686ac65e8f9a2962a975e6863c791a4f (diff)
downloadavr-ioe-dfc471c4f68eba0c054e61dbb3567ee89e3a036f.tar.gz
avr-ioe-dfc471c4f68eba0c054e61dbb3567ee89e3a036f.tar.bz2
avr-ioe-dfc471c4f68eba0c054e61dbb3567ee89e3a036f.zip
Update spiblink example to use examples.mk
-rw-r--r--Makefile1
-rw-r--r--examples/blink/Kconfig5
-rw-r--r--examples/blink/Makefile1
-rw-r--r--examples/blink/blink.c6
-rw-r--r--examples/examples.mk16
-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
-rw-r--r--examples/usartecho/Makefile1
-rw-r--r--include/ioport.h2
-rw-r--r--include/spi.h55
-rw-r--r--src/spi.c9
22 files changed, 213 insertions, 198 deletions
diff --git a/Makefile b/Makefile
index ea96319..53b42a0 100644
--- a/Makefile
+++ b/Makefile
@@ -94,6 +94,7 @@ proper: clean clean-docs
.PHONY: help
help:
+ @echo "AVR input/output expansion library"
@echo "all/libioe.a - Build library"
@echo "config - Start configuration program"
@echo "menuconfig - NCurses based configuration program (Kconfig)"
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
diff --git a/include/ioport.h b/include/ioport.h
index 95b6205..1b6f806 100644
--- a/include/ioport.h
+++ b/include/ioport.h
@@ -30,7 +30,7 @@ static inline void io_set(uint8_t group, uint8_t mask, int8_t val) {
}
static inline void io_setin(uint8_t group, uint8_t mask,
- enum ioInResistor resistor) {
+ enum ioInResistor resistor) {
IO_DDR(group) &= ~mask;
if (resistor == IO_PULLUP)
IO_PORT(group) |= mask;
diff --git a/include/spi.h b/include/spi.h
index c4c003b..68b90ce 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -1,63 +1,60 @@
-// vim:ts=4:sw=4:sts=4:expandtab
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include "mcu/mcu_def.h"
-#include "tasks.h"
#ifndef _IOE_SPI_H_
#define _IOE_SPI_H_
#ifdef CONFIG_SPI
enum spiMode {
- SPI_MODE_MASTER,
- SPI_MODE_SLAVE
+ SPI_MODE_MASTER,
+ SPI_MODE_SLAVE
};
volatile extern int8_t _spi_busy;
-volatile extern Mutex spi_mutex;
static inline void spi_init(enum spiMode mode) {
- _spi_busy = 0;
- if (mode == SPI_MODE_MASTER) {
- // Set MOSI and SCK output
- DDR_SPI |= _BV(DD_MOSI) | _BV(DD_SCLK);
- // Set MISO pull up resistor
- PORT_SPI |= _BV(PORT_MISO);
- // Enable SPI master, set clock rate fck/16 and enable SPI interrupt
- SPCR = _BV(SPE) | _BV(SPIE) | _BV(MSTR) | _BV(SPR0);
- } else {
- // Set MISO as output
- DDR_SPI |= _BV(DD_MISO);
- // Set SCLK and MOSI pull up resistor
- PORT_SPI |= _BV(PORT_SCLK) | _BV(PORT_MOSI);
- // Enable SPI and interrupt
- SPCR = _BV(SPE) | _BV(SPIE);
- }
+ _spi_busy = 0;
+ if (mode == SPI_MODE_MASTER) {
+ // Set MOSI and SCK output
+ DDR_SPI |= _BV(DD_MOSI) | _BV(DD_SCLK);
+ // Set MISO pull up resistor
+ PORT_SPI |= _BV(PORT_MISO);
+ // Enable SPI master, set clock rate fck/16 and enable SPI interrupt
+ SPCR = _BV(SPE) | _BV(SPIE) | _BV(MSTR) | _BV(SPR0);
+ } else {
+ // Set MISO as output
+ DDR_SPI |= _BV(DD_MISO);
+ // Set SCLK and MOSI pull up resistor
+ PORT_SPI |= _BV(PORT_SCLK) | _BV(PORT_MOSI);
+ // Enable SPI and interrupt
+ SPCR = _BV(SPE) | _BV(SPIE);
+ }
}
static inline int8_t spi_busy(void) {
- return _spi_busy;
+ return _spi_busy;
}
static inline void spi_join(void) {
- task_delay_till(&_spi_busy, 0);
+ while(!_spi_busy) ;
}
static inline void spi_transfer(uint8_t data) {
- _spi_busy = 1;
- SPDR = data;
+ _spi_busy = 1;
+ SPDR = data;
}
static inline uint8_t spi_send(uint8_t data) {
- spi_transfer(data);
- task_delay_till(&_spi_busy, 0);
- return SPDR;
+ spi_transfer(data);
+ spi_join();
+ return SPDR;
}
static inline void spi_expose(uint8_t data) {
- SPDR = data;
+ SPDR = data;
}
extern void (*spi_receive)(uint8_t data);
diff --git a/src/spi.c b/src/spi.c
index adf858d..d7af297 100644
--- a/src/spi.c
+++ b/src/spi.c
@@ -3,15 +3,14 @@
#ifdef CONFIG_SPI
volatile int8_t _spi_busy;
-volatile Mutex spi_mutex;
void (*spi_receive) (uint8_t data) = 0;
ISR(SPI_STC_vect, ISR_BLOCK) {
- _spi_busy = 0;
- if (spi_receive != NULL) {
- spir_w(SPDR);
- }
+ _spi_busy = 0;
+ if (spi_receive != 0) {
+ spi_receive(SPDR);
+ }
}
#endif /* CONFIG_SPI */