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

Overview

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

Function description

The MU driver provides these functions:

MU initialization

The function MU_Init() initializes the MU module and enables the MU clock. It should be called before any other MU functions.
The function MU_Deinit() deinitializes the MU module and disables the MU clock. No MU functions can be called after this function.

MU message

The MU message must be sent when the transmit register is empty. The MU driver provides blocking API and non-blocking API to send message.
The MU_SendMsgNonBlocking() function writes a message to the MU transmit register without checking the transmit register status. The upper layer should check that the transmit register is empty before calling this function. This function can be used in the ISR for better performance.
The MU_SendMsg() function is a blocking function. It waits until the transmit register is empty and sends the message.
Correspondingly, there are blocking and non-blocking APIs for receiving a message. The MU_ReadMsgNonBlocking() function is a non-blocking API. The MU_ReadMsg() function is the blocking API.

MU flags

The MU driver provides 3-bit general purpose flags. When the flags are set on one side, they are reflected on the other side.
The MU flags must be set when the previous flags have been updated to the other side. The MU driver provides a non-blocking function and a blocking function. The blocking function MU_SetFlags() waits until previous flags have been updated to the other side and then sets flags. The non-blocking function sets the flags directly. Ensure that the kMU_FlagsUpdatingFlag is not pending before calling this function.
The function MU_GetFlags() gets the MU flags on the current side.

Status and interrupt

The function MU_GetStatusFlags() returns all MU status flags. Use the _mu_status_flags to check for specific flags, for example, to check RX0 and RX1 register full, use the following code:

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/mu The receive full flags are cleared automatically after messages are read out. The transmit empty flags are cleared automatically after new messages are written to the transmit register. The general purpose interrupt flags must be cleared manually using the function MU_ClearStatusFlags().
Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/mu To enable or disable a specific interrupt, use MU_EnableInterrupts() and MU_DisableInterrupts() functions. The interrupts to enable or disable should be passed in as a bit mask of the _mu_interrupt_enable.
The MU_TriggerInterrupts() function triggers general purpose interrupts and NMI to the other core. The interrupts to trigger are passed in as a bit mask of the _mu_interrupt_trigger. If previously triggered interrupts have not been processed by the other side, this function returns an error.

MU misc functions

The MU_BootCoreB() and MU_HoldCoreBReset() functions should only be used from A side. They are used to boot the core B or to hold core B in reset.
The MU_ResetBothSides() function resets MU at both A and B sides. However, only the A side can call this function.
If a core enters stop mode, the platform clock of this core is disabled by default. The function MU_SetClockOnOtherCoreEnable() forces the other core's platform clock to remain enabled even after that core has entered a stop mode. In this case, the other core's platform clock keeps running until the current core enters stop mode too.
Function MU_GetOtherCorePowerMode() gets the power mode of the other core.

Enumerations

enum  _mu_status_flags {
  kMU_Tx0EmptyFlag = (1U << (MU_SR_TEn_SHIFT + 3U)),
  kMU_Tx1EmptyFlag = (1U << (MU_SR_TEn_SHIFT + 2U)),
  kMU_Tx2EmptyFlag = (1U << (MU_SR_TEn_SHIFT + 1U)),
  kMU_Tx3EmptyFlag = (1U << (MU_SR_TEn_SHIFT + 0U)),
  kMU_Rx0FullFlag = (1U << (MU_SR_RFn_SHIFT + 3U)),
  kMU_Rx1FullFlag = (1U << (MU_SR_RFn_SHIFT + 2U)),
  kMU_Rx2FullFlag = (1U << (MU_SR_RFn_SHIFT + 1U)),
  kMU_Rx3FullFlag = (1U << (MU_SR_RFn_SHIFT + 0U)),
  kMU_GenInt0Flag = (1U << (MU_SR_GIPn_SHIFT + 3U)),
  kMU_GenInt1Flag = (1U << (MU_SR_GIPn_SHIFT + 2U)),
  kMU_GenInt2Flag = (1U << (MU_SR_GIPn_SHIFT + 1U)),
  kMU_GenInt3Flag = (1U << (MU_SR_GIPn_SHIFT + 0U)),
  kMU_EventPendingFlag = MU_SR_EP_MASK,
  kMU_FlagsUpdatingFlag = MU_SR_FUP_MASK,
  kMU_OtherSideInResetFlag = MU_SR_RS_MASK
}
 MU status flags. More...
 
