From e48054c22284be22cfc02c20c4861ce6c5beca42 Mon Sep 17 00:00:00 2001 From: Nicolas Pouillon Date: Wed, 2 Nov 2016 10:01:11 +0100 Subject: [PATCH] soft: Add NFC detect test --- software/tests/nfc_detect/Makefile | 1 + software/tests/nfc_detect/config | 11 +++++++++ software/tests/nfc_detect/main.c | 38 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 software/tests/nfc_detect/Makefile create mode 100644 software/tests/nfc_detect/config create mode 100644 software/tests/nfc_detect/main.c diff --git a/software/tests/nfc_detect/Makefile b/software/tests/nfc_detect/Makefile new file mode 100644 index 0000000..85ec727 --- /dev/null +++ b/software/tests/nfc_detect/Makefile @@ -0,0 +1 @@ +objs += main.o diff --git a/software/tests/nfc_detect/config b/software/tests/nfc_detect/config new file mode 100644 index 0000000..6b422b8 --- /dev/null +++ b/software/tests/nfc_detect/config @@ -0,0 +1,11 @@ +%set OUTPUT_NAME nfc +%append MODULES $(OUTPUT_NAME):$(CONFIGPATH) + +CONFIG_MUTEK_THREAD +CONFIG_LICENSE_APP_BSD +CONFIG_APP_START +CONFIG_MUTEK_CONTEXT_SCHED + +%inherit bmaaa-pinky +%inherit nfc +%include bmaaa.build diff --git a/software/tests/nfc_detect/main.c b/software/tests/nfc_detect/main.c new file mode 100644 index 0000000..3456ca0 --- /dev/null +++ b/software/tests/nfc_detect/main.c @@ -0,0 +1,38 @@ +#include +#include +#include + +#include + +static CONTEXT_ENTRY(nfc_main) +{ + error_t err; + struct device_nfc_s nfc; + struct dev_nfc_rq_s req; + struct dev_nfc_peer_s peer; + + req.peer = &peer; + peer.side = DEV_NFC_PASSIVE_PICC; + peer.protocol = DEV_NFC_14443A; + peer.atqa = 0; + + err = device_get_accessor_by_path(&nfc.base, NULL, "/nfc0", DRIVER_CLASS_NFC); + assert(!err); + + req.type = DEV_NFC_WRITE; + err = dev_nfc_wait_request(&nfc, &req); + assert(!err); + + req.type = DEV_NFC_READ; + err = dev_nfc_wait_request(&nfc, &req); + assert(!err); +} + +void app_start(void) +{ + struct thread_attr_s attr = { + .stack_size = 1024, + }; + + thread_create(nfc_main, 0, &attr); +} -- GitLab