STM32F4xx HAL Documentation
Hardware Abstraction Layer for STM32F4 familiy
Loading...
Searching...
No Matches
stm32f4xx_hal_dsi.c File Reference

DSI HAL module driver. This file provides firmware functions to manage the following functionalities of the DSI peripheral: More...

#include "stm32f4xx_hal.h"
Include dependency graph for stm32f4xx_hal_dsi.c:

Go to the source code of this file.

Macros

#define DSI_TIMEOUT_VALUE   ((uint32_t)1000U) /* 1s */
 
#define DSI_ERROR_ACK_MASK
 
#define DSI_ERROR_PHY_MASK   (DSI_ISR0_PE0 | DSI_ISR0_PE1 | DSI_ISR0_PE2 | DSI_ISR0_PE3 | DSI_ISR0_PE4)
 
#define DSI_ERROR_TX_MASK   DSI_ISR1_TOHSTX
 
#define DSI_ERROR_RX_MASK   DSI_ISR1_TOLPRX
 
#define DSI_ERROR_ECC_MASK   (DSI_ISR1_ECCSE | DSI_ISR1_ECCME)
 
#define DSI_ERROR_CRC_MASK   DSI_ISR1_CRCE
 
#define DSI_ERROR_PSE_MASK   DSI_ISR1_PSE
 
#define DSI_ERROR_EOT_MASK   DSI_ISR1_EOTPE
 
#define DSI_ERROR_OVF_MASK   DSI_ISR1_LPWRE
 
#define DSI_ERROR_GEN_MASK   (DSI_ISR1_GCWRE | DSI_ISR1_GPWRE | DSI_ISR1_GPTXE | DSI_ISR1_GPRDE | DSI_ISR1_GPRXE)
 

Functions

static void DSI_ConfigPacketHeader (DSI_TypeDef *DSIx, uint32_t ChannelID, uint32_t DataType, uint32_t Data0, uint32_t Data1)
 Generic DSI packet header configuration.
 
static HAL_StatusTypeDef DSI_ShortWrite (DSI_HandleTypeDef *hdsi, uint32_t ChannelID, uint32_t Mode, uint32_t Param1, uint32_t Param2)
 write short DCS or short Generic command
 
HAL_StatusTypeDef HAL_DSI_Init (DSI_HandleTypeDef *hdsi, DSI_PLLInitTypeDef *PLLInit)
 Initializes the DSI according to the specified parameters in the DSI_InitTypeDef and create the associated handle.
 
HAL_StatusTypeDef HAL_DSI_DeInit (DSI_HandleTypeDef *hdsi)
 De-initializes the DSI peripheral registers to their default reset values.
 
HAL_StatusTypeDef HAL_DSI_ConfigErrorMonitor (DSI_HandleTypeDef *hdsi, uint32_t ActiveErrors)
 Enable the error monitor flags.
 
void HAL_DSI_MspInit (DSI_HandleTypeDef *hdsi)
 Initializes the DSI MSP.
 
void HAL_DSI_MspDeInit (DSI_HandleTypeDef *hdsi)
 De-initializes the DSI MSP.
 
void HAL_DSI_IRQHandler (DSI_HandleTypeDef *hdsi)
 Handles DSI interrupt request.
 
void HAL_DSI_TearingEffectCallback (DSI_HandleTypeDef *hdsi)
 Tearing Effect DSI callback.
 
void HAL_DSI_EndOfRefreshCallback (DSI_HandleTypeDef *hdsi)
 End of Refresh DSI callback.
 
void HAL_DSI_ErrorCallback (DSI_HandleTypeDef *hdsi)
 Operation Error DSI callback.
 
HAL_StatusTypeDef HAL_DSI_SetGenericVCID (DSI_HandleTypeDef *hdsi, uint32_t VirtualChannelID)
 Configure the Generic interface read-back Virtual Channel ID.
 
HAL_StatusTypeDef HAL_DSI_ConfigVideoMode (DSI_HandleTypeDef *hdsi, DSI_VidCfgTypeDef *VidCfg)
 Select video mode and configure the corresponding parameters.
 
HAL_StatusTypeDef HAL_DSI_ConfigAdaptedCommandMode (DSI_HandleTypeDef *hdsi, DSI_CmdCfgTypeDef *CmdCfg)
 Select adapted command mode and configure the corresponding parameters.
 
