The MCUXpresso SDK provides a driver for the IMU module of MCUXpresso SDK devices.
|
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...
|
|
#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 |
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
-
- Return values
-
kStatus_InvalidArgument | The link is invalid. |
kStatus_Success | Initialized successfully. |
void IMU_Deinit |
( |
imu_link_t |
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
-
link | IMU link. |
msg | The 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
-
- 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
-
link | IMU link. |
msgs | The messages to send. |
msgCount | Message count, one message is a 32-bit word. |
lockSendFifo | If 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
-
link | IMU link. |
msgs | The messages to send. |
msgCount | Message count, one message is a 32-bit word. |
lockSendFifo | If 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
-
link | IMU link. |
msgs | The buffer to read messages. |
desiredMsgCount | Desired read count, one message is a 32-bit word. |
needAckLock | Upper 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
-
link | IMU link. |
msgs | The buffer to read messages. |
desiredMsgCount | Desired read count, one message is a 32-bit word. |
needAckLock | Upper 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
-
link | IMU link. |
msgPtr | The buffer pointer to message to send. |
needAckLock | Upper 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
-
0 | The message pointer set successfully. |
IMU_ERR_TX_FIFO_LOCKED | The TX FIFO is locked, send failed. |
static void IMU_LockSendFifo |
( |
imu_link_t |
link, |
|
|
bool |
lock |
|
) |
| |
|
inlinestatic |
- Parameters
-
link | IMU link. |
lock | Use true to lock the FIFO, use false to unlock. |
void IMU_FlushSendFifo |
( |
imu_link_t |
link | ) |
|
Flush all messages in send FIFO.
- Parameters
-
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
-
link | IMU link. |
waterMark | Send FIFO warter mark. |
static uint32_t IMU_GetReceivedMsgCount |
( |
imu_link_t |
link | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- The message count in receive FIFO.
static uint32_t IMU_GetSendFifoEmptySpace |
( |
imu_link_t |
link | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- The empty slot count in send FIFO.
uint32_t IMU_GetStatusFlags |
( |
imu_link_t |
link | ) |
|
static void IMU_ClearPendingInterrupts |
( |
imu_link_t |
link, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
link | IMU link. |
mask | Bit mask of the interrupts to clear, see _imu_interrupts. |