enum  _mu_interrupt_enable {
  kMU_Tx0EmptyInterruptEnable = (1U << (MU_CR_TIEn_SHIFT + 3U)),
  kMU_Tx1EmptyInterruptEnable = (1U << (MU_CR_TIEn_SHIFT + 2U)),
  kMU_Tx2EmptyInterruptEnable = (1U << (MU_CR_TIEn_SHIFT + 1U)),
  kMU_Tx3EmptyInterruptEnable = (1U << (MU_CR_TIEn_SHIFT + 0U)),
  kMU_Rx0FullInterruptEnable = (1U << (MU_CR_RIEn_SHIFT + 3U)),
  kMU_Rx1FullInterruptEnable = (1U << (MU_CR_RIEn_SHIFT + 2U)),
  kMU_Rx2FullInterruptEnable = (1U << (MU_CR_RIEn_SHIFT + 1U)),
  kMU_Rx3FullInterruptEnable = (1U << (MU_CR_RIEn_SHIFT + 0U)),
  kMU_GenInt0InterruptEnable = (int)(1U << (MU_CR_GIEn_SHIFT + 3U)),
  kMU_GenInt1InterruptEnable = (1U << (MU_CR_GIEn_SHIFT + 2U)),
  kMU_GenInt2InterruptEnable = (1U << (MU_CR_GIEn_SHIFT + 1U)),
  kMU_GenInt3InterruptEnable = (1U << (MU_CR_GIEn_SHIFT + 0U))
}
 MU interrupt source to enable. More...
 
enum  _mu_interrupt_trigger {
  kMU_GenInt0InterruptTrigger = (1U << (MU_CR_GIRn_SHIFT + 3U)),
  kMU_GenInt1InterruptTrigger = (1U << (MU_CR_GIRn_SHIFT + 2U)),
  kMU_GenInt2InterruptTrigger = (1U << (MU_CR_GIRn_SHIFT + 1U)),
  kMU_GenInt3InterruptTrigger = (1U << (MU_CR_GIRn_SHIFT + 0U))
}
 MU interrupt that could be triggered to the other core. More...
 

Driver version

#define FSL_MU_DRIVER_VERSION   (MAKE_VERSION(2, 0, 6))
 MU driver version. More...
 

MU initialization.

void MU_Init (MU_Type *base)
 Initializes the MU module. More...
 
void MU_Deinit (MU_Type *base)
 De-initializes the MU module. More...
 

MU Message

static void MU_SendMsgNonBlocking (MU_Type *base, uint32_t regIndex, uint32_t msg)
 Writes a message to the TX register. More...
 
void MU_SendMsg (MU_Type *base, uint32_t regIndex, uint32_t msg)
 Blocks to send a message. More...
 
static uint32_t MU_ReceiveMsgNonBlocking (MU_Type *base, uint32_t regIndex)
 Reads a message from the RX register. More...
 
uint32_t MU_ReceiveMsg (MU_Type *base, uint32_t regIndex)
 Blocks to receive a message. More...
 

MU Flags

static void MU_SetFlagsNonBlocking (MU_Type *base, uint32_t flags)
 Sets the 3-bit MU flags reflect on the other MU side. More...
 
void MU_SetFlags (MU_Type *base, uint32_t flags)
 Blocks setting the 3-bit MU flags reflect on the other MU side. More...
 
static uint32_t MU_GetFlags (MU_Type *base)
 Gets the current value of the 3-bit MU flags set by the other side. More...
 

Status and Interrupt.

static uint32_t MU_GetStatusFlags (MU_Type *base)
 Gets the MU status flags. More...
 
static uint32_t MU_GetInterruptsPending (MU_Type *base)
 Gets the MU IRQ pending status. More...
 
static void MU_ClearStatusFlags (MU_Type *base, uint32_t mask)
 Clears the specific MU status flags. More...
 
static void MU_EnableInterrupts (MU_Type *base, uint32_t mask)
 Enables the specific MU interrupts. More...
 
static void MU_DisableInterrupts (MU_Type *base, uint32_t mask)
 Disables the specific MU interrupts. More...
 
status_t MU_TriggerInterrupts (MU_Type *base, uint32_t mask)
 Triggers interrupts to the other core. More...
 

Macro Definition Documentation

#define FSL_MU_DRIVER_VERSION   (MAKE_VERSION(2, 0, 6))

Enumeration Type Documentation

Enumerator
kMU_Tx0EmptyFlag 

TX0 empty.

kMU_Tx1EmptyFlag 

TX1 empty.

kMU_Tx2EmptyFlag 

TX2 empty.

kMU_Tx3EmptyFlag 

TX3 empty.

kMU_Rx0FullFlag 

