Contiki-NG
Loading...
Searching...
No Matches
nRF5340 Inter-Processor Communication

Files

file  nrf-ipc-radio.c
 IPC radio driver for the nRF5340 application core.
 
file  nrf-ipc.c
 IPC transport layer for nRF5340 inter-core communication.
 
file  nrf-ipc.h
 IPC protocol definitions for nRF5340 dual-core communication.
 

Data Structures

struct  nrf_ipc_msg
 IPC message structure used for both commands and responses. More...
 
struct  nrf_ipc_shared_mem
 Shared memory layout between the application core and the network core. More...
 

Macros

#define NRF_IPC_PROTOCOL_VERSION   1
 Protocol version.
 
#define NRF_IPC_SHARED_MEM_ADDR   0x20070000UL
 Shared memory address.
 
#define NRF_IPC_MAX_FRAME_LEN   128
 Maximum 802.15.4 frame size carried over IPC.
 
#define NRF_IPC_MAX_DATA_LEN   140
 Maximum data size in a command or response message.
 
#define NRF_IPC_CMD_TIMEOUT_MS   100
 Timeout in milliseconds for IPC command responses.
 
#define NRF_IPC_HEARTBEAT_INTERVAL_SEC   10
 Interval in seconds between net core heartbeat checks on the app core.
 
#define NRF_IPC_LOG_BUF_SIZE   2048
 Size of the log ring buffer for forwarding net core output to the app core.
 
#define NRF_IPC_SHARED_MEM    ((volatile struct nrf_ipc_shared_mem *)NRF_IPC_SHARED_MEM_ADDR)
 Get a pointer to the shared memory structure.
 

Enumerations

enum  nrf_ipc_cmd_type {
  NRF_IPC_CMD_INIT = 1 , NRF_IPC_CMD_ON , NRF_IPC_CMD_OFF , NRF_IPC_CMD_SEND ,
  NRF_IPC_CMD_CCA , NRF_IPC_CMD_RECEIVING , NRF_IPC_CMD_PENDING , NRF_IPC_CMD_GET_VALUE ,
  NRF_IPC_CMD_SET_VALUE , NRF_IPC_CMD_GET_OBJECT , NRF_IPC_CMD_SET_OBJECT , NRF_IPC_CMD_DIAG
}
 IPC command types (app core -> net core). More...
 

Functions

void nrf_ipc_init (struct process *callback_proc)
 Initialize the IPC transport layer.
 
void nrf_ipc_signal (void)
 Send an IPC signal to the other core.
 

Detailed Description

Macro Definition Documentation

◆ NRF_IPC_CMD_TIMEOUT_MS

#define NRF_IPC_CMD_TIMEOUT_MS   100

Timeout in milliseconds for IPC command responses.

If the net core does not respond within this time, send_command() returns -1.

Definition at line 87 of file nrf-ipc.h.

◆ NRF_IPC_HEARTBEAT_INTERVAL_SEC

#define NRF_IPC_HEARTBEAT_INTERVAL_SEC   10

Interval in seconds between net core heartbeat checks on the app core.

If the heartbeat counter has not advanced within this many seconds, the app core logs a warning.

Definition at line 96 of file nrf-ipc.h.

◆ NRF_IPC_MAX_FRAME_LEN

#define NRF_IPC_MAX_FRAME_LEN   128

Maximum 802.15.4 frame size carried over IPC.

The 802.15.4 PHY payload is 127 bytes; the nRF radio driver strips the 2-byte FCS, yielding up to 125 data bytes. We use 128 to provide a small margin for alignment and future use.

Definition at line 75 of file nrf-ipc.h.

Referenced by packet_input().

◆ NRF_IPC_PROTOCOL_VERSION

#define NRF_IPC_PROTOCOL_VERSION   1

Protocol version.

Both cores must agree on this value; the net core checks it at startup and refuses to proceed on mismatch.

Definition at line 55 of file nrf-ipc.h.

◆ NRF_IPC_SHARED_MEM_ADDR

#define NRF_IPC_SHARED_MEM_ADDR   0x20070000UL

Shared memory address.

Placed at the top of the application core's RAM1 region (0x20060000–0x2007FFFF, 128 KB), which is accessible from both cores. The nRF5340 application core has 512 KB total SRAM (0x20000000–0x2007FFFF). This address must not overlap with any linker-allocated region on either core.

See nRF5340 Product Specification, Section "Memory Map" for details.

Definition at line 66 of file nrf-ipc.h.

Enumeration Type Documentation

◆ nrf_ipc_cmd_type

IPC command types (app core -> net core).

Each command is sent via the shared memory mailbox. The response carries the result code in rsp.data[0]; additional response payload (if any) starts at rsp.data[1].

Enumerator
NRF_IPC_CMD_INIT 

Initialize the radio driver.

NRF_IPC_CMD_ON 

Turn the radio on.

NRF_IPC_CMD_OFF 

Turn the radio off.

NRF_IPC_CMD_SEND 

Transmit a frame (data in cmd.data).

NRF_IPC_CMD_CCA 

Perform Clear Channel Assessment.

NRF_IPC_CMD_RECEIVING 

Check if a frame is being received.

NRF_IPC_CMD_PENDING 

Check for pending received frames.

NRF_IPC_CMD_GET_VALUE 

Get a radio parameter (radio_value_t).

NRF_IPC_CMD_SET_VALUE 

Set a radio parameter (radio_value_t).

NRF_IPC_CMD_GET_OBJECT 

Get a radio parameter (object/blob).

NRF_IPC_CMD_SET_OBJECT 

Set a radio parameter (object/blob).

NRF_IPC_CMD_DIAG 

Read radio diagnostic registers (nRF5340-specific).

Response payload (20 bytes): [0-3] RADIO STATE register [4-7] EVENTS_CRCOK [8-11] EVENTS_CRCERROR [12-15] PACKETPTR [16-19] FREQUENCY register

Definition at line 111 of file nrf-ipc.h.

Function Documentation

◆ nrf_ipc_init()

void nrf_ipc_init ( struct process * callback_proc)

Initialize the IPC transport layer.

Configures IPC channels and enables interrupts. The callback process will be polled when an IPC signal is received.

Parameters
callback_procProcess to poll on IPC signal, or NULL.