MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
HOSTIF: Host Interface Unit Driver

Overview

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...
 

Data Structure Documentation

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...
 

Field Documentation

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...
 

Field Documentation

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...
 

Field Documentation

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...
 

Field Documentation

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...
 

Field Documentation

hostif_transfer_callback_t hostif_handle_t::callback
void* hostif_handle_t::userData
HOSTIF_Type* hostif_handle_t::base

Macro Definition Documentation

#define FSL_HOSTIF_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))

Typedef Documentation

typedef void(* hostif_transfer_callback_t)(hostif_handle_t *handle, void *userData, uint32_t transferredLength, uint32_t status)

Enumeration Type Documentation

anonymous enum
Enumerator
kHOSTIF_RxBufferBusy 

RX Buffer is busy.

kHOSTIF_EndOfReception 

End of reception.

kHOSTIF_EndOfTransmit 

End of transmit.

kHOSTIF_ReachedWaterLevel 

Water level reached.

kHOSTIF_TransferError 

Transfer error.

kHOSTIF_UnknownInterrupt 

Unknown interrupt.

kHOSTIF_TxPrefetchFailed 

TX prefetch failed.

kHOSTIF_TxBufferBusy 

TX Buffer is busy.

kHOSTIF_InvalidArgument 

Invalid argument.

Enumerator
kHOSTIF_Rx0BufferLocked 

RX0 Buffer is locked by the H/w.

kHOSTIF_Rx1BufferLocked 

RX1 Buffer is locked by the H/w.

kHOSTIF_Rx2BufferLocked 

RX2 Buffer is locked by the H/w.

kHOSTIF_Rx3BufferLocked 

RX3 Buffer is locked by the H/w.

kHOSTIF_TxBufferLocked 

TX Buffer is locked by the H/w.

kHOSTIF_TxBufferPrefetchOk 

Prefetch Failed while initiating transmission.

kHOSTIF_CommunicationOngoing 

Communication ongoing.

Enumerator
kHOSTIF_Rx0DataReady 

Frame valid bit for RX buffer 0.

1 - buffer contains a frame received from Host 0 - frame has been processed by FW and buffer is free to receive a new frame.

kHOSTIF_Rx1DataReady 

Frame valid bit for RX buffer 0.

1 - buffer contains a frame received from Host 0 - frame has been processed by FW and buffer is free to receive a new frame.

kHOSTIF_Rx2DataReady 

Frame valid bit for RX buffer 0.

1 - buffer contains a frame received from Host 0 - frame has been processed by FW and buffer is free to receive a new frame.

kHOSTIF_Rx3DataReady 

Frame valid bit for RX buffer 0.

1 - buffer contains a frame received from Host 0 - frame has been processed by FW and buffer is free to receive a new frame.

kHOSTIF_TxDataReady 

Frame valid bit for TX buffer.

1 - buffer loaded with frame by FW to be sent to Host 0 - frame successfully sent to Host.

Enumerator
kHOSTIF_RxBufferId0 

hostif rx0 buffer id

kHOSTIF_RxBufferId1 

hostif rx1 buffer id

kHOSTIF_RxBufferId2 

hostif rx2 buffer id

kHOSTIF_RxBufferId3 

hostif rx3 buffer id

Enumerator
kHOSTIF_SelectNone 

hostif select none bus

kHOSTIF_SelectI2c 

hostif select i2c bus

kHOSTIF_SelectSpi 

hostif select spi bus

Function Documentation