RX0 full.

kMU_Rx1FullFlag 

RX1 full.

kMU_Rx2FullFlag 

RX2 full.

kMU_Rx3FullFlag 

RX3 full.

kMU_GenInt0Flag 

General purpose interrupt 0 pending.

kMU_GenInt1Flag 

General purpose interrupt 0 pending.

kMU_GenInt2Flag 

General purpose interrupt 0 pending.

kMU_GenInt3Flag 

General purpose interrupt 0 pending.

kMU_EventPendingFlag 

MU event pending.

kMU_FlagsUpdatingFlag 

MU flags update is on-going.

kMU_OtherSideInResetFlag 

The other side is in reset.

Enumerator
kMU_Tx0EmptyInterruptEnable 

TX0 empty.

kMU_Tx1EmptyInterruptEnable 

TX1 empty.

kMU_Tx2EmptyInterruptEnable 

TX2 empty.

kMU_Tx3EmptyInterruptEnable 

TX3 empty.

kMU_Rx0FullInterruptEnable 

RX0 full.

kMU_Rx1FullInterruptEnable 

RX1 full.

kMU_Rx2FullInterruptEnable 

RX2 full.

kMU_Rx3FullInterruptEnable 

RX3 full.

kMU_GenInt0InterruptEnable 

General purpose interrupt 0.

kMU_GenInt1InterruptEnable 

General purpose interrupt 1.

kMU_GenInt2InterruptEnable 

General purpose interrupt 2.

kMU_GenInt3InterruptEnable 

General purpose interrupt 3.

Enumerator
kMU_GenInt0InterruptTrigger 

General purpose interrupt 0.

kMU_GenInt1InterruptTrigger 

General purpose interrupt 1.

kMU_GenInt2InterruptTrigger 

General purpose interrupt 2.

kMU_GenInt3InterruptTrigger 

General purpose interrupt 3.

Function Documentation

void MU_Init ( MU_Type *  base)

This function enables the MU clock only.

Parameters
baseMU peripheral base address.
void MU_Deinit ( MU_Type *  base)

This function disables the MU clock only.

Parameters
baseMU peripheral base address.
static void MU_SendMsgNonBlocking ( MU_Type *  base,
uint32_t  regIndex,
uint32_t  msg 
)
inlinestatic

This function writes a message to the specific TX register. It does not check whether the TX register is empty or not. The upper layer should make sure the TX register is empty before calling this function. This function can be used in ISR for better performance.

* while (!(kMU_Tx0EmptyFlag & MU_GetStatusFlags(base))) { } Wait for TX0 register empty.
* MU_SendMsgNonBlocking(base, 0U, MSG_VAL); Write message to the TX0 register.
*
Parameters
baseMU peripheral base address.
regIndexTX register index.
msgMessage to send.
void MU_SendMsg ( MU_Type *  base,
uint32_t  regIndex,
uint32_t  msg 
)

This function waits until the TX register is empty and sends the message.

Parameters
baseMU peripheral base address.
regIndexTX register index.
msgMessage to send.
static uint32_t MU_ReceiveMsgNonBlocking ( MU_Type *  base,
uint32_t  regIndex 
)
inlinestatic

This function reads a message from the specific RX register. It does not check whether the RX register is full or not. The upper layer should make sure the RX register is full before calling this function. This function can be used in ISR for better performance.

* uint32_t msg;
* while (!(kMU_Rx0FullFlag & MU_GetStatusFlags(base)))
* {
* } Wait for the RX0 register full.
*
* msg = MU_ReceiveMsgNonBlocking(base, 0U); Read message from RX0 register.
*
Parameters
baseMU peripheral base address.
regIndexTX register index.
Returns
The received message.
uint32_t MU_ReceiveMsg ( MU_Type *  base,
uint32_t  regIndex 
)

This function waits until the RX register is full and receives the message.

Parameters
baseMU peripheral base address.
regIndexRX register index.
Returns
The received message.
static void MU_SetFlagsNonBlocking ( MU_Type *  base,
uint32_t  flags 
)
inlinestatic

This function sets the 3-bit MU flags directly. Every time the 3-bit MU flags are changed, the status flag kMU_FlagsUpdatingFlag asserts indicating the 3-bit MU flags are updating to the other side. After the 3-bit MU flags are updated, the status flag kMU_FlagsUpdatingFlag is cleared by hardware. During the flags updating period, the flags cannot be changed. The upper layer should make sure the status flag kMU_FlagsUpdatingFlag is cleared before calling this function.

* {
* } Wait for previous MU flags updating.
*
* MU_SetFlagsNonBlocking(base, 0U); Set the mU flags.
*
Parameters
baseMU peripheral base address.
flagsThe 3-bit MU flags to set.
void MU_SetFlags ( MU_Type *  base,
uint32_t  flags 
)

This function blocks setting the 3-bit MU flags. Every time the 3-bit MU flags are changed, the status flag kMU_FlagsUpdatingFlag asserts indicating the 3-bit MU flags are updating to the other side. After the 3-bit MU flags are updated, the status flag kMU_FlagsUpdatingFlag is cleared by hardware. During the flags updating period, the flags cannot be changed. This function waits for the MU status flag kMU_FlagsUpdatingFlag cleared and sets the 3-bit MU flags.

Parameters
baseMU peripheral base address.
flagsThe 3-bit MU flags to set.
static uint32_t MU_GetFlags ( MU_Type *  base)
inlinestatic

This function gets the current 3-bit MU flags on the current side.

Parameters
baseMU peripheral base address.
Returns
flags Current value of the 3-bit flags.
static uint32_t MU_GetStatusFlags ( MU_Type *  base)
inlinestatic

This function returns the bit mask of the MU status flags. See _mu_status_flags.

* uint32_t flags;
* flags = MU_GetStatusFlags(base); Get all status flags.
* if (kMU_Tx0EmptyFlag & flags)
* {
* The TX0 register is empty. Message can be sent.
* MU_SendMsgNonBlocking(base, 0U, MSG0_VAL);
* }
* if (kMU_Tx1EmptyFlag & flags)
* {
* The TX1 register is empty. Message can be sent.
* MU_SendMsgNonBlocking(base, 1U, MSG1_VAL);
* }
*
Parameters
baseMU peripheral base address.
Returns
Bit mask of the MU status flags, see _mu_status_flags.
static uint32_t MU_GetInterruptsPending ( MU_Type *  base)
inlinestatic

This function returns the bit mask of the pending MU IRQs.

Parameters
baseMU peripheral base address.
Returns
Bit mask of the MU IRQs pending.
static void MU_ClearStatusFlags ( MU_Type *  base,
uint32_t  mask 
)
inlinestatic

This function clears the specific MU status flags. The flags to clear should be passed in as bit mask. See _mu_status_flags.

* Clear general interrupt 0 and general interrupt 1 pending flags.
*
Parameters
baseMU peripheral base address.
maskBit mask of the MU status flags. See _mu_status_flags. The following flags are cleared by hardware, this function could not clear them.
  • kMU_Tx0EmptyFlag
  • kMU_Tx1EmptyFlag
  • kMU_Tx2EmptyFlag
  • kMU_Tx3EmptyFlag
  • kMU_Rx0FullFlag
  • kMU_Rx1FullFlag
  • kMU_Rx2FullFlag
  • kMU_Rx3FullFlag
  • kMU_EventPendingFlag
  • kMU_FlagsUpdatingFlag
  • kMU_OtherSideInResetFlag
static void MU_EnableInterrupts ( MU_Type *  base,
uint32_t  mask 
)
inlinestatic

This function enables the specific MU interrupts. The interrupts to enable should be passed in as bit mask. See _mu_interrupt_enable.

* Enable general interrupt 0 and TX0 empty interrupt.
*
Parameters
baseMU peripheral base address.
maskBit mask of the MU interrupts. See _mu_interrupt_enable.
static void MU_DisableInterrupts ( MU_Type *  base,
uint32_t  mask 
)
inlinestatic

This function disables the specific MU interrupts. The interrupts to disable should be passed in as bit mask. See _mu_interrupt_enable.

* Disable general interrupt 0 and TX0 empty interrupt.
*
Parameters
baseMU peripheral base address.
maskBit mask of the MU interrupts. See _mu_interrupt_enable.
status_t MU_TriggerInterrupts ( MU_Type *  base,
uint32_t  mask 
)

This function triggers the specific interrupts to the other core. The interrupts to trigger are passed in as bit mask. See _mu_interrupt_trigger. The MU should not trigger an interrupt to the other core when the previous interrupt has not been processed by the other core. This function checks whether the previous interrupts have been processed. If not, it returns an error.

* {
* Previous general purpose interrupt 0 or general purpose interrupt 2
* has not been processed by the other core.
* }
*
Parameters
baseMU peripheral base address.
maskBit mask of the interrupts to trigger. See _mu_interrupt_trigger.
Return values
kStatus_SuccessInterrupts have been triggered successfully.
kStatus_FailPrevious interrupts have not been accepted.