HAL_StatusTypeDef HAL_DSI_ConfigCommand (DSI_HandleTypeDef *hdsi, DSI_LPCmdTypeDef *LPCmd)
 Configure command transmission mode: High-speed or Low-power and enable/disable acknowledge request after packet transmission.
 
HAL_StatusTypeDef HAL_DSI_ConfigFlowControl (DSI_HandleTypeDef *hdsi, uint32_t FlowControl)
 Configure the flow control parameters.
 
HAL_StatusTypeDef HAL_DSI_ConfigPhyTimer (DSI_HandleTypeDef *hdsi, DSI_PHY_TimerTypeDef *PhyTimers)
 Configure the DSI PHY timer parameters.
 
HAL_StatusTypeDef HAL_DSI_ConfigHostTimeouts (DSI_HandleTypeDef *hdsi, DSI_HOST_TimeoutTypeDef *HostTimeouts)
 Configure the DSI HOST timeout parameters.
 
HAL_StatusTypeDef HAL_DSI_Start (DSI_HandleTypeDef *hdsi)
 Start the DSI module.
 
HAL_StatusTypeDef HAL_DSI_Stop (DSI_HandleTypeDef *hdsi)
 Stop the DSI module.
 
HAL_StatusTypeDef HAL_DSI_Refresh (DSI_HandleTypeDef *hdsi)
 Refresh the display in command mode.
 
HAL_StatusTypeDef HAL_DSI_ColorMode (DSI_HandleTypeDef *hdsi, uint32_t ColorMode)
 Controls the display color mode in Video mode.
 
HAL_StatusTypeDef HAL_DSI_Shutdown (DSI_HandleTypeDef *hdsi, uint32_t Shutdown)
 Control the display shutdown in Video mode.
 
HAL_StatusTypeDef HAL_DSI_ShortWrite (DSI_HandleTypeDef *hdsi, uint32_t ChannelID, uint32_t Mode, uint32_t Param1, uint32_t Param2)
 write short DCS or short Generic command
 
HAL_StatusTypeDef HAL_DSI_LongWrite (DSI_HandleTypeDef *hdsi, uint32_t ChannelID, uint32_t Mode, uint32_t NbParams, uint32_t Param1, const uint8_t *ParametersTable)
 write long DCS or long Generic command
 
HAL_StatusTypeDef HAL_DSI_Read (DSI_HandleTypeDef *hdsi, uint32_t ChannelNbr, uint8_t *Array, uint32_t Size, uint32_t Mode, uint32_t DCSCmd, uint8_t *ParametersTable)
 Read command (DCS or generic)
 
HAL_StatusTypeDef HAL_DSI_EnterULPMData (DSI_HandleTypeDef *hdsi)
 Enter the ULPM (Ultra Low Power Mode) with the D-PHY PLL running (only data lanes are in ULPM)
 
HAL_StatusTypeDef HAL_DSI_ExitULPMData (DSI_HandleTypeDef *hdsi)
 Exit the ULPM (Ultra Low Power Mode) with the D-PHY PLL running (only data lanes are in ULPM)
 
HAL_StatusTypeDef HAL_DSI_EnterULPM (DSI_HandleTypeDef *hdsi)
 Enter the ULPM (Ultra Low Power Mode) with the D-PHY PLL turned off (both data and clock lanes are in ULPM)
 
HAL_StatusTypeDef HAL_DSI_ExitULPM (DSI_HandleTypeDef *hdsi)
 Exit the ULPM (Ultra Low Power Mode) with the D-PHY PLL turned off (both data and clock lanes are in ULPM)
 
HAL_StatusTypeDef HAL_DSI_PatternGeneratorStart (DSI_HandleTypeDef *hdsi, uint32_t Mode, uint32_t Orientation)
 Start test pattern generation.
 
HAL_StatusTypeDef HAL_DSI_PatternGeneratorStop (DSI_HandleTypeDef *hdsi)
 Stop test pattern generation.
 
HAL_StatusTypeDef HAL_DSI_SetSlewRateAndDelayTuning (DSI_HandleTypeDef *hdsi, uint32_t CommDelay, uint32_t Lane, uint32_t Value)
 Set Slew-Rate And Delay Tuning.
 
HAL_StatusTypeDef HAL_DSI_SetLowPowerRXFilter (DSI_HandleTypeDef *hdsi, uint32_t Frequency)
 Low-Power Reception Filter Tuning.
 