void HOSTIF_Init ( HOSTIF_Type *  base,
const hostif_config_t config 
)
Parameters
baseHOSTIF base address.
configPointer to the HOSTIF configuration structure, see _hostif_config for detail.
void HOSTIF_Deinit ( HOSTIF_Type *  base)
Parameters
baseHOSTIF base address.
void HOSTIF_GetDefaultConfig ( hostif_config_t config)
Parameters
configPointer to the HOSTIF configuration structure, see _hostif_config for detail.
void HOSTIF_SetTxBufferConfig ( HOSTIF_Type *  base,
uint8_t *  startAddress,
uint16_t  bufferLength 
)
Parameters
baseHOSTIF base address.
startAddressPointer to double word (4 byte) aligned memory.
bufferLengthLength 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 
)
Parameters
baseHOSTIF base address.
startAddressPointer to the Dword aligned buffer to which the data has to be saved.
maxSizeMax Length of the data in bytes which can be received by the buffer.
bufferIdBuffer ID of the register which should be configured.
static void HOSTIF_EnableRxBuffer ( HOSTIF_Type *  base,
hostif_rx_buffer_id_t  bufferId 
)
inlinestatic
Parameters
baseHOSTIF base address.
bufferIdBuffer ID of the register which should be enabled.
static void HOSTIF_DisableRxBuffer ( HOSTIF_Type *  base,
hostif_rx_buffer_id_t  bufferId 
)
inlinestatic
Parameters
baseHOSTIF base address.
bufferIdBuffer ID of the register which should be disabled.
static bool HOSTIF_IsRxBufferEnabled ( HOSTIF_Type *  base,
hostif_rx_buffer_id_t  bufferId 
)
inlinestatic
Parameters
baseHOSTIF base address.
bufferIdBuffer ID of the status to set.
Returns
true The rx buffer is enabled. false The rx buffer is disabled.
static uint16_t HOSTIF_GetRxBufferLength ( HOSTIF_Type *  base,
hostif_rx_buffer_id_t  bufferId 
)
inlinestatic
Parameters
baseHOSTIF base address.
Returns
bufferId Buffer ID of the length to get.
static bool HOSTIF_IsRxBufferCrcOk ( HOSTIF_Type *  base,
hostif_rx_buffer_id_t  bufferId 
)
inlinestatic
Parameters
baseHOSTIF base address.
bufferIdBuffer ID of the status to set.
Returns
true The rx buffer crc is ok. false The rx buffer crc is not ok.
static void HOSTIF_SetWaterLevel ( HOSTIF_Type *  base,
uint16_t  waterMarkLevel 
)
inlinestatic
Parameters
baseHOSTIF base address.
waterMarkLevelNumber 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.
static void HOSTIF_SetTimeOut ( HOSTIF_Type *  base,
uint16_t  timeOut 
)
inlinestatic
Parameters
baseHOSTIF base address.
timeOutInter-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.
static void HOSTIF_EnableInterrupts ( HOSTIF_Type *  base,
uint32_t  interrupts 
)
inlinestatic
Parameters
baseHOSTIF base address.
interruptsThe mask you enabled.
static void HOSTIF_DisableInterrupts ( HOSTIF_Type *  base,
uint32_t  interrupts 
)
inlinestatic
Parameters
baseHOSTIF base address.
interruptsThe mask you disabled.
static uint32_t HOSTIF_GetControlllerStatus ( HOSTIF_Type *  base)
inlinestatic
Parameters
baseHOSTIF base address.
Returns
status The status of HOSTIF, see _hostif_controller_status for detail.
static uint32_t HOSTIF_GetDataReadyStatus ( HOSTIF_Type *  base)
inlinestatic
Parameters
baseHOSTIF base address.
Returns
status The status of data ready, see _hostif_data_ready_status for detail.
static void HOSTIF_SetDataReady ( HOSTIF_Type *  base,
uint32_t  status 
)
inlinestatic
Parameters
baseHOSTIF base address.
statusThe status of data ready, see _hostif_data_ready_status for detail.
static void HOSTIF_ClearDataReadyStatus ( HOSTIF_Type *  base,
uint32_t  status 
)
inlinestatic
Parameters
baseHOSTIF base address.
statusThe status of data ready, see _hostif_data_ready_status for detail.
static uint32_t HOSTIF_GetInterruptsStatus ( HOSTIF_Type *  base)
inlinestatic
Parameters
baseHOSTIF base address.
Returns
status The status of interrupts, see _hostif_interrupt_status for detail.
static void HOSTIF_SetInterruptsStatus ( HOSTIF_Type *  base,
uint32_t  interruptsMask 
)
inlinestatic
Parameters
baseHOSTIF base address.
interruptmasksThe Mask of interrupts, see _hostif_interrupt_status for detail.
static void HOSTIF_ClearInterruptsStatus ( HOSTIF_Type *  base,
uint32_t  interruptsMask 
)
inlinestatic
Parameters
baseHOSTIF base address.
interruptmasksThe Mask of interrupts, see _hostif_interrupt_status for detail.
status_t HOSTIF_SendNonBlocking ( hostif_handle_t *  handle,
hostif_transfer_t transfer 
)
Parameters
handleHOSTIF handle pointer.
transferTx transfer pointer, see hostif_transfer for detail.
Returns
status Status of the HOSTIF send success or failure.
status_t HOSTIF_AbortSend ( hostif_handle_t *  handle)
Parameters
handleHOSTIF handle pointer.
Return values
kStatus_SuccessAbort succeed.
kStatus_TimeoutTimeout.
status_t HOSTIF_ReceiveNonBlocking ( hostif_handle_t *  handle,
hostif_transfer_t transfer,
uint8_t  count 
)
Parameters
handleHOSTIF handle pointer.
transferRx transfer pointer, see hostif_transfer for detail.
countCount of the buffer, ransfer should be the first address of the array pointer.
void HOSTIF_AbortReceive ( hostif_handle_t *  handle)
Parameters
handleHOSTIF handle pointer.
void HOSTIF_CreateHandle ( HOSTIF_Type *  base,
hostif_handle_t *  handle,
hostif_transfer_callback_t  callback,
void *  userData 
)
Parameters
baseHOSTIF base address.
handleHOSTIF handle pointer. The HOSTIF handle stores Callback function and parameters.
callbackHOSTIF callback function pointer.
userDataParameter for callback function. If it is not needed, just set to NULL.
void HOSTIF_HandleIRQ ( hostif_handle_t *  handle)
Parameters
handleHOSTIF handle pointer. The HOSTIF handle stores Callback function and parameters.