![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides a peripheral driver for the Host Interface Unit (HOSTIF) module of MCUXpresso SDK devices.
The Host Interface Unit (HOSTIF) module allows communication between the application host (SPI/I2C) and system RAM via the BMA (Buffer Management and Arbitration) module. The HostIF is protocol agnostic and stores the received frames in a series of buffers.
Data Structures | |
| struct | hostif_i2c_config_t |
| hostif i2c config More... | |
| struct | hostif_spi_config_t |
| hostif spi config More... | |
| struct | hostif_config_t |
| hostif config More... | |
| struct | hostif_transfer_t |
| HOSTIF transfer structure. More... | |
| struct | hostif_handle_t |
| HOSTIF handle structure. More... | |
Macros | |
| #define | FSL_HOSTIF_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
| HOSTIF driver version 2.0.1. More... | |
Typedefs | |
| typedef void(* | hostif_transfer_callback_t )(hostif_handle_t *handle, void *userData, uint32_t transferredLength, uint32_t status) |
| HOSTIF transfer callback function. More... | |
Enumerations | |
| enum | { kHOSTIF_RxBufferBusy = MAKE_STATUS(kStatusGroup_HOSTIF, 1), kHOSTIF_EndOfReception = MAKE_STATUS(kStatusGroup_HOSTIF, 2), kHOSTIF_EndOfTransmit = MAKE_STATUS(kStatusGroup_HOSTIF, 3), kHOSTIF_ReachedWaterLevel = MAKE_STATUS(kStatusGroup_HOSTIF, 4), kHOSTIF_TransferError = MAKE_STATUS(kStatusGroup_HOSTIF, 5), kHOSTIF_UnknownInterrupt = MAKE_STATUS(kStatusGroup_HOSTIF, 6), kHOSTIF_TxPrefetchFailed = MAKE_STATUS(kStatusGroup_HOSTIF, 7), kHOSTIF_TxBufferBusy = MAKE_STATUS(kStatusGroup_HOSTIF, 8), kHOSTIF_InvalidArgument = MAKE_STATUS(kStatusGroup_HOSTIF, 9) } |
| hostif status More... | |
| enum | _hostif_controller_status { kHOSTIF_Rx0BufferLocked = HOSTIF_STATUS_RX0_BUFFER_LOCK_MASK, kHOSTIF_Rx1BufferLocked = HOSTIF_STATUS_RX1_BUFFER_LOCK_MASK, kHOSTIF_Rx2BufferLocked = HOSTIF_STATUS_RX2_BUFFER_LOCK_MASK, kHOSTIF_Rx3BufferLocked = HOSTIF_STATUS_RX3_BUFFER_LOCK_MASK, kHOSTIF_TxBufferLocked = HOSTIF_STATUS_TX_BUFFER_LOCK_MASK, kHOSTIF_TxBufferPrefetchOk, kHOSTIF_CommunicationOngoing = HOSTIF_STATUS_HOSTCOMM_ONGOING_MASK } |
| hostif controller status More... | |
| enum | _hostif_data_ready_status { kHOSTIF_Rx0DataReady = HOSTIF_DATA_READY_STATUS_RX0_DATA_READY_MASK, kHOSTIF_Rx1DataReady = HOSTIF_DATA_READY_STATUS_RX1_DATA_READY_MASK, kHOSTIF_Rx2DataReady = HOSTIF_DATA_READY_STATUS_RX2_DATA_READY_MASK, kHOSTIF_Rx3DataReady = HOSTIF_DATA_READY_STATUS_RX3_DATA_READY_MASK, kHOSTIF_TxDataReady = HOSTIF_DATA_READY_STATUS_TX_DATA_READY_MASK } |
| hostif data ready status More... | |
| enum | _hostif_interrupt_status |
| hostif interrupt status | |
| enum | hostif_rx_buffer_id_t { kHOSTIF_RxBufferId0 = 0, kHOSTIF_RxBufferId1, kHOSTIF_RxBufferId2, kHOSTIF_RxBufferId3 } |
| hostif buffer id More... | |
| enum | hostif_interface_t { kHOSTIF_SelectNone = 0, kHOSTIF_SelectI2c = 1, kHOSTIF_SelectSpi = 2 } |
| hostif select config More... | |
HOSTIF Initialization and De-initialization interfaces | |
| void | HOSTIF_Init (HOSTIF_Type *base, const hostif_config_t *config) |
| HOSTIF initialization. More... | |
| void | HOSTIF_Deinit (HOSTIF_Type *base) |
| HOSTIF De-initialization. More... | |
HOSTIF Functional Interfaces | |
| void | HOSTIF_GetDefaultConfig (hostif_config_t *config) |
| Gets HOSTIF default config. More... | |
| void | HOSTIF_SetTxBufferConfig (HOSTIF_Type *base, uint8_t *startAddress, uint16_t bufferLength) |
| Sets HOSTIF tx buffer config. More... | |
| void | HOSTIF_SetRxBufferConfig (HOSTIF_Type *base, uint8_t *startAddress, uint16_t maxSize, hostif_rx_buffer_id_t bufferId) |
| Sets HOSTIF rx buffer config. More... | |
| static void | HOSTIF_EnableRxBuffer (HOSTIF_Type *base, hostif_rx_buffer_id_t bufferId) |
| Enables HOSTIF rx buffer. More... | |
| static void | HOSTIF_DisableRxBuffer (HOSTIF_Type *base, hostif_rx_buffer_id_t bufferId) |
| Disables HOSTIF rx buffer. More... | |
| static bool | HOSTIF_IsRxBufferEnabled (HOSTIF_Type *base, hostif_rx_buffer_id_t bufferId) |
| Is HOSTIF rx buffer enabled. More... | |
| static uint16_t | HOSTIF_GetRxBufferLength (HOSTIF_Type *base, hostif_rx_buffer_id_t bufferId) |
| Gets HOSTIF rx buffer length. More... | |
| static bool | HOSTIF_IsRxBufferCrcOk (HOSTIF_Type *base, hostif_rx_buffer_id_t bufferId) |
| Is HOSTIF rx buffer crc ok. More... | |
| static void | HOSTIF_SetWaterLevel (HOSTIF_Type *base, uint16_t waterMarkLevel) |
| Sets HOSTIF water mark level. More... | |
| static void | HOSTIF_SetTimeOut (HOSTIF_Type *base, uint16_t timeOut) |
| Sets HOSTIF timeout value. More... | |
HOSTIF Interrupt Interfaces | |
| static void | HOSTIF_EnableInterrupts (HOSTIF_Type *base, uint32_t interrupts) |
| Enables HOSTIF interrupts. More... | |
| static void | HOSTIF_DisableInterrupts (HOSTIF_Type *base, uint32_t interrupts) |
| Disables HOSTIF interrupts. More... | |
HOSTIF Status Interfaces | |
| static uint32_t | HOSTIF_GetControlllerStatus (HOSTIF_Type *base) |
| Gets HOSTIF buffer status. More... | |
| static uint32_t | HOSTIF_GetDataReadyStatus (HOSTIF_Type *base) |
| Gets HOSTIF data ready status. More... | |
| static void | HOSTIF_SetDataReady (HOSTIF_Type *base, uint32_t status) |
| Sets HOSTIF data ready status. More... | |
| static void | HOSTIF_ClearDataReadyStatus (HOSTIF_Type *base, uint32_t status) |
| Clears HOSTIF data ready status. More... | |
| static uint32_t | HOSTIF_GetInterruptsStatus (HOSTIF_Type *base) |
| Gets HOSTIF interrupt status. More... | |
| static void | HOSTIF_SetInterruptsStatus (HOSTIF_Type *base, uint32_t interruptsMask) |
| Sets HOSTIF interrupt status. More... | |
| static void | HOSTIF_ClearInterruptsStatus (HOSTIF_Type *base, uint32_t interruptsMask) |
| Clears HOSTIF interrupt status. More... | |
HOSTIF Transactional Interfaces | |
| status_t | HOSTIF_SendNonBlocking (hostif_handle_t *handle, hostif_transfer_t *transfer) |
| This API sends a buffer of length over the previously selected. More... | |
| status_t | HOSTIF_AbortSend (hostif_handle_t *handle) |
| Aborts HOSTIF send. More... | |
| status_t | HOSTIF_ReceiveNonBlocking (hostif_handle_t *handle, hostif_transfer_t *transfer, uint8_t count) |
| This API will allocate and enable RX buffers for reception from host. More... | |
| void | HOSTIF_AbortReceive (hostif_handle_t *handle) |
| Aborts HOSTIF receive. More... | |
| void | HOSTIF_CreateHandle (HOSTIF_Type *base, hostif_handle_t *handle, hostif_transfer_callback_t callback, void *userData) |
| Creates the HOSTIF handle. More... | |
| void | HOSTIF_HandleIRQ (hostif_handle_t *handle) |
| HOSTIF IRQ handle. More... | |
| struct hostif_i2c_config_t |
Data Fields | |
| uint8_t | slaveAddress: 2 |
| Slave address. More... | |
| uint8_t | enableHsMode: 1 |
| Enable HS mode. More... | |
| uint8_t | enableReset: 1 |
| Enable reset. More... | |
| uint8_t | enableDeviceID: 1 |
| Enable device ID. More... | |
| uint8_t | revisionId: 3 |
| I2C revision ID. More... | |
| uint8_t hostif_i2c_config_t::slaveAddress |
| uint8_t hostif_i2c_config_t::enableHsMode |
| uint8_t hostif_i2c_config_t::enableReset |
| uint8_t hostif_i2c_config_t::enableDeviceID |
| uint8_t hostif_i2c_config_t::revisionId |
| struct hostif_spi_config_t |
Data Fields | |
| uint8_t | clockPolarity: 1 |
| SPI clockPolarity. More... | |
| uint8_t | clockPhase: 1 |
| SPI clockPhase. More... | |
| uint8_t hostif_spi_config_t::clockPolarity |
| uint8_t hostif_spi_config_t::clockPhase |
| struct hostif_config_t |
Data Fields | |
| union hostif_config_t::_hostif_interface_config | interfaceConfig |
| Users need to configure according to their own needs. More... | |
| hostif_interface_t | interface |
| Select one of in I2C, SPI. More... | |
| uint16_t | timeOut |
| Inter-character timeout in 5us steps (max delay 200ms). More... | |
| uint16_t | waterMarkLevel |
| Number of bytes received in incoming buffer before triggering an interrupt (pre-empting EOR). More... | |
| bool | enableCrc |
| Enable CRC. More... | |
| bool | enableExtIrqCtrl |
| Enable Ext IRQ line asserted if PREFETCH_OK is set. More... | |
| union hostif_config_t::_hostif_interface_config hostif_config_t::interfaceConfig |
| hostif_interface_t hostif_config_t::interface |
| uint16_t hostif_config_t::timeOut |
If set to 0, this feature is disabled when FIFO_MODE='0'. When FIFO_MODE='1' this defines the RX timeout value in 5us step.
| uint16_t hostif_config_t::waterMarkLevel |
If set to 0, this feature is disabled. FIFO Waterlvel when FIFO_MODE='1' Must remain static.
| bool hostif_config_t::enableCrc |
| bool hostif_config_t::enableExtIrqCtrl |
| struct hostif_transfer_t |
Data Fields | |
| uint8_t * | startAddress |
| Pointer to the Dword aligned buffer to which the data has to be saved. More... | |
| uint16_t | bufferLength |
| Length of the data in bytes which can be received by the buffer. More... | |
| uint8_t* hostif_transfer_t::startAddress |
| uint16_t hostif_transfer_t::bufferLength |
| struct _hostif_handle |
Forward declaration of the handle typedef.
Data Fields | |
| hostif_transfer_callback_t | callback |
| Callback function. More... | |
| void * | userData |
| Callback function parameter. More... | |
| HOSTIF_Type * | base |
| HOSTIF base address. More... | |
| hostif_transfer_callback_t hostif_handle_t::callback |
| void* hostif_handle_t::userData |
| HOSTIF_Type* hostif_handle_t::base |
| #define FSL_HOSTIF_DRIVER_VERSION (MAKE_VERSION(2, 0, 1)) |
| typedef void(* hostif_transfer_callback_t)(hostif_handle_t *handle, void *userData, uint32_t transferredLength, uint32_t status) |
| anonymous enum |
| enum hostif_interface_t |
| void HOSTIF_Init | ( | HOSTIF_Type * | base, |
| const hostif_config_t * | config | ||
| ) |
| base | HOSTIF base address. |
| config | Pointer to the HOSTIF configuration structure, see _hostif_config for detail. |
| void HOSTIF_Deinit | ( | HOSTIF_Type * | base | ) |
| base | HOSTIF base address. |
| void HOSTIF_GetDefaultConfig | ( | hostif_config_t * | config | ) |
| config | Pointer to the HOSTIF configuration structure, see _hostif_config for detail. |
| void HOSTIF_SetTxBufferConfig | ( | HOSTIF_Type * | base, |
| uint8_t * | startAddress, | ||
| uint16_t | bufferLength | ||
| ) |
| base | HOSTIF base address. |
| startAddress | Pointer to double word (4 byte) aligned memory. |
| bufferLength | Length of the buffer to be transmitted Maximum 1024 in for fixed format and 256 for free format. |
| void HOSTIF_SetRxBufferConfig | ( | HOSTIF_Type * | base, |
| uint8_t * | startAddress, | ||
| uint16_t | maxSize, | ||
| hostif_rx_buffer_id_t | bufferId | ||
| ) |
| base | HOSTIF base address. |
| startAddress | Pointer to the Dword aligned buffer to which the data has to be saved. |
| maxSize | Max Length of the data in bytes which can be received by the buffer. |
| bufferId | Buffer ID of the register which should be configured. |
|
inlinestatic |
| base | HOSTIF base address. |
| bufferId | Buffer ID of the register which should be enabled. |
|
inlinestatic |
| base | HOSTIF base address. |
| bufferId | Buffer ID of the register which should be disabled. |
|
inlinestatic |
| base | HOSTIF base address. |
| bufferId | Buffer ID of the status to set. |
|
inlinestatic |
| base | HOSTIF base address. |
|
inlinestatic |
| base | HOSTIF base address. |
| bufferId | Buffer ID of the status to set. |
|
inlinestatic |
| base | HOSTIF base address. |
| waterMarkLevel | Number of bytes received in incoming buffer before triggering an interrupt. If set to 0, this feature is disabled. FIFO Waterlvel when FIFO_MODE='1' Must remain static. |
|
inlinestatic |
| base | HOSTIF base address. |
| timeOut | Inter-character timeout in 5us steps (max delay 200ms). If set to 0, this feature is disabled when FIFO_MODE='0'. When FIFO_MODE='1' this defines the rx timeout value in 5us step. |
|
inlinestatic |
| base | HOSTIF base address. |
| interrupts | The mask you enabled. |
|
inlinestatic |
| base | HOSTIF base address. |
| interrupts | The mask you disabled. |
|
inlinestatic |
| base | HOSTIF base address. |
|
inlinestatic |
| base | HOSTIF base address. |
|
inlinestatic |
| base | HOSTIF base address. |
| status | The status of data ready, see _hostif_data_ready_status for detail. |
|
inlinestatic |
| base | HOSTIF base address. |
| status | The status of data ready, see _hostif_data_ready_status for detail. |
|
inlinestatic |
| base | HOSTIF base address. |
|
inlinestatic |
| base | HOSTIF base address. |
| interruptmasks | The Mask of interrupts, see _hostif_interrupt_status for detail. |
|
inlinestatic |
| base | HOSTIF base address. |
| interruptmasks | The Mask of interrupts, see _hostif_interrupt_status for detail. |
| status_t HOSTIF_SendNonBlocking | ( | hostif_handle_t * | handle, |
| hostif_transfer_t * | transfer | ||
| ) |
| handle | HOSTIF handle pointer. |
| transfer | Tx transfer pointer, see hostif_transfer for detail. |
| status_t HOSTIF_AbortSend | ( | hostif_handle_t * | handle | ) |
| handle | HOSTIF handle pointer. |
| kStatus_Success | Abort succeed. |
| kStatus_Timeout | Timeout. |
| status_t HOSTIF_ReceiveNonBlocking | ( | hostif_handle_t * | handle, |
| hostif_transfer_t * | transfer, | ||
| uint8_t | count | ||
| ) |
| handle | HOSTIF handle pointer. |
| transfer | Rx transfer pointer, see hostif_transfer for detail. |
| count | Count of the buffer, ransfer should be the first address of the array pointer. |
| void HOSTIF_AbortReceive | ( | hostif_handle_t * | handle | ) |
| handle | HOSTIF handle pointer. |
| void HOSTIF_CreateHandle | ( | HOSTIF_Type * | base, |
| hostif_handle_t * | handle, | ||
| hostif_transfer_callback_t | callback, | ||
| void * | userData | ||
| ) |
| base | HOSTIF base address. |
| handle | HOSTIF handle pointer. The HOSTIF handle stores Callback function and parameters. |
| callback | HOSTIF callback function pointer. |
| userData | Parameter for callback function. If it is not needed, just set to NULL. |
| void HOSTIF_HandleIRQ | ( | hostif_handle_t * | handle | ) |
| handle | HOSTIF handle pointer. The HOSTIF handle stores Callback function and parameters. |