From 589af14217ce2024da73524a8dc74ea581e51fcd Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sat, 30 Jan 2016 14:05:03 -0500 Subject: 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 --- samples/microkernel/apps/nfc_hello/Makefile | 8 -- samples/microkernel/apps/nfc_hello/README.txt | 2 - samples/microkernel/apps/nfc_hello/prj.conf | 3 - samples/microkernel/apps/nfc_hello/src/Makefile | 3 - samples/microkernel/apps/nfc_hello/src/main.c | 97 ------------------------- samples/microkernel/apps/nfc_hello/testcase.ini | 7 -- samples/nfc/nfc_hello/Makefile | 7 ++ samples/nfc/nfc_hello/README.txt | 2 + samples/nfc/nfc_hello/prj.conf | 3 + samples/nfc/nfc_hello/src/Makefile | 3 + samples/nfc/nfc_hello/src/main.c | 97 +++++++++++++++++++++++++ samples/nfc/nfc_hello/testcase.ini | 7 ++ 12 files changed, 119 insertions(+), 120 deletions(-) delete mode 100644 samples/microkernel/apps/nfc_hello/Makefile delete mode 100644 samples/microkernel/apps/nfc_hello/README.txt delete mode 100644 samples/microkernel/apps/nfc_hello/prj.conf delete mode 100644 samples/microkernel/apps/nfc_hello/src/Makefile delete mode 100644 samples/microkernel/apps/nfc_hello/src/main.c delete mode 100644 samples/microkernel/apps/nfc_hello/testcase.ini create mode 100644 samples/nfc/nfc_hello/Makefile create mode 100644 samples/nfc/nfc_hello/README.txt create mode 100644 samples/nfc/nfc_hello/prj.conf create mode 100644 samples/nfc/nfc_hello/src/Makefile create mode 100644 samples/nfc/nfc_hello/src/main.c create mode 100644 samples/nfc/nfc_hello/testcase.ini (limited to 'samples') diff --git a/samples/microkernel/apps/nfc_hello/Makefile b/samples/microkernel/apps/nfc_hello/Makefile deleted file mode 100644 index d2ae4548d..000000000 --- a/samples/microkernel/apps/nfc_hello/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -KERNEL_TYPE ?= nano -BOARD ?= qemu_x86 -CONF_FILE = prj.conf -SOURCE_DIR = $(ZEPHYR_BASE)/samples/microkernel/apps/nfc_hello/src/ - -QEMU_EXTRA_FLAGS += -serial tcp:localhost:8888 - -include ${ZEPHYR_BASE}/Makefile.inc diff --git a/samples/microkernel/apps/nfc_hello/README.txt b/samples/microkernel/apps/nfc_hello/README.txt deleted file mode 100644 index 554e6bcb5..000000000 --- a/samples/microkernel/apps/nfc_hello/README.txt +++ /dev/null @@ -1,2 +0,0 @@ -This is a simple application to test an elementary signal-through -with NFC module connected to the second UART. diff --git a/samples/microkernel/apps/nfc_hello/prj.conf b/samples/microkernel/apps/nfc_hello/prj.conf deleted file mode 100644 index 0856b34c9..000000000 --- a/samples/microkernel/apps/nfc_hello/prj.conf +++ /dev/null @@ -1,3 +0,0 @@ -CONFIG_STDOUT_CONSOLE=y -CONFIG_UART_INTERRUPT_DRIVEN=y -CONFIG_NUM_DYNAMIC_STUBS=1 diff --git a/samples/microkernel/apps/nfc_hello/src/Makefile b/samples/microkernel/apps/nfc_hello/src/Makefile deleted file mode 100644 index dec2a41f9..000000000 --- a/samples/microkernel/apps/nfc_hello/src/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -ccflags-y += -I${ZEPHYR_BASE}/include/drivers - -obj-y = main.o diff --git a/samples/microkernel/apps/nfc_hello/src/main.c b/samples/microkernel/apps/nfc_hello/src/main.c deleted file mode 100644 index 18a3e4263..000000000 --- a/samples/microkernel/apps/nfc_hello/src/main.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * 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 -#include -#include -#include - -#include -#include - -#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/microkernel/apps/nfc_hello/testcase.ini b/samples/microkernel/apps/nfc_hello/testcase.ini deleted file mode 100644 index 765172c06..000000000 --- a/samples/microkernel/apps/nfc_hello/testcase.ini +++ /dev/null @@ -1,7 +0,0 @@ -[test] -build_only = true -tags = apps -arch_whitelist = x86 -# Doesn't work for ia32_pci -config_whitelist = CONFIG_SOC="ia32" - 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 +#include +#include +#include + +#include +#include + +#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" + -- cgit v1.2.3