HAL_StatusTypeDef HAL_DSI_SetSDD (DSI_HandleTypeDef *hdsi, FunctionalState State)
 Activate an additional current path on all lanes to meet the SDDTx parameter defined in the MIPI D-PHY specification.
 
HAL_StatusTypeDef HAL_DSI_SetLanePinsConfiguration (DSI_HandleTypeDef *hdsi, uint32_t CustomLane, uint32_t Lane, FunctionalState State)
 Custom lane pins configuration.
 
HAL_StatusTypeDef HAL_DSI_SetPHYTimings (DSI_HandleTypeDef *hdsi, uint32_t Timing, FunctionalState State, uint32_t Value)
 Set custom timing for the PHY.
 
HAL_StatusTypeDef HAL_DSI_ForceTXStopMode (DSI_HandleTypeDef *hdsi, uint32_t Lane, FunctionalState State)
 Force the Clock/Data Lane in TX Stop Mode.
 
HAL_StatusTypeDef HAL_DSI_ForceRXLowPower (DSI_HandleTypeDef *hdsi, FunctionalState State)
 Force LP Receiver in Low-Power Mode.
 
HAL_StatusTypeDef HAL_DSI_ForceDataLanesInRX (DSI_HandleTypeDef *hdsi, FunctionalState State)
 Force Data Lanes in RX Mode after a BTA.
 
HAL_StatusTypeDef HAL_DSI_SetPullDown (DSI_HandleTypeDef *hdsi, FunctionalState State)
 Enable a pull-down on the lanes to prevent from floating states when unused.
 
HAL_StatusTypeDef HAL_DSI_SetContentionDetectionOff (DSI_HandleTypeDef *hdsi, FunctionalState State)
 Switch off the contention detection on data lanes.
 
HAL_DSI_StateTypeDef HAL_DSI_GetState (const DSI_HandleTypeDef *hdsi)
 Return the DSI state.
 
uint32_t HAL_DSI_GetError (const DSI_HandleTypeDef *hdsi)
 Return the DSI error code.
 

Detailed Description

DSI HAL module driver. This file provides firmware functions to manage the following functionalities of the DSI peripheral:

Author
MCD Application Team
  • Initialization and de-initialization functions
  • IO operation functions
  • Peripheral Control functions
  • Peripheral State and Errors functions
Attention

Copyright (c) 2016 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

==============================================================================
                      ##### How to use this driver #####
