From dfc471c4f68eba0c054e61dbb3567ee89e3a036f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 9 Mar 2017 07:04:55 +0100 Subject: Update spiblink example to use examples.mk --- examples/spiblink/master/.config | 35 +++++++++++++++++++++++++++++++++++ examples/spiblink/master/Kconfig | 20 ++++++++++++++++++++ examples/spiblink/master/Makefile | 6 ++++++ examples/spiblink/master/master.c | 17 +++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 examples/spiblink/master/.config create mode 100644 examples/spiblink/master/Kconfig create mode 100644 examples/spiblink/master/Makefile create mode 100644 examples/spiblink/master/master.c (limited to 'examples/spiblink/master') 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 +#include +#include +#include + +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)); + } +} -- cgit v1.2.3