MCUXpresso SDK API Reference Manual
Rev. 1
NXP Semiconductors
|
The MCUXpresso SDK provides a peripheral driver for the MIPI DSI
The MIPI DSI driver supports both video mode and command mode. For both modes, first call DSI_Init and DSI_InitDphy to initialize the module and enable the D-PHY. The DSI driver provides function DSI_GetDphyDefaultConfig to help with the D-PHY timing parameter calculation. With the input txHsBitClk frequency and txEscClk frequency, the function can generate the timing parameters based on the D-PHY specification. The user can use the parameter directly, or change them according to the special device.
For the command mode, DSI driver provides polling method and interrupt method for the data transfer. At the same time, there are also small functional APIs so that user can construct them for their special purpose.
When the peripheral is configured through command mode, the video mode can be started by DSI_SetDpiConfig.
Data Structures | |
struct | dsi_config_t |
MIPI DSI controller configuration. More... | |
struct | dsi_dpi_config_t |
MIPI DSI controller DPI interface configuration. More... | |
struct | dsi_dphy_config_t |
MIPI DSI D-PHY configuration. More... | |
struct | dsi_transfer_t |
Structure for the data transfer. More... | |
struct | dsi_handle_t |
MIPI DSI transfer handle structure. More... | |
Typedefs | |
typedef void(* | dsi_callback_t )(MIPI_DSI_HOST_Type *base, dsi_handle_t *handle, status_t status, void *userData) |
MIPI DSI callback for finished transfer. More... | |
Driver version | |
#define | FSL_MIPI_DSI_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
Version 2.0.0. | |
MIPI_DSI host initialization. | |
void | DSI_Init (MIPI_DSI_HOST_Type *base, const dsi_config_t *config) |
Initializes an MIPI DSI host with the user configuration. More... | |
void | DSI_Deinit (MIPI_DSI_HOST_Type *base) |
Deinitializes an MIPI DSI host. More... | |
void | DSI_GetDefaultConfig (dsi_config_t *config) |
Get the default configuration to initialize the MIPI DSI host. More... | |
DPI interface | |
void | DSI_SetDpiConfig (MIPI_DSI_HOST_Type *base, const dsi_dpi_config_t *config, uint8_t numLanes, uint32_t dpiPixelClkFreq_Hz, uint32_t dsiHsBitClkFreq_Hz) |
Configure the DPI interface core. More... | |
D-PHY configuration. | |
uint32_t | DSI_InitDphy (MIPI_DSI_HOST_Type *base, const dsi_dphy_config_t *config, uint32_t refClkFreq_Hz) |
Initializes the D-PHY. More... | |
void | DSI_DeinitDphy (MIPI_DSI_HOST_Type *base) |
Deinitializes the D-PHY. More... | |
void | DSI_GetDphyDefaultConfig (dsi_dphy_config_t *config, uint32_t txHsBitClk_Hz, uint32_t txEscClk_Hz) |
Get the default D-PHY configuration. More... | |
Interrupts | |
static void | DSI_EnableInterrupts (MIPI_DSI_HOST_Type *base, uint32_t intGroup1, uint32_t intGroup2) |
Enable the interrupts. More... | |
static void | DSI_DisableInterrupts (MIPI_DSI_HOST_Type *base, uint32_t intGroup1, uint32_t intGroup2) |
Disable the interrupts. More... | |
static void | DSI_GetAndClearInterruptStatus (MIPI_DSI_HOST_Type *base, uint32_t *intGroup1, uint32_t *intGroup2) |
Get and clear the interrupt status. More... | |
MIPI DSI APB | |
void | DSI_SetApbPacketControl (MIPI_DSI_HOST_Type *base, uint16_t wordCount, uint8_t virtualChannel, dsi_tx_data_type_t dataType, uint8_t flags) |
Configure the APB packet to send. More... | |
void | DSI_WriteApbTxPayload (MIPI_DSI_HOST_Type *base, const uint8_t *payload, uint16_t payloadSize) |
Fill the long APB packet payload. More... | |
void | DSI_ReadApbRxPayload (MIPI_DSI_HOST_Type *base, uint8_t *payload, uint16_t payloadSize) |
Read the long APB packet payload. More... | |
static void | DSI_SendApbPacket (MIPI_DSI_HOST_Type *base) |
Trigger the controller to send out APB packet. More... | |
static uint32_t | DSI_GetApbStatus (MIPI_DSI_HOST_Type *base) |
Get the APB status. More... | |
static uint32_t | DSI_GetRxErrorStatus (MIPI_DSI_HOST_Type *base) |
Get the error status during data transfer. More... | |
static uint8_t | DSI_GetEccRxErrorPosition (uint32_t rxErrorStatus) |
Get the one-bit RX ECC error position. More... | |
static uint32_t | DSI_GetAndClearHostStatus (MIPI_DSI_HOST_Type *base) |
Get and clear the DSI host status. More... | |
static uint32_t | DSI_GetRxPacketHeader (MIPI_DSI_HOST_Type *base) |
Get the RX packet header. More... | |
static dsi_rx_data_type_t | DSI_GetRxPacketType (uint32_t rxPktHeader) |
Extract the RX packet type from the packet header. More... | |
static uint16_t | DSI_GetRxPacketWordCount (uint32_t rxPktHeader) |
Extract the RX packet word count from the packet header. More... | |
static uint8_t | DSI_GetRxPacketVirtualChannel (uint32_t rxPktHeader) |
Extract the RX packet virtual channel from the packet header. More... | |
status_t | DSI_TransferBlocking (MIPI_DSI_HOST_Type *base, dsi_transfer_t *xfer) |
APB data transfer using blocking method. More... | |
Transactional | |
status_t | DSI_TransferCreateHandle (MIPI_DSI_HOST_Type *base, dsi_handle_t *handle, dsi_callback_t callback, void *userData) |
Create the MIPI DSI handle. More... | |
status_t | DSI_TransferNonBlocking (MIPI_DSI_HOST_Type *base, dsi_handle_t *handle, dsi_transfer_t *xfer) |
APB data transfer using interrupt method. More... | |
void | DSI_TransferAbort (MIPI_DSI_HOST_Type *base, dsi_handle_t *handle) |
Abort current APB data transfer. More... | |
void | DSI_TransferHandleIRQ (MIPI_DSI_HOST_Type *base, dsi_handle_t *handle) |
Interrupt handler for the DSI. More... | |
struct dsi_config_t |
Data Fields | |
uint8_t | numLanes |
Number of lanes. More... | |
bool | enableNonContinuousHsClk |
In enabled, the high speed clock will enter low power mode between transmissions. More... | |
bool | enableTxUlps |
Enable the TX ULPS. More... | |
bool | autoInsertEoTp |
Insert an EoTp short package when switching from HS to LP. More... | |
uint8_t | numExtraEoTp |
How many extra EoTp to send after the end of a packet. More... | |
uint32_t | htxTo_ByteClk |
HS TX timeout count (HTX_TO) in byte clock. More... | |
uint32_t | lrxHostTo_ByteClk |
LP RX host timeout count (LRX-H_TO) in byte clock. More... | |
uint32_t | btaTo_ByteClk |
Bus turn around timeout count (TA_TO) in byte clock. More... | |
uint8_t dsi_config_t::numLanes |
bool dsi_config_t::enableNonContinuousHsClk |
bool dsi_config_t::enableTxUlps |
bool dsi_config_t::autoInsertEoTp |
uint8_t dsi_config_t::numExtraEoTp |
uint32_t dsi_config_t::htxTo_ByteClk |
uint32_t dsi_config_t::lrxHostTo_ByteClk |
uint32_t dsi_config_t::btaTo_ByteClk |
struct dsi_dpi_config_t |
Data Fields | |
uint16_t | pixelPayloadSize |
Maximum number of pixels that should be sent as one DSI packet. More... | |
dsi_dpi_color_coding_t | dpiColorCoding |
DPI color coding. More... | |
dsi_dpi_pixel_packet_t | pixelPacket |
Pixel packet format. More... | |
dsi_dpi_video_mode_t | videoMode |
Video mode. More... | |
dsi_dpi_bllp_mode_t | bllpMode |
Behavior in BLLP. More... | |
uint8_t | polarityFlags |
OR'ed value of _dsi_dpi_polarity_flag controls signal polarity. More... | |
uint16_t | hfp |
Horizontal front porch, in dpi pixel clock. More... | |
uint16_t | hbp |
Horizontal back porch, in dpi pixel clock. More... | |
uint16_t | hsw |
Horizontal sync width, in dpi pixel clock. More... | |
uint8_t | vfp |
Number of lines in vertical front porch. More... | |
uint8_t | vbp |
Number of lines in vertical back porch. More... | |
uint16_t | panelHeight |
Line number in vertical active area. More... | |
uint8_t | virtualChannel |
Virtual channel. More... | |
uint16_t dsi_dpi_config_t::pixelPayloadSize |
Recommended that the line size (in pixels) is evenly divisible by this parameter.
dsi_dpi_color_coding_t dsi_dpi_config_t::dpiColorCoding |
dsi_dpi_pixel_packet_t dsi_dpi_config_t::pixelPacket |
dsi_dpi_video_mode_t dsi_dpi_config_t::videoMode |
dsi_dpi_bllp_mode_t dsi_dpi_config_t::bllpMode |
uint8_t dsi_dpi_config_t::polarityFlags |
uint16_t dsi_dpi_config_t::hfp |
uint16_t dsi_dpi_config_t::hbp |
uint16_t dsi_dpi_config_t::hsw |
uint8_t dsi_dpi_config_t::vfp |
uint8_t dsi_dpi_config_t::vbp |
uint16_t dsi_dpi_config_t::panelHeight |
uint8_t dsi_dpi_config_t::virtualChannel |
struct dsi_dphy_config_t |
Data Fields | |
uint32_t | txHsBitClk_Hz |
The generated HS TX bit clock in Hz. More... | |
uint8_t | tClkPre_ByteClk |
TCLK-PRE in byte clock. More... | |
uint8_t | tClkPost_ByteClk |
TCLK-POST in byte clock. More... | |
uint8_t | tHsExit_ByteClk |
THS-EXIT in byte clock. More... | |
uint32_t | tWakeup_EscClk |
Number of clk_esc clock periods to keep a clock or data lane in Mark-1 state after exiting ULPS. More... | |
uint8_t | tHsPrepare_HalfEscClk |
THS-PREPARE in clk_esc/2. More... | |
uint8_t | tClkPrepare_HalfEscClk |
TCLK-PREPARE in clk_esc/2. More... | |
uint8_t | tHsZero_ByteClk |
THS-ZERO in clk_byte. More... | |
uint8_t | tClkZero_ByteClk |
TCLK-ZERO in clk_byte. More... | |
uint8_t | tHsTrail_ByteClk |
THS-TRAIL in clk_byte. More... | |
uint8_t | tClkTrail_ByteClk |
TCLK-TRAIL in clk_byte. More... | |
uint32_t dsi_dphy_config_t::txHsBitClk_Hz |
uint8_t dsi_dphy_config_t::tClkPre_ByteClk |
Set how long the controller will wait after enabling clock lane for HS before enabling data lanes for HS.
uint8_t dsi_dphy_config_t::tClkPost_ByteClk |
Set how long the controller will wait before putting clock lane into LP mode after data lanes detected in stop state.
uint8_t dsi_dphy_config_t::tHsExit_ByteClk |
Set how long the controller will wait after the clock lane has been put into LP mode before enabling clock lane for HS again.
uint32_t dsi_dphy_config_t::tWakeup_EscClk |
uint8_t dsi_dphy_config_t::tHsPrepare_HalfEscClk |
Set how long to drive the LP-00 state before HS transmissions, available values are 2, 3, 4, 5.
uint8_t dsi_dphy_config_t::tClkPrepare_HalfEscClk |
Set how long to drive the LP-00 state before HS transmissions, available values are 2, 3.
uint8_t dsi_dphy_config_t::tHsZero_ByteClk |
Set how long that controller drives data lane HS-0 state before transmit the Sync sequence. Available values are 6, 7, ..., 37.
uint8_t dsi_dphy_config_t::tClkZero_ByteClk |
Set how long that controller drives clock lane HS-0 state before transmit the Sync sequence. Available values are 3, 4, ..., 66.
uint8_t dsi_dphy_config_t::tHsTrail_ByteClk |
Set the time of the flipped differential state after last payload data bit of HS transmission burst. Available values are 0, 1, ..., 15.
uint8_t dsi_dphy_config_t::tClkTrail_ByteClk |
Set the time of the flipped differential state after last payload data bit of HS transmission burst. Available values are 0, 1, ..., 15.
struct dsi_transfer_t |
Data Fields | |
uint8_t | virtualChannel |
Virtual channel. More... | |
dsi_tx_data_type_t | txDataType |
TX data type. More... | |
uint8_t | flags |
Flags to control the transfer, see _dsi_transfer_flags. More... | |
const uint8_t * | txData |
The TX data buffer. More... | |
uint8_t * | rxData |
The TX data buffer. More... | |
uint16_t | txDataSize |
Size of the TX data. More... | |
uint16_t | rxDataSize |
Size of the RX data. More... | |
uint8_t dsi_transfer_t::virtualChannel |
dsi_tx_data_type_t dsi_transfer_t::txDataType |
uint8_t dsi_transfer_t::flags |
const uint8_t* dsi_transfer_t::txData |
uint8_t* dsi_transfer_t::rxData |
uint16_t dsi_transfer_t::txDataSize |
uint16_t dsi_transfer_t::rxDataSize |
struct _dsi_handle |
MIPI DSI transfer handle.
Data Fields | |
volatile bool | isBusy |
MIPI DSI is busy with APB data transfer. More... | |
dsi_transfer_t | xfer |
Transfer information. More... | |
dsi_callback_t | callback |
DSI callback. | |
void * | userData |
Callback parameter. | |
volatile bool dsi_handle_t::isBusy |
dsi_transfer_t dsi_handle_t::xfer |
typedef void(* dsi_callback_t)(MIPI_DSI_HOST_Type *base, dsi_handle_t *handle, status_t status, void *userData) |
When transfer finished, one of these status values will be passed to the user:
enum _dsi_status |
enum dsi_dpi_video_mode_t |
enum dsi_dpi_bllp_mode_t |
enum _dsi_apb_status |
enum _dsi_rx_error_status |
enum _dsi_host_status |
enum _dsi_interrupt |
enum dsi_tx_data_type_t |
enum dsi_rx_data_type_t |
enum _dsi_transfer_flags |
void DSI_Init | ( | MIPI_DSI_HOST_Type * | base, |
const dsi_config_t * | config | ||
) |
This function initializes the MIPI DSI host with the configuration, it should be called first before other MIPI DSI driver functions.
base | MIPI DSI host peripheral base address. |
config | Pointer to a user-defined configuration structure. |
void DSI_Deinit | ( | MIPI_DSI_HOST_Type * | base | ) |
This function should be called after all bother MIPI DSI driver functions.
base | MIPI DSI host peripheral base address. |
void DSI_GetDefaultConfig | ( | dsi_config_t * | config | ) |
The default value is:
config | Pointer to a user-defined configuration structure. |
void DSI_SetDpiConfig | ( | MIPI_DSI_HOST_Type * | base, |
const dsi_dpi_config_t * | config, | ||
uint8_t | numLanes, | ||
uint32_t | dpiPixelClkFreq_Hz, | ||
uint32_t | dsiHsBitClkFreq_Hz | ||
) |
This function sets the DPI interface configuration, it should be used in video mode.
base | MIPI DSI host peripheral base address. |
config | Pointer to the DPI interface configuration. |
numLanes | Lane number, should be same with the setting in dsi_dpi_config_t. |
dpiPixelClkFreq_Hz | The DPI pixel clock frequency in Hz. |
dsiHsBitClkFreq_Hz | The DSI high speed bit clock frequency in Hz. It is the same with DPHY PLL output. |
uint32_t DSI_InitDphy | ( | MIPI_DSI_HOST_Type * | base, |
const dsi_dphy_config_t * | config, | ||
uint32_t | refClkFreq_Hz | ||
) |
This function configures the D-PHY timing and setups the D-PHY PLL based on user configuration. The configuration structure could be got by the function DSI_GetDphyDefaultConfig.
base | MIPI DSI host peripheral base address. |
config | Pointer to the D-PHY configuration. |
refClkFreq_Hz | The REFCLK frequency in Hz. |
void DSI_DeinitDphy | ( | MIPI_DSI_HOST_Type * | base | ) |
Power down the D-PHY PLL and shut down D-PHY.
base | MIPI DSI host peripheral base address. |
void DSI_GetDphyDefaultConfig | ( | dsi_dphy_config_t * | config, |
uint32_t | txHsBitClk_Hz, | ||
uint32_t | txEscClk_Hz | ||
) |
Gets the default D-PHY configuration, the timing parameters are set according to D-PHY specification. User could use the configuration directly, or change some parameters according to the special device.
config | Pointer to the D-PHY configuration. |
txHsBitClk_Hz | High speed bit clock in Hz. |
txEscClk_Hz | Esc clock in Hz. |
|
inlinestatic |
The interrupts to enable are passed in as OR'ed mask value of _dsi_interrupt.
base | MIPI DSI host peripheral base address. |
intGroup1 | Interrupts to enable in group 1. |
intGroup2 | Interrupts to enable in group 2. |
|
inlinestatic |
The interrupts to disable are passed in as OR'ed mask value of _dsi_interrupt.
base | MIPI DSI host peripheral base address. |
intGroup1 | Interrupts to disable in group 1. |
intGroup2 | Interrupts to disable in group 2. |
|
inlinestatic |
base | MIPI DSI host peripheral base address. |
intGroup1 | Group 1 interrupt status. |
intGroup2 | Group 2 interrupt status. |
void DSI_SetApbPacketControl | ( | MIPI_DSI_HOST_Type * | base, |
uint16_t | wordCount, | ||
uint8_t | virtualChannel, | ||
dsi_tx_data_type_t | dataType, | ||
uint8_t | flags | ||
) |
This function configures the next APB packet transfer. After configuration, the packet transfer could be started with function DSI_SendApbPacket. If the packet is long packet, Use DSI_WriteApbTxPayload to fill the payload before start transfer.
base | MIPI DSI host peripheral base address. |
wordCount | For long packet, this is the byte count of the payload. For short packet, this is (data1 << 8) | data0. |
virtualChannel | Virtual channel. |
dataType | The packet data type, (DI). |
flags | The transfer control flags, see _dsi_transfer_flags. |
void DSI_WriteApbTxPayload | ( | MIPI_DSI_HOST_Type * | base, |
const uint8_t * | payload, | ||
uint16_t | payloadSize | ||
) |
Write the long packet payload to TX FIFO.
base | MIPI DSI host peripheral base address. |
payload | Pointer to the payload. |
payloadSize | Payload size in byte. |
void DSI_ReadApbRxPayload | ( | MIPI_DSI_HOST_Type * | base, |
uint8_t * | payload, | ||
uint16_t | payloadSize | ||
) |
Read the long packet payload from RX FIFO. This function reads directly but does not check the RX FIFO status. Upper layer should make sure there are available data.
base | MIPI DSI host peripheral base address. |
payload | Pointer to the payload. |
payloadSize | Payload size in byte. |
|
inlinestatic |
Send the packet set by DSI_SetApbPacketControl.
base | MIPI DSI host peripheral base address. |
|
inlinestatic |
The return value is OR'ed value of _dsi_apb_status.
base | MIPI DSI host peripheral base address. |
|
inlinestatic |
The return value is OR'ed value of _dsi_rx_error_status.
base | MIPI DSI host peripheral base address. |
|
inlinestatic |
When one-bit ECC RX error detected using DSI_GetRxErrorStatus, this function could be used to get the error bit position.
rxErrorStatus | The error status returned by DSI_GetRxErrorStatus. |
|
inlinestatic |
The host status are returned as mask value of _dsi_host_status.
base | MIPI DSI host peripheral base address. |
|
inlinestatic |
base | MIPI DSI host peripheral base address. |
|
inlinestatic |
Extract the RX packet type from the packet header get by DSI_GetRxPacketHeader.
rxPktHeader | The RX packet header get by DSI_GetRxPacketHeader. |
|
inlinestatic |
Extract the RX packet word count from the packet header get by DSI_GetRxPacketHeader.
rxPktHeader | The RX packet header get by DSI_GetRxPacketHeader. |
|
inlinestatic |
Extract the RX packet virtual channel from the packet header get by DSI_GetRxPacketHeader.
rxPktHeader | The RX packet header get by DSI_GetRxPacketHeader. |
status_t DSI_TransferBlocking | ( | MIPI_DSI_HOST_Type * | base, |
dsi_transfer_t * | xfer | ||
) |
Perform APB data transfer using blocking method. This function waits until all data send or received, or timeout happens.
base | MIPI DSI host peripheral base address. |
xfer | Pointer to the transfer structure. |
kStatus_Success | Data transfer finished with no error. |
kStatus_Timeout | Transfer failed because of timeout. |
kStatus_DSI_RxDataError | RX data error, user could use DSI_GetRxErrorStatus to check the error details. |
kStatus_DSI_ErrorReportReceived | Error Report packet received, user could use DSI_GetAndClearHostStatus to check the error report status. |
kStatus_DSI_NotSupported | Transfer format not supported. |
kStatus_DSI_Fail | Transfer failed for other reasons. |
status_t DSI_TransferCreateHandle | ( | MIPI_DSI_HOST_Type * | base, |
dsi_handle_t * | handle, | ||
dsi_callback_t | callback, | ||
void * | userData | ||
) |
This function initializes the MIPI DSI handle which can be used for other transactional APIs.
base | MIPI DSI host peripheral base address. |
handle | Handle pointer. |
callback | Callback function. |
userData | User data. |
status_t DSI_TransferNonBlocking | ( | MIPI_DSI_HOST_Type * | base, |
dsi_handle_t * | handle, | ||
dsi_transfer_t * | xfer | ||
) |
Perform APB data transfer using interrupt method, when transfer finished, upper layer could be informed through callback function.
base | MIPI DSI host peripheral base address. |
handle | pointer to dsi_handle_t structure which stores the transfer state. |
xfer | Pointer to the transfer structure. |
kStatus_Success | Data transfer started successfully. |
kStatus_DSI_Busy | Failed to start transfer because DSI is busy with pervious transfer. |
kStatus_DSI_NotSupported | Transfer format not supported. |
void DSI_TransferAbort | ( | MIPI_DSI_HOST_Type * | base, |
dsi_handle_t * | handle | ||
) |
base | MIPI DSI host peripheral base address. |
handle | pointer to dsi_handle_t structure which stores the transfer state. |
void DSI_TransferHandleIRQ | ( | MIPI_DSI_HOST_Type * | base, |
dsi_handle_t * | handle | ||
) |
base | MIPI DSI host peripheral base address. |
handle | pointer to dsi_handle_t structure which stores the transfer state. |