==============================================================================
[..]
  The DSI HAL driver can be used as follows:

  (#) Declare a DSI_HandleTypeDef handle structure, for example: DSI_HandleTypeDef  hdsi;

  (#) Initialize the DSI low level resources by implementing the HAL_DSI_MspInit() API:
      (##) Enable the DSI interface clock
      (##) NVIC configuration if you need to use interrupt process
          (+++) Configure the DSI interrupt priority
          (+++) Enable the NVIC DSI IRQ Channel

  (#) Initialize the DSI Host peripheral, the required PLL parameters, number of lances and
      TX Escape clock divider by calling the HAL_DSI_Init() API which calls HAL_DSI_MspInit().

  *** Configuration ***
  =========================
  [..]
  (#) Use HAL_DSI_ConfigAdaptedCommandMode() function to configure the DSI host in adapted
      command mode.

  (#) When operating in video mode , use HAL_DSI_ConfigVideoMode() to configure the DSI host.

  (#) Function HAL_DSI_ConfigCommand() is used to configure the DSI commands behavior in low power mode.

  (#) To configure the DSI PHY timings parameters, use function HAL_DSI_ConfigPhyTimer().

  (#) The DSI Host can be started/stopped using respectively functions HAL_DSI_Start() and HAL_DSI_Stop().
      Functions HAL_DSI_ShortWrite(), HAL_DSI_LongWrite() and HAL_DSI_Read() allows respectively
      to write DSI short packets, long packets and to read DSI packets.

  (#) The DSI Host Offers two Low power modes :
      (++) Low Power Mode on data lanes only: Only DSI data lanes are shut down.
          It is possible to enter/exit from this mode using respectively functions HAL_DSI_EnterULPMData()
          and HAL_DSI_ExitULPMData()

      (++) Low Power Mode on data and clock lanes : All DSI lanes are shut down including data and clock lanes.
          It is possible to enter/exit from this mode using respectively functions HAL_DSI_EnterULPM()
          and HAL_DSI_ExitULPM()

  (#) To control DSI state you can use the following function: HAL_DSI_GetState()

  *** Error management ***
  ========================
  [..]
  (#) User can select the DSI errors to be reported/monitored using function HAL_DSI_ConfigErrorMonitor()
      When an error occurs, the callback HAL_DSI_ErrorCallback() is asserted and then user can retrieve
      the error code by calling function HAL_DSI_GetError()

  *** DSI HAL driver macros list ***
  =============================================
  [..]
     Below the list of most used macros in DSI HAL driver.

    (+) __HAL_DSI_ENABLE: Enable the DSI Host.
    (+) __HAL_DSI_DISABLE: Disable the DSI Host.
    (+) __HAL_DSI_WRAPPER_ENABLE: Enables the DSI wrapper.
    (+) __HAL_DSI_WRAPPER_DISABLE: Disable the DSI wrapper.
    (+) __HAL_DSI_PLL_ENABLE: Enables the DSI PLL.
    (+) __HAL_DSI_PLL_DISABLE: Disables the DSI PLL.
    (+) __HAL_DSI_REG_ENABLE: Enables the DSI regulator.
    (+) __HAL_DSI_REG_DISABLE: Disables the DSI regulator.
    (+) __HAL_DSI_GET_FLAG: Get the DSI pending flags.
    (+) __HAL_DSI_CLEAR_FLAG: Clears the DSI pending flags.
    (+) __HAL_DSI_ENABLE_IT: Enables the specified DSI interrupts.
    (+) __HAL_DSI_DISABLE_IT: Disables the specified DSI interrupts.
    (+) __HAL_DSI_GET_IT_SOURCE: Checks whether the specified DSI interrupt source is enabled or not.

  [..]
    (@) You can refer to the DSI HAL driver header file for more useful macros

  *** Callback registration ***
  =============================================
  [..]
  The compilation define  USE_HAL_DSI_REGISTER_CALLBACKS when set to 1
  allows the user to configure dynamically the driver callbacks.
  Use Function HAL_DSI_RegisterCallback() to register a callback.

  [..]
  Function HAL_DSI_RegisterCallback() allows to register following callbacks:
    (+) TearingEffectCallback : DSI Tearing Effect Callback.
    (+) EndOfRefreshCallback  : DSI End Of Refresh Callback.
    (+) ErrorCallback         : DSI Error Callback
    (+) MspInitCallback       : DSI MspInit.
    (+) MspDeInitCallback     : DSI MspDeInit.
  [..]
  This function takes as parameters the HAL peripheral handle, the callback ID
  and a pointer to the user callback function.

  [..]
  Use function HAL_DSI_UnRegisterCallback() to reset a callback to the default
  weak function.
  HAL_DSI_UnRegisterCallback takes as parameters the HAL peripheral handle,
  and the callback ID.
  [..]
  This function allows to reset following callbacks:
    (+) TearingEffectCallback : DSI Tearing Effect Callback.
    (+) EndOfRefreshCallback  : DSI End Of Refresh Callback.
    (+) ErrorCallback         : DSI Error Callback
    (+) MspInitCallback       : DSI MspInit.
    (+) MspDeInitCallback     : DSI MspDeInit.

  [..]
  By default, after the HAL_DSI_Init and when the state is HAL_DSI_STATE_RESET
  all callbacks are set to the corresponding weak functions:
  examples HAL_DSI_TearingEffectCallback(), HAL_DSI_EndOfRefreshCallback().
  Exception done for MspInit and MspDeInit functions that are respectively
  reset to the legacy weak (overridden) functions in the HAL_DSI_Init()
  and HAL_DSI_DeInit() only when these callbacks are null (not registered beforehand).
  If not, MspInit or MspDeInit are not null, the HAL_DSI_Init() and HAL_DSI_DeInit()
  keep and use the user MspInit/MspDeInit callbacks (registered beforehand).

  [..]
  Callbacks can be registered/unregistered in HAL_DSI_STATE_READY state only.
  Exception done MspInit/MspDeInit that can be registered/unregistered
  in HAL_DSI_STATE_READY or HAL_DSI_STATE_RESET state,
  thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
  In that case first register the MspInit/MspDeInit user callbacks
  using HAL_DSI_RegisterCallback() before calling HAL_DSI_DeInit()
  or HAL_DSI_Init() function.

  [..]
  When The compilation define USE_HAL_DSI_REGISTER_CALLBACKS is set to 0 or
  not defined, the callback registration feature is not available and all callbacks
  are set to the corresponding weak functions.

Definition in file stm32f4xx_hal_dsi.c.