Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfc: Introduce Zero Latency IRQ #13248

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dchat-nordic
Copy link
Contributor

@dchat-nordic dchat-nordic commented Nov 28, 2023

Introduce Zero Latency IRQ in NFC Platform.
The Zero Latency IRQ is an improvement on NFC
processing latency with cost of a single SWI interrupt.

@github-actions github-actions bot added the changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. label Nov 28, 2023
#endif /* CONFIG_NFC_LOW_LATENCY_IRQ */
#endif /* CONFIG_NFC_ZERO_LATENCY_IRQ */

#define HFCLK_NONE 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum?

static atomic_t clk_mode;
#endif /* CONFIG_NFC_ZERO_LATENCY_IRQ */

static void hfclk_set(uint32_t mode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static void hfclk_set(uint32_t mode)
static void hfclk_set(uint32_t mode)

enum?

ISR_DIRECT_DECLARE(nfc_swi_handler)
{
atomic_val_t tmp;

tmp = atomic_set(&clk_mode, HFCLK_NONE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if atomic would have any effect in our case. Probably using just volatile would make sense

ISR_DIRECT_DECLARE(nfc_swi_handler)
{
atomic_val_t tmp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could remember previous clock status and check it in this function to prevent doing the same operation few times

@github-actions github-actions bot added doc-required PR must not be merged without tech writer approval. and removed changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. labels Nov 29, 2023
@dchat-nordic dchat-nordic marked this pull request as ready for review December 6, 2023 10:08
Comment on lines 515 to 517
* Added:

* Support for zero-latency interrupts for NFC.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Added:
* Support for zero-latency interrupts for NFC.
* Added support for zero-latency interrupts for all NFC libraries.

If this is added for all of them.

@@ -33,6 +33,33 @@ extern "C" {
*/
int nfc_platform_internal_init(nfc_lib_cb_resolve_t cb_rslv);

/** @brief Function for initializing internal hfclk control.
Copy link
Contributor

@peknis peknis Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** @brief Function for initializing internal hfclk control.
/** @brief Initialize internal hfclk control.

What is hfclk? Should we open it in the first instance?

*/
int nfc_platform_internal_hfclk_init(void);

/** @brief Function for starting hfclk.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** @brief Function for starting hfclk.
/** @brief Start hfclk.

*/
int nfc_platform_internal_hfclk_start(void);

/** @brief Function for stopping hfclk.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** @brief Function for stopping hfclk.
/** @brief Stop hfclk.

Comment on lines 48 to 54
#ifdef CONFIG_NFC_ZERO_LATENCY_IRQ
IRQ_DIRECT_CONNECT(NFCT_IRQn, CONFIG_NFCT_IRQ_PRIORITY,
nfc_isr_wrapper, IRQ_ZERO_LATENCY);
#else
IRQ_DIRECT_CONNECT(NFCT_IRQn, CONFIG_NFCT_IRQ_PRIORITY,
nfc_isr_wrapper, 0);
#endif /* CONFIG_NFC_ZERO_LATENCY_IRQ */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#ifdef CONFIG_NFC_ZERO_LATENCY_IRQ
IRQ_DIRECT_CONNECT(NFCT_IRQn, CONFIG_NFCT_IRQ_PRIORITY,
nfc_isr_wrapper, IRQ_ZERO_LATENCY);
#else
IRQ_DIRECT_CONNECT(NFCT_IRQn, CONFIG_NFCT_IRQ_PRIORITY,
nfc_isr_wrapper, 0);
#endif /* CONFIG_NFC_ZERO_LATENCY_IRQ */
IRQ_DIRECT_CONNECT(NFCT_IRQn, CONFIG_NFCT_IRQ_PRIORITY,
nfc_isr_wrapper, NFCT_IRQ_FLAGS);

What do you think about using the NFCT_IRQ_FLAGS definition?
This way we avoid conditional compilation at this place.

@@ -80,14 +80,15 @@ config NFC_THREAD_PRIORITY

endif# NFC_OWN_THREAD

config NFC_LOW_LATENCY_IRQ
bool "Use low latency IRQ for NFC"
config NFC_ZERO_LATENCY_IRQ
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Experimental?

{
switch (event->evt_id) {
case NRFX_NFCT_EVT_FIELD_DETECTED:
#ifdef CONFIG_NFC_ZERO_LATENCY_IRQ
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My general suggestion is to avoid conditional compilation by using IS_ENABLED()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't be swapped here because of clk_mode variable which is conditional.

@KAGA164
Copy link
Contributor

KAGA164 commented Dec 12, 2023

I also noticed error log:
E: Tried to read header: 4 bytes, read 0.
E: Reading nfc ring buffer failed, resetting ring buffer.

@NordicBuilder
Copy link
Contributor

NordicBuilder commented Dec 20, 2023

Test specification

CI/Jenkins/NRF

  • Integration Platforms

CI/Jenkins/integration

Test Module File based changes Manually selected West overwrite
test-sdk-find-my X

Detailed information of selected test modules

Note: This message is automatically posted and updated by the CI

@NordicBuilder
Copy link
Contributor

You can find the documentation preview for this PR at this link. It will be updated about 10 minutes after the documentation build succeeds.

Note: This comment is automatically posted by the Documentation Publishing GitHub Action.

Introduce Zero Latency IRQ in NFC Platform.
The Zero Latency IRQ is an improvement on NFC
processing latency with cost of a single SWI interrupt.

Jira: NCSDK-23347

Signed-off-by: Dominik Chat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DNM doc-required PR must not be merged without tech writer approval.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants