MCUXpresso SDK API Reference Manual  Rev 2.12.1
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
IMU: Inter CPU Messaging Unit

Overview

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

Data Structures

struct  IMU_Type
 IMU register structure. More...
 

Macros

#define IMU_RX_FIFO_EMPTY(link)   (0UL != (((IMU_Type *)IMU_PEER_CPU_BASE(link))->MSG_FIFO_STATUS & IMU_MSG_FIFO_STATUS_MSG_FIFO_EMPTY_MASK))
 Get Rx FIFO empty status. More...
 
#define IMU_ERR_TX_FIFO_LOCKED   (-1L)
 IMU driver returned error value. More...
 
#define IMU_MSG_FIFO_MAX_COUNT   16U
 Maximum message numbers in FIFO. More...
 
#define IMU_MAX_MSG_FIFO_WATER_MARK   (IMU_MSG_FIFO_MAX_COUNT - 1U)
 Maximum message FIFO warter mark. More...
 

Enumerations

enum  _imu_status_flags
 IMU status flags. More...
 
enum  _imu_interrupts
 IMU interrupt. More...
 

Driver version

#define FSL_IMU_DRIVER_VERSION   (MAKE_VERSION(2, 1, 1))
 IMU driver version. More...
 

IMU initialization.

status_t IMU_Init (imu_link_t link)
 Initializes the IMU module. More...
 
void IMU_Deinit (imu_link_t link)
 De-initializes the IMU module. More...
 

IMU Message

static void IMU_WriteMsg (imu_link_t link, uint32_t msg)
 Write one message to TX FIFO. More...
 
static uint32_t IMU_ReadMsg (imu_link_t link)
 Read one message from RX FIFO. More...
 
int32_t IMU_SendMsgsBlocking (imu_link_t link, const uint32_t *msgs, int32_t msgCount, bool lockSendFifo)
 Blocking to send messages. More...
 
int32_t IMU_TrySendMsgs (imu_link_t link, const uint32_t *msgs, int32_t msgCount, bool lockSendFifo)
 Try to send messages. More...
 
int32_t IMU_TryReceiveMsgs (imu_link_t link, uint32_t *msgs, int32_t desiredMsgCount, bool *needAckLock)
 Try to receive messages. More...
 
int32_t IMU_ReceiveMsgsBlocking (imu_link_t link, uint32_t *msgs, int32_t desiredMsgCount, bool *needAckLock)
 Blocking to receive messages. More...
 
int32_t IMU_SendMsgPtrBlocking (imu_link_t link, uint32_t msgPtr, bool lockSendFifo)
 Blocking to send messages pointer. More...
 
static void IMU_LockSendFifo (imu_link_t link, bool lock)
 Lock or unlock the TX FIFO. More...
 
void IMU_FlushSendFifo (imu_link_t link)
 Flush the send FIFO. More...
 
static void IMU_SetSendFifoWaterMark (imu_link_t link, uint8_t waterMark)
 Set send FIFO warter mark. More...
 
static uint32_t IMU_GetReceivedMsgCount (imu_link_t link)
 Get the message count in receive FIFO. More...
 
static uint32_t IMU_GetSendFifoEmptySpace (imu_link_t link)
 Get the empty slot in send FIFO. More...
 

Status and Interrupt.

uint32_t IMU_GetStatusFlags (imu_link_t link)
 Gets the IMU status flags. More...
 
static void IMU_ClearPendingInterrupts (imu_link_t link, uint32_t mask)
 Clear the IMU IRQ. More...
 

Data Structure Documentation

struct IMU_Type

Macro Definition Documentation

#define FSL_IMU_DRIVER_VERSION   (MAKE_VERSION(2, 1, 1))
#define IMU_RX_FIFO_EMPTY (   link)    (0UL != (((IMU_Type *)IMU_PEER_CPU_BASE(link))->MSG_FIFO_STATUS & IMU_MSG_FIFO_STATUS_MSG_FIFO_EMPTY_MASK))
#define IMU_ERR_TX_FIFO_LOCKED   (-1L)
#define IMU_MSG_FIFO_MAX_COUNT   16U
#define IMU_MAX_MSG_FIFO_WATER_MARK   (IMU_MSG_FIFO_MAX_COUNT - 1U)

Enumeration Type Documentation

Function Documentation

status_t IMU_Init ( imu_link_t  link)

This function sets IMU to initialized state, including:

  • Flush the send FIFO.
  • Unlock the send FIFO.
  • Set the water mark to (IMU_MAX_MSG_FIFO_WATER_MARK)
  • Flush the read FIFO.
Parameters
linkIMU link.
Return values
kStatus_InvalidArgumentThe link is invalid.
kStatus_SuccessInitialized successfully.
void IMU_Deinit ( imu_link_t  link)
Parameters
linkIMU link.
static void IMU_WriteMsg ( imu_link_t  link,
uint32_t  msg 
)
inlinestatic

This function writes message to the TX FIFO, user need to make sure there is empty space in the TX FIFO, and TX FIFO not locked before calling this function.

Parameters
linkIMU link.
msgThe message to send.
static uint32_t IMU_ReadMsg ( imu_link_t  link)
inlinestatic

User need to make sure there is available message in the RX FIFO.

Parameters
linkIMU link.
Returns
The message.
int32_t IMU_SendMsgsBlocking ( imu_link_t  link,
const uint32_t *  msgs,
int32_t  msgCount,
bool  lockSendFifo 
)

This function blocks until all messages have been filled to TX FIFO.

  • If the TX FIFO is locked, this function returns IMU_ERR_TX_FIFO_LOCKED.
  • If TX FIFO not locked, this function waits the available empty slot in TX FIFO, and fills the message to TX FIFO.
  • To lock TX FIFO after filling all messages, set lockSendFifo to true.
Parameters
linkIMU link.
msgsThe messages to send.
msgCountMessage count, one message is a 32-bit word.
lockSendFifoIf set to true, the TX FIFO is locked after all messages filled to TX FIFO.
Returns
If TX FIFO is locked, this function returns IMU_ERR_TX_FIFO_LOCKED, otherwise, this function returns the actual message count sent out, it equals msgCount because this function is blocking function, it returns until all messages have been filled into TX FIFO.
int32_t IMU_TrySendMsgs ( imu_link_t  link,
const uint32_t *  msgs,
int32_t  msgCount,
bool  lockSendFifo 
)

This function is similar with IMU_SendMsgsBlocking, the difference is, this function tries to send as many as possible, if there is not enough empty slot in TX FIFO, this function fills messages to available empty slots and returns how many messages have been filled.

  • If the TX FIFO is locked, this function returns IMU_ERR_TX_FIFO_LOCKED.
  • If TX FIFO not locked, this function fills messages to TX FIFO empty slot, and returns how many messages have been filled.
  • If lockSendFifo is set to true, TX FIFO is locked after all messages have been filled to TX FIFO. In other word, TX FIFO is locked if the function return value equals msgCount, when lockSendFifo set to true.
Parameters
linkIMU link.
msgsThe messages to send.
msgCountMessage count, one message is a 32-bit word.
lockSendFifoIf set to true, the TX FIFO is locked after all messages filled to TX FIFO.
Returns
If TX FIFO is locked, this function returns IMU_ERR_TX_FIFO_LOCKED, otherwise, this function returns the actual message count sent out.
int32_t IMU_TryReceiveMsgs ( imu_link_t  link,
uint32_t *  msgs,
int32_t  desiredMsgCount,
bool *  needAckLock 
)

This function tries to read messages from RX FIFO. It reads the messages already exists in RX FIFO and returns the actual read count.

  • If the RX FIFO has enough messages, this function reads the messages and returns.
  • If the RX FIFO does not have enough messages, this function the messages in RX FIFO and returns the actual read count.
  • During message reading, if RX FIFO is empty and locked, in this case peer CPU will not send message until current CPU send lock ack message. Then this function returns the message count actually received, and sets needAckLock to true to inform upper layer.
Parameters
linkIMU link.
msgsThe buffer to read messages.
desiredMsgCountDesired read count, one message is a 32-bit word.
needAckLockUpper layer should always check this value. When this is set to true by this function, upper layer should send lock ack message to peer CPU.
Returns
Count of messages actually received.
int32_t IMU_ReceiveMsgsBlocking ( imu_link_t  link,
uint32_t *  msgs,
int32_t  desiredMsgCount,
bool *  needAckLock 
)

This function blocks until all desired messages have been received or the RX FIFO is locked.

  • If the RX FIFO has enough messages, this function reads the messages and returns.
  • If the RX FIFO does not have enough messages, this function waits for the new messages.
  • During message reading, if RX FIFO is empty and locked, in this case peer CPU will not send message until current CPU send lock ack message. Then this function returns the message count actually received, and sets needAckLock to true to inform upper layer.
Parameters
linkIMU link.
msgsThe buffer to read messages.
desiredMsgCountDesired read count, one message is a 32-bit word.
needAckLockUpper layer should always check this value. When this is set to true by this function, upper layer should send lock ack message to peer CPU.
Returns
Count of messages actually received.
int32_t IMU_SendMsgPtrBlocking ( imu_link_t  link,
uint32_t  msgPtr,
bool  lockSendFifo 
)

Compared with IMU_SendMsgsBlocking, this function fills message pointer to TX FIFO, but not the message content.

This function blocks until the message pointer is filled to TX FIFO.

  • If the TX FIFO is locked, this function returns IMU_ERR_TX_FIFO_LOCKED.
  • If TX FIFO not locked, this function waits the available empty slot in TX FIFO, and fills the message pointer to TX FIFO.
  • To lock TX FIFO after filling the message pointer, set lockSendFifo to true.
Parameters
linkIMU link.
msgPtrThe buffer pointer to message to send.
needAckLockUpper layer should always check this value. When this is set to true by this function, upper layer should send lock ack message to peer CPU.
Return values
0The message pointer set successfully.
IMU_ERR_TX_FIFO_LOCKEDThe TX FIFO is locked, send failed.
static void IMU_LockSendFifo ( imu_link_t  link,
bool  lock 
)
inlinestatic
Parameters
linkIMU link.
lockUse true to lock the FIFO, use false to unlock.
void IMU_FlushSendFifo ( imu_link_t  link)

Flush all messages in send FIFO.

Parameters
linkIMU link.
static void IMU_SetSendFifoWaterMark ( imu_link_t  link,
uint8_t  waterMark 
)
inlinestatic

The warter mark must be less than IMU_MAX_MSG_FIFO_WATER_MARK, i.e. 0 < waterMark <= IMU_MAX_MSG_FIFO_WATER_MARK.

Parameters
linkIMU link.
waterMarkSend FIFO warter mark.
static uint32_t IMU_GetReceivedMsgCount ( imu_link_t  link)
inlinestatic
Parameters
linkIMU link.
Returns
The message count in receive FIFO.
static uint32_t IMU_GetSendFifoEmptySpace ( imu_link_t  link)
inlinestatic
Parameters
linkIMU link.
Returns
The empty slot count in send FIFO.
uint32_t IMU_GetStatusFlags ( imu_link_t  link)
Parameters
linkIMU link.
Returns
Bit mask of the IMU status flags, see _imu_status_flags.
static void IMU_ClearPendingInterrupts ( imu_link_t  link,
uint32_t  mask 
)
inlinestatic
Parameters
linkIMU link.
maskBit mask of the interrupts to clear, see _imu_interrupts.