summaryrefslogtreecommitdiff
path: root/samples/nfc
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2016-01-30 14:05:03 -0500
committerAnas Nashif <anas.nashif@intel.com>2016-02-11 13:08:44 -0500
commit589af14217ce2024da73524a8dc74ea581e51fcd (patch)
tree92398667b392af95bc55d2055db902303006b741 /samples/nfc
parent74df249dd81468138ed11bacee746f2544c31968 (diff)
nfc: move sample app under samples/nfc
This sample goes under samples/nfc directory where we will have all nfc related samples. Change-Id: I6e7664d8e0dcbfcb0d9e11e2c7b79d8217665757 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Diffstat (limited to 'samples/nfc')
-rw-r--r--samples/nfc/nfc_hello/Makefile7
-rw-r--r--samples/nfc/nfc_hello/README.txt2
-rw-r--r--samples/nfc/nfc_hello/prj.conf3
-rw-r--r--samples/nfc/nfc_hello/src/Makefile3
-rw-r--r--samples/nfc/nfc_hello/src/main.c97
-rw-r--r--samples/nfc/nfc_hello/testcase.ini7
6 files changed, 119 insertions, 0 deletions
diff --git a/samples/nfc/nfc_hello/Makefile b/samples/nfc/nfc_hello/Makefile
new file mode 100644
index 000000000..33c3ed6c2
--- /dev/null
+++ b/samples/nfc/nfc_hello/Makefile
@@ -0,0 +1,7 @@
+KERNEL_TYPE ?= nano
+BOARD ?= qemu_x86
+CONF_FILE = prj.conf
+
+QEMU_EXTRA_FLAGS += -serial tcp:localhost:8888
+
+include ${ZEPHYR_BASE}/Makefile.inc
diff --git a/samples/nfc/nfc_hello/README.txt b/samples/nfc/nfc_hello/README.txt
new file mode 100644
index 000000000..554e6bcb5
--- /dev/null
+++ b/samples/nfc/nfc_hello/README.txt
@@ -0,0 +1,2 @@
+This is a simple application to test an elementary signal-through
+with NFC module connected to the second UART.
diff --git a/samples/nfc/nfc_hello/prj.conf b/samples/nfc/nfc_hello/prj.conf
new file mode 100644
index 000000000..0856b34c9
--- /dev/null
+++ b/samples/nfc/nfc_hello/prj.conf
@@ -0,0 +1,3 @@
+CONFIG_STDOUT_CONSOLE=y
+CONFIG_UART_INTERRUPT_DRIVEN=y
+CONFIG_NUM_DYNAMIC_STUBS=1
diff --git a/samples/nfc/nfc_hello/src/Makefile b/samples/nfc/nfc_hello/src/Makefile
new file mode 100644
index 000000000..dec2a41f9
--- /dev/null
+++ b/samples/nfc/nfc_hello/src/Makefile
@@ -0,0 +1,3 @@
+ccflags-y += -I${ZEPHYR_BASE}/include/drivers
+
+obj-y = main.o
diff --git a/samples/nfc/nfc_hello/src/main.c b/samples/nfc/nfc_hello/src/main.c
new file mode 100644
index 000000000..18a3e4263
--- /dev/null
+++ b/samples/nfc/nfc_hello/src/main.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <zephyr.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+
+#include <board.h>
+#include <uart.h>
+
+#define UART1_IRQ CONFIG_UART_NS16550_PORT_1_IRQ
+#define UART1_IRQ_PRI CONFIG_UART_NS16550_PORT_1_IRQ_PRI
+#define BUF_MAXSIZE 256
+
+struct device *uart1_dev;
+
+#define D(fmt, args...) \
+do { \
+ printf("%s() " fmt "\n", __func__, ## args); \
+} while (0)
+
+
+static uint8_t buf[BUF_MAXSIZE];
+static uint8_t nci_reset[] = { 0x20, 0x00, 0x01, 0x00 };
+
+
+static inline const uint32_t htonl(uint32_t x)
+{
+ __asm__ __volatile__ ("bswap %0" : "=r" (x) : "0" (x));
+ return x;
+}
+
+static void msg_dump(const char *s, uint8_t *data, unsigned len)
+{
+ unsigned i;
+ printf("%s: ", s);
+ for (i = 0; i < len; i++)
+ printf("%02x ", data[i]);
+ printf("(%u bytes)\n", len);
+}
+
+static void uart1_isr(void *x)
+{
+ int len = uart_fifo_read(uart1_dev, buf, BUF_MAXSIZE);
+ ARG_UNUSED(x);
+ msg_dump(__func__, buf, len);
+}
+
+static void uart1_init(void)
+{
+ uart1_dev = device_get_binding("UART_1");
+
+ IRQ_CONNECT(UART1_IRQ, UART1_IRQ_PRI, uart1_isr, 0, UART_IRQ_FLAGS);
+
+ irq_enable(UART1_IRQ);
+
+ uart_irq_rx_enable(uart1_dev);
+
+ D("done");
+}
+
+void main(void)
+{
+ struct nano_timer t;
+ void *t_data;
+ uint8_t *pdu = buf;
+ uint32_t *len = (void *) pdu;
+
+ nano_timer_init(&t, &t_data);
+
+ uart1_init();
+
+ *len = htonl(sizeof(nci_reset));
+
+ memcpy(pdu + sizeof(*len), nci_reset, sizeof(nci_reset));
+
+ uart_fifo_fill(uart1_dev, pdu, sizeof(*len) + sizeof(nci_reset));
+
+ while (1) {
+ nano_task_timer_start(&t, MSEC(500));
+ nano_task_timer_test(&t, TICKS_UNLIMITED);
+ }
+}
diff --git a/samples/nfc/nfc_hello/testcase.ini b/samples/nfc/nfc_hello/testcase.ini
new file mode 100644
index 000000000..765172c06
--- /dev/null
+++ b/samples/nfc/nfc_hello/testcase.ini
@@ -0,0 +1,7 @@
+[test]
+build_only = true
+tags = apps
+arch_whitelist = x86
+# Doesn't work for ia32_pci
+config_whitelist = CONFIG_SOC="ia32"
+