Skip to content

Commit

Permalink
🚀 deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
KafCoppelia committed Sep 17, 2023
1 parent b1a3cb7 commit 8f30e30
Show file tree
Hide file tree
Showing 6 changed files with 488 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ modules.order
Module.symvers
Mkfile.old
dkms.conf

build
.vscode
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2020 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)
set(BOARD nrf7002dk_nrf5340_cpuapp)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(nfc_function_switching)

FILE(GLOB app_sources src/*.c)

# NORDIC SDK APP START
target_sources(app PRIVATE ${app_sources})

# NORDIC SDK APP END
116 changes: 116 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
.. _nrf-nfc-system-off-sample:

NFC: System OFF
###############

.. contents::
:local:
:depth: 2

The NFC System OFF sample shows how to make the NFC Tag device wake up from the System OFF mode when it detects the NFC field.
The sample uses the :ref:`lib_nfc_ndef`.

Requirements
************

The sample supports the following development kits:

.. table-from-sample-yaml::

.. include:: /includes/tfm.txt

The sample also requires a smartphone or tablet with the NFC feature.

Overview
********

The sample starts with the initialization of the NFC Tag device.
The device then attempts to detect an external NFC field.
If the field is not detected within three seconds, the device goes into the System OFF mode.

The device wakes up from the System OFF mode when an NFC field is detected.
The system is started and the NFC Tag device is reinitialized.
The tag can be read afterwards.

When the NFC field is not within range anymore, the device goes back to the System OFF mode.

You do not necessarily need a fully working NFC Tag for the wake-up.
You can use the NFCT peripheral registers directly.
In this case, the reader cannot read anything, but it can wake up the system.

When using the registers to wake up the device, replace :c:func:`start_nfc()` with the following function:

.. code-block:: c
void field_sens_start(void)
{
int key = irq_lock();
/* First check if NFCT is not already sensing. */
if ((NRF_NFCT->NFCTAGSTATE & NFCT_NFCTAGSTATE_NFCTAGSTATE_Msk)
== NFCT_NFCTAGSTATE_NFCTAGSTATE_Disabled) {
NRF_NFCT->TASKS_SENSE = 1;
}
irq_unlock(key);
}
See the `System OFF mode`_ page in the nRF52840 Product Specification for more information.

User interface
**************

LED 1:
Lit when an NFC field is present within range.

LED 2:
Lit when the system is on.

Building and running
********************

.. |sample path| replace:: :file:`samples/nfc/system_off`

.. include:: /includes/build_and_run_ns.txt

.. note::
|nfc_nfct_driver_note|

Testing
=======

After programming the sample to your development kit, complete the following steps to test it:

1. Observe that **LED 2** on the Tag device turns off three seconds after the programming has completed.
This indicates that the system is in the System OFF mode.
#. Make sure that the NFC feature is activated on the smartphone or tablet.
Check the device documentation on how to enable the NFC feature.
#. With the smartphone or tablet, touch the NFC antenna of the NFC Tag device.
#. Observe that **LED 2** on the Tag device is lit, followed by **LED 1** shortly after that.
Also a "Hello World!" notification appears on the smartphone or tablet.
The notification text is obtained from NFC.
#. Move the smartphone or tablet away from the NFC antenna.
**LED 1** turns off.
#. Observe that **LED 2** on the Tag device turns off after three seconds.
This indicates that system is in the System OFF mode again.

Dependencies
************

This sample uses the following |NCS| libraries:

* :ref:`nfc_ndef_msg`
* :ref:`nfc_text`

In addition, it uses the Type 2 Tag library from `sdk-nrfxlib`_:

* :ref:`nrfxlib:nfc_api_type2`

The sample uses the following Zephyr libraries:

* ``include/zephyr.h``
* ``include/device.h``
* ``include/power/power.h``
* :ref:`GPIO Interface <zephyr:api_peripherals>`

The sample also uses the following secure firmware component:

* :ref:`Trusted Firmware-M <ug_tfm>`
18 changes: 18 additions & 0 deletions prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2020 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_NCS_SAMPLES_DEFAULTS=y
CONFIG_REBOOT=y
CONFIG_DK_LIBRARY=y

CONFIG_NFC_T2T_NRFXLIB=y

CONFIG_NFC_NDEF=y
CONFIG_NFC_NDEF_MSG=y
CONFIG_NFC_NDEF_RECORD=y
CONFIG_NFC_NDEF_TEXT_RECORD=y
CONFIG_NFC_NDEF_URI_REC=y
CONFIG_NFC_NDEF_LAUNCHAPP_MSG=y
14 changes: 14 additions & 0 deletions sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sample:
description: Switch NFC functions between recording text & launcing app.
name: NFC Functions Switching
tests:
sample.nfc.function_switching:
build_only: true
integration_platforms:
- nrf52840dk_nrf52840
- nrf52dk_nrf52832
- nrf5340dk_nrf5340_cpuapp
- nrf5340dk_nrf5340_cpuapp_ns
platform_allow: nrf52840dk_nrf52840 nrf52dk_nrf52832 nrf5340dk_nrf5340_cpuapp
nrf5340dk_nrf5340_cpuapp_ns
tags: ci_build
Loading

0 comments on commit 8f30e30

Please sign in to comment.