MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Mailbox

Overview

The MCUXpresso SDK provides a peripheral driver for the Mailbox module of MCUXpresso SDK devices.

The mailbox driver API provide:

Typical use case

Example of code on primary core, which cause interrupt on secondary core by writing to mailbox register.

int main(void)
{
/* Init Mailbox */
MAILBOX_Init(MAILBOX);
uint32_t message = 1;
/* Write message to CM0+ mailbox register - it causes interrupt on CM0+ core */
MAILBOX_SetValue(MAILBOX, kMAILBOX_CM0Plus, message);
}

Example of code on secondary core to handle interrupt from primary core.

void MAILBOX_IRQHandler()
{
/* Read message from CM0+ mailbox register, sent by primary core */
uint32_t message;
message = MAILBOX_GetValue(MAILBOX, kMAILBOX_CM0Plus);
/* Clear mailbox CM0+ mailbox register */
MAILBOX_ClearValueBits(MAILBOX, kMAILBOX_CM0Plus, 0xffffffff);
}
int main(void)
{
/* Init Mailbox */
MAILBOX_Init(MAILBOX);
/* Enable mailbox interrupt */
NVIC_EnableIRQ(MAILBOX_IRQn);
while (1)
{
__WFI();
}
}

Example of code to get/set mutex.

/* Shared variable by both cores */
volatile uint32_t g_shared = 0;
int main(void)
{
/* Init Mailbox */
MAILBOX_Init(MAILBOX);
/* The core try get the mailbox mutex */
while (MAILBOX_GetMutex(MAILBOX) == 0)
{}
/* The core has mutex, can change shared variable g_shared */
g_shared++;
/* Set mutex to allow access other core to shared variable */
MAILBOX_SetMutex(MAILBOX);
}

Files

file  fsl_mailbox.h
 

Enumerations

enum  mailbox_cpu_id_t
 CPU ID.
 

Functions

static void MAILBOX_SetValue (MAILBOX_Type *base, mailbox_cpu_id_t cpu_id, uint32_t mboxData)
 Set data value in the mailbox based on the CPU ID. More...
 
static uint32_t MAILBOX_GetValue (MAILBOX_Type *base, mailbox_cpu_id_t cpu_id)
 Get data in the mailbox based on the CPU ID. More...
 
static void MAILBOX_SetValueBits (MAILBOX_Type *base, mailbox_cpu_id_t cpu_id, uint32_t mboxSetBits)
 Set data bits in the mailbox based on the CPU ID. More...
 
static void MAILBOX_ClearValueBits (MAILBOX_Type *base, mailbox_cpu_id_t cpu_id, uint32_t mboxClrBits)
 Clear data bits in the mailbox based on the CPU ID. More...
 
static uint32_t MAILBOX_GetMutex (MAILBOX_Type *base)
 Get MUTEX state and lock mutex. More...
 
static void MAILBOX_SetMutex (MAILBOX_Type *base)
 Set MUTEX state. More...
 

Driver version

#define FSL_MAILBOX_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 MAILBOX driver version 2.0.0. More...
 

MAILBOX initialization

static void MAILBOX_Init (MAILBOX_Type *base)
 Initializes the MAILBOX module. More...
 
static void MAILBOX_Deinit (MAILBOX_Type *base)
 De-initializes the MAILBOX module. More...
 

Macro Definition Documentation

#define FSL_MAILBOX_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Function Documentation

static void MAILBOX_Init ( MAILBOX_Type *  base)
inlinestatic

This function enables the MAILBOX clock only.

Parameters
baseMAILBOX peripheral base address.
static void MAILBOX_Deinit ( MAILBOX_Type *  base)
inlinestatic

This function disables the MAILBOX clock only.

Parameters
baseMAILBOX peripheral base address.
static void MAILBOX_SetValue ( MAILBOX_Type *  base,
mailbox_cpu_id_t  cpu_id,
uint32_t  mboxData 
)
inlinestatic
Parameters
baseMAILBOX peripheral base address.
cpu_idCPU id, kMAILBOX_CM0Plus is M0+ or kMAILBOX_CM4 is M4.
mboxDataData to send in the mailbox.
Note
Sets a data value to send via the MAILBOX to the other core.
static uint32_t MAILBOX_GetValue ( MAILBOX_Type *  base,
mailbox_cpu_id_t  cpu_id 
)
inlinestatic
Parameters
baseMAILBOX peripheral base address.
cpu_idCPU id, kMAILBOX_CM0Plus is M0+ or kMAILBOX_CM4 is M4.
Returns
Current mailbox data.
static void MAILBOX_SetValueBits ( MAILBOX_Type *  base,
mailbox_cpu_id_t  cpu_id,
uint32_t  mboxSetBits 
)
inlinestatic
Parameters
baseMAILBOX peripheral base address.
cpu_idCPU id, kMAILBOX_CM0Plus is M0+ or kMAILBOX_CM4 is M4.
mboxSetBitsData bits to set in the mailbox.
Note
Sets data bits to send via the MAILBOX to the other core. A value of 0 will do nothing. Only sets bits selected with a 1 in it's bit position.
static void MAILBOX_ClearValueBits ( MAILBOX_Type *  base,
mailbox_cpu_id_t  cpu_id,
uint32_t  mboxClrBits 
)
inlinestatic
Parameters
baseMAILBOX peripheral base address.
cpu_idCPU id, kMAILBOX_CM0Plus is M0+ or kMAILBOX_CM4 is M4.
mboxClrBitsData bits to clear in the mailbox.
Note
Clear data bits to send via the MAILBOX to the other core. A value of 0 will do nothing. Only clears bits selected with a 1 in it's bit position.
static uint32_t MAILBOX_GetMutex ( MAILBOX_Type *  base)
inlinestatic
Parameters
baseMAILBOX peripheral base address.
Returns
See note
Note
Returns '1' if the mutex was taken or '0' if another resources has the mutex locked. Once a mutex is taken, it can be returned with the MAILBOX_SetMutex() function.
static void MAILBOX_SetMutex ( MAILBOX_Type *  base)
inlinestatic
Parameters
baseMAILBOX peripheral base address.
Note
Sets mutex state to '1' and allows other resources to get the mutex.