2 ******************************************************************************
3 * @file stm32f7xx_hal_dsi.c
4 * @author MCD Application Team
5 * @brief DSI HAL module driver.
6 * This file provides firmware functions to manage the following
7 * functionalities of the DSI peripheral:
8 * + Initialization and de-initialization functions
9 * + IO operation functions
10 * + Peripheral Control functions
11 * + Peripheral State and Errors functions
13 ==============================================================================
14 ##### How to use this driver #####
15 ==============================================================================
17 (#) Use @ref HAL_DSI_Init() function to initialize the DSI Host IP and program the required
18 PLL parameters, number of lanes and TX Escape clock divider.
19 (#) Use @ref HAL_DSI_ConfigAdaptedCommandMode() function to configure the DSI host in adapted
21 (#) When operating in video mode , use @ref HAL_DSI_ConfigVideoMode() to configure the DSI host.
22 (#) Function @ref HAL_DSI_ConfigCommand() is used to configure the DSI commands behavior in low power mode.
23 (#) To configure the DSI PHY timings parameters, use function @ref HAL_DSI_ConfigPhyTimer().
24 (#) The DSI Host can be started/stopped using respectively functions @ref HAL_DSI_Start() and @ref HAL_DSI_Stop().
25 Functions @ref HAL_DSI_ShortWrite(), @ref HAL_DSI_LongWrite() and @ref HAL_DSI_Read() allows respectively
26 to write DSI short packets, long packets and to read DSI packets.
28 (#) The DSI Host Offers two Low power modes :
29 (+) Low Power Mode on data lanes only: Only DSI data lanes are shut down.
30 It is possible to enter/exit from this mode using respectively functions @ref HAL_DSI_EnterULPMData()
31 and @ref HAL_DSI_ExitULPMData()
33 (+) Low Power Mode on data and clock lanes : All DSI lanes are shut down including data and clock lanes.
34 It is possible to enter/exit from this mode using respectively functions @ref HAL_DSI_EnterULPM()
35 and @ref HAL_DSI_ExitULPM()
37 (#) User can select the DSI errors to be reported/monitored using function @ref HAL_DSI_ConfigErrorMonitor()
38 When an error occurs, the callback @ref HAL_DSI_ErrorCallback() is asserted and then user can retrieve
39 the error code by calling function @ref HAL_DSI_GetError()
41 (#) To control DSI state you can use the following function: HAL_DSI_GetState()
43 *** DSI HAL driver macros list ***
44 =============================================
46 Below the list of most used macros in DSI HAL driver.
48 (+) __HAL_DSI_ENABLE: Enable the DSI Host.
49 (+) __HAL_DSI_DISABLE: Disable the DSI Host.
50 (+) __HAL_DSI_WRAPPER_ENABLE: Enables the DSI wrapper.
51 (+) __HAL_DSI_WRAPPER_DISABLE: Disable the DSI wrapper.
52 (+) __HAL_DSI_PLL_ENABLE: Enables the DSI PLL.
53 (+) __HAL_DSI_PLL_DISABLE: Disables the DSI PLL.
54 (+) __HAL_DSI_REG_ENABLE: Enables the DSI regulator.
55 (+) __HAL_DSI_REG_DISABLE: Disables the DSI regulator.
56 (+) __HAL_DSI_GET_FLAG: Get the DSI pending flags.
57 (+) __HAL_DSI_CLEAR_FLAG: Clears the DSI pending flags.
58 (+) __HAL_DSI_ENABLE_IT: Enables the specified DSI interrupts.
59 (+) __HAL_DSI_DISABLE_IT: Disables the specified DSI interrupts.
60 (+) __HAL_DSI_GET_IT_SOURCE: Checks whether the specified DSI interrupt source is enabled or not.
64 *** Callback registration ***
65 =============================================
67 The compilation define USE_HAL_DSI_REGISTER_CALLBACKS when set to 1
68 allows the user to configure dynamically the driver callbacks.
69 Use Function @ref HAL_DSI_RegisterCallback() to register a callback.
71 Function @ref HAL_DSI_RegisterCallback() allows to register following callbacks:
72 (+) TearingEffectCallback : DSI Tearing Effect Callback.
73 (+) EndOfRefreshCallback : DSI End Of Refresh Callback.
74 (+) ErrorCallback : DSI Error Callback
75 (+) MspInitCallback : DSI MspInit.
76 (+) MspDeInitCallback : DSI MspDeInit.
77 This function takes as parameters the HAL peripheral handle, the Callback ID
78 and a pointer to the user callback function.
80 Use function @ref HAL_DSI_UnRegisterCallback() to reset a callback to the default
82 @ref HAL_DSI_UnRegisterCallback takes as parameters the HAL peripheral handle,
84 This function allows to reset following callbacks:
85 (+) TearingEffectCallback : DSI Tearing Effect Callback.
86 (+) EndOfRefreshCallback : DSI End Of Refresh Callback.
87 (+) ErrorCallback : DSI Error Callback
88 (+) MspInitCallback : DSI MspInit.
89 (+) MspDeInitCallback : DSI MspDeInit.
91 By default, after the HAL_DSI_Init and when the state is HAL_DSI_STATE_RESET
92 all callbacks are set to the corresponding weak functions:
93 examples @ref HAL_DSI_TearingEffectCallback(), @ref HAL_DSI_EndOfRefreshCallback().
94 Exception done for MspInit and MspDeInit functions that are
95 reset to the legacy weak function in the HAL_DSI_Init/ @ref HAL_DSI_DeInit only when
96 these callbacks are null (not registered beforehand).
97 if not, MspInit or MspDeInit are not null, the @ref HAL_DSI_Init/ @ref HAL_DSI_DeInit
98 keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
100 Callbacks can be registered/unregistered in HAL_DSI_STATE_READY state only.
101 Exception done MspInit/MspDeInit that can be registered/unregistered
102 in HAL_DSI_STATE_READY or HAL_DSI_STATE_RESET state,
103 thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
104 In that case first register the MspInit/MspDeInit user callbacks
105 using @ref HAL_DSI_RegisterCallback() before calling @ref HAL_DSI_DeInit
106 or HAL_DSI_Init function.
108 When The compilation define USE_HAL_DSI_REGISTER_CALLBACKS is set to 0 or
109 not defined, the callback registration feature is not available and all callbacks
110 are set to the corresponding weak functions.
113 (@) You can refer to the DSI HAL driver header file for more useful macros
116 ******************************************************************************
119 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
120 * All rights reserved.</center></h2>
122 * This software component is licensed by ST under BSD 3-Clause license,
123 * the "License"; You may not use this file except in compliance with the
124 * License. You may obtain a copy of the License at:
125 * opensource.org/licenses/BSD-3-Clause
127 ******************************************************************************
130 /* Includes ------------------------------------------------------------------*/
131 #include "stm32f7xx_hal.h"
133 /** @addtogroup STM32F7xx_HAL_Driver
137 #ifdef HAL_DSI_MODULE_ENABLED
145 /* Private types -------------------------------------------------------------*/
146 /* Private defines -----------------------------------------------------------*/
147 /** @addtogroup DSI_Private_Constants
150 #define DSI_TIMEOUT_VALUE ((uint32_t)1000U) /* 1s */
152 #define DSI_ERROR_ACK_MASK (DSI_ISR0_AE0 | DSI_ISR0_AE1 | DSI_ISR0_AE2 | DSI_ISR0_AE3 | \
153 DSI_ISR0_AE4 | DSI_ISR0_AE5 | DSI_ISR0_AE6 | DSI_ISR0_AE7 | \
154 DSI_ISR0_AE8 | DSI_ISR0_AE9 | DSI_ISR0_AE10 | DSI_ISR0_AE11 | \
155 DSI_ISR0_AE12 | DSI_ISR0_AE13 | DSI_ISR0_AE14 | DSI_ISR0_AE15)
156 #define DSI_ERROR_PHY_MASK (DSI_ISR0_PE0 | DSI_ISR0_PE1 | DSI_ISR0_PE2 | DSI_ISR0_PE3 | DSI_ISR0_PE4)
157 #define DSI_ERROR_TX_MASK DSI_ISR1_TOHSTX
158 #define DSI_ERROR_RX_MASK DSI_ISR1_TOLPRX
159 #define DSI_ERROR_ECC_MASK (DSI_ISR1_ECCSE | DSI_ISR1_ECCME)
160 #define DSI_ERROR_CRC_MASK DSI_ISR1_CRCE
161 #define DSI_ERROR_PSE_MASK DSI_ISR1_PSE
162 #define DSI_ERROR_EOT_MASK DSI_ISR1_EOTPE
163 #define DSI_ERROR_OVF_MASK DSI_ISR1_LPWRE
164 #define DSI_ERROR_GEN_MASK (DSI_ISR1_GCWRE | DSI_ISR1_GPWRE | DSI_ISR1_GPTXE | DSI_ISR1_GPRDE | DSI_ISR1_GPRXE)
169 /* Private variables ---------------------------------------------------------*/
170 /* Private constants ---------------------------------------------------------*/
171 /* Private macros ------------------------------------------------------------*/
172 /* Private function prototypes -----------------------------------------------*/
173 static void DSI_ConfigPacketHeader(DSI_TypeDef
*DSIx
, uint32_t ChannelID
, uint32_t DataType
, uint32_t Data0
,
176 static HAL_StatusTypeDef
DSI_ShortWrite(DSI_HandleTypeDef
*hdsi
,
182 /* Private functions ---------------------------------------------------------*/
184 * @brief Generic DSI packet header configuration
185 * @param DSIx Pointer to DSI register base
186 * @param ChannelID Virtual channel ID of the header packet
187 * @param DataType Packet data type of the header packet
188 * This parameter can be any value of :
189 * @ref DSI_SHORT_WRITE_PKT_Data_Type
190 * or @ref DSI_LONG_WRITE_PKT_Data_Type
191 * or @ref DSI_SHORT_READ_PKT_Data_Type
192 * or DSI_MAX_RETURN_PKT_SIZE
193 * @param Data0 Word count LSB
194 * @param Data1 Word count MSB
197 static void DSI_ConfigPacketHeader(DSI_TypeDef
*DSIx
,
203 /* Update the DSI packet header with new information */
204 DSIx
->GHCR
= (DataType
| (ChannelID
<< 6U) | (Data0
<< 8U) | (Data1
<< 16U));
208 * @brief write short DCS or short Generic command
209 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
210 * the configuration information for the DSI.
211 * @param ChannelID Virtual channel ID.
212 * @param Mode DSI short packet data type.
213 * This parameter can be any value of @ref DSI_SHORT_WRITE_PKT_Data_Type.
214 * @param Param1 DSC command or first generic parameter.
215 * This parameter can be any value of @ref DSI_DCS_Command or a
216 * generic command code.
217 * @param Param2 DSC parameter or second generic parameter.
220 static HAL_StatusTypeDef
DSI_ShortWrite(DSI_HandleTypeDef
*hdsi
,
229 tickstart
= HAL_GetTick();
231 /* Wait for Command FIFO Empty */
232 while((hdsi
->Instance
->GPSR
& DSI_GPSR_CMDFE
) == 0U)
234 /* Check for the Timeout */
235 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
241 /* Configure the packet to send a short DCS command with 0 or 1 parameter */
242 /* Update the DSI packet header with new information */
243 hdsi
->Instance
->GHCR
= (Mode
| (ChannelID
<< 6U) | (Param1
<< 8U) | (Param2
<< 16U));
248 /* Exported functions --------------------------------------------------------*/
249 /** @addtogroup DSI_Exported_Functions
253 /** @defgroup DSI_Group1 Initialization and Configuration functions
254 * @brief Initialization and Configuration functions
257 ===============================================================================
258 ##### Initialization and Configuration functions #####
259 ===============================================================================
260 [..] This section provides functions allowing to:
261 (+) Initialize and configure the DSI
262 (+) De-initialize the DSI
269 * @brief Initializes the DSI according to the specified
270 * parameters in the DSI_InitTypeDef and create the associated handle.
271 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
272 * the configuration information for the DSI.
273 * @param PLLInit pointer to a DSI_PLLInitTypeDef structure that contains
274 * the PLL Clock structure definition for the DSI.
277 HAL_StatusTypeDef
HAL_DSI_Init(DSI_HandleTypeDef
*hdsi
, DSI_PLLInitTypeDef
*PLLInit
)
280 uint32_t unitIntervalx4
;
283 /* Check the DSI handle allocation */
289 /* Check function parameters */
290 assert_param(IS_DSI_PLL_NDIV(PLLInit
->PLLNDIV
));
291 assert_param(IS_DSI_PLL_IDF(PLLInit
->PLLIDF
));
292 assert_param(IS_DSI_PLL_ODF(PLLInit
->PLLODF
));
293 assert_param(IS_DSI_AUTO_CLKLANE_CONTROL(hdsi
->Init
.AutomaticClockLaneControl
));
294 assert_param(IS_DSI_NUMBER_OF_LANES(hdsi
->Init
.NumberOfLanes
));
296 #if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
297 if (hdsi
->State
== HAL_DSI_STATE_RESET
)
299 /* Reset the DSI callback to the legacy weak callbacks */
300 hdsi
->TearingEffectCallback
= HAL_DSI_TearingEffectCallback
; /* Legacy weak TearingEffectCallback */
301 hdsi
->EndOfRefreshCallback
= HAL_DSI_EndOfRefreshCallback
; /* Legacy weak EndOfRefreshCallback */
302 hdsi
->ErrorCallback
= HAL_DSI_ErrorCallback
; /* Legacy weak ErrorCallback */
304 if (hdsi
->MspInitCallback
== NULL
)
306 hdsi
->MspInitCallback
= HAL_DSI_MspInit
;
308 /* Initialize the low level hardware */
309 hdsi
->MspInitCallback(hdsi
);
312 if (hdsi
->State
== HAL_DSI_STATE_RESET
)
314 /* Initialize the low level hardware */
315 HAL_DSI_MspInit(hdsi
);
317 #endif /* USE_HAL_DSI_REGISTER_CALLBACKS */
319 /* Change DSI peripheral state */
320 hdsi
->State
= HAL_DSI_STATE_BUSY
;
322 /**************** Turn on the regulator and enable the DSI PLL ****************/
324 /* Enable the regulator */
325 __HAL_DSI_REG_ENABLE(hdsi
);
328 tickstart
= HAL_GetTick();
330 /* Wait until the regulator is ready */
331 while (__HAL_DSI_GET_FLAG(hdsi
, DSI_FLAG_RRS
) == 0U)
333 /* Check for the Timeout */
334 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
340 /* Set the PLL division factors */
341 hdsi
->Instance
->WRPCR
&= ~(DSI_WRPCR_PLL_NDIV
| DSI_WRPCR_PLL_IDF
| DSI_WRPCR_PLL_ODF
);
342 hdsi
->Instance
->WRPCR
|= (((PLLInit
->PLLNDIV
) << 2U) | ((PLLInit
->PLLIDF
) << 11U) | ((PLLInit
->PLLODF
) << 16U));
344 /* Enable the DSI PLL */
345 __HAL_DSI_PLL_ENABLE(hdsi
);
348 tickstart
= HAL_GetTick();
350 /* Wait for the lock of the PLL */
351 while (__HAL_DSI_GET_FLAG(hdsi
, DSI_FLAG_PLLLS
) == 0U)
353 /* Check for the Timeout */
354 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
360 /*************************** Set the PHY parameters ***************************/
362 /* D-PHY clock and digital enable*/
363 hdsi
->Instance
->PCTLR
|= (DSI_PCTLR_CKE
| DSI_PCTLR_DEN
);
365 /* Clock lane configuration */
366 hdsi
->Instance
->CLCR
&= ~(DSI_CLCR_DPCC
| DSI_CLCR_ACR
);
367 hdsi
->Instance
->CLCR
|= (DSI_CLCR_DPCC
| hdsi
->Init
.AutomaticClockLaneControl
);
369 /* Configure the number of active data lanes */
370 hdsi
->Instance
->PCONFR
&= ~DSI_PCONFR_NL
;
371 hdsi
->Instance
->PCONFR
|= hdsi
->Init
.NumberOfLanes
;
373 /************************ Set the DSI clock parameters ************************/
375 /* Set the TX escape clock division factor */
376 hdsi
->Instance
->CCR
&= ~DSI_CCR_TXECKDIV
;
377 hdsi
->Instance
->CCR
|= hdsi
->Init
.TXEscapeCkdiv
;
379 /* Calculate the bit period in high-speed mode in unit of 0.25 ns (UIX4) */
380 /* The equation is : UIX4 = IntegerPart( (1000/F_PHY_Mhz) * 4 ) */
381 /* Where : F_PHY_Mhz = (NDIV * HSE_Mhz) / (IDF * ODF) */
382 tempIDF
= (PLLInit
->PLLIDF
> 0U) ? PLLInit
->PLLIDF
: 1U;
383 unitIntervalx4
= (4000000U * tempIDF
* ((1UL << (0x3U
& PLLInit
->PLLODF
)))) / ((HSE_VALUE
/ 1000U) * PLLInit
->PLLNDIV
);
385 /* Set the bit period in high-speed mode */
386 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_UIX4
;
387 hdsi
->Instance
->WPCR
[0U] |= unitIntervalx4
;
389 /****************************** Error management *****************************/
391 /* Disable all error interrupts and reset the Error Mask */
392 hdsi
->Instance
->IER
[0U] = 0U;
393 hdsi
->Instance
->IER
[1U] = 0U;
396 /* Initialise the error code */
397 hdsi
->ErrorCode
= HAL_DSI_ERROR_NONE
;
399 /* Initialize the DSI state*/
400 hdsi
->State
= HAL_DSI_STATE_READY
;
406 * @brief De-initializes the DSI peripheral registers to their default reset
408 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
409 * the configuration information for the DSI.
412 HAL_StatusTypeDef
HAL_DSI_DeInit(DSI_HandleTypeDef
*hdsi
)
414 /* Check the DSI handle allocation */
420 /* Change DSI peripheral state */
421 hdsi
->State
= HAL_DSI_STATE_BUSY
;
423 /* Disable the DSI wrapper */
424 __HAL_DSI_WRAPPER_DISABLE(hdsi
);
426 /* Disable the DSI host */
427 __HAL_DSI_DISABLE(hdsi
);
429 /* D-PHY clock and digital disable */
430 hdsi
->Instance
->PCTLR
&= ~(DSI_PCTLR_CKE
| DSI_PCTLR_DEN
);
432 /* Turn off the DSI PLL */
433 __HAL_DSI_PLL_DISABLE(hdsi
);
435 /* Disable the regulator */
436 __HAL_DSI_REG_DISABLE(hdsi
);
438 #if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
439 if (hdsi
->MspDeInitCallback
== NULL
)
441 hdsi
->MspDeInitCallback
= HAL_DSI_MspDeInit
;
443 /* DeInit the low level hardware */
444 hdsi
->MspDeInitCallback(hdsi
);
446 /* DeInit the low level hardware */
447 HAL_DSI_MspDeInit(hdsi
);
448 #endif /* USE_HAL_DSI_REGISTER_CALLBACKS */
450 /* Initialise the error code */
451 hdsi
->ErrorCode
= HAL_DSI_ERROR_NONE
;
453 /* Initialize the DSI state*/
454 hdsi
->State
= HAL_DSI_STATE_RESET
;
463 * @brief Enable the error monitor flags
464 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
465 * the configuration information for the DSI.
466 * @param ActiveErrors indicates which error interrupts will be enabled.
467 * This parameter can be any combination of @ref DSI_Error_Data_Type.
470 HAL_StatusTypeDef
HAL_DSI_ConfigErrorMonitor(DSI_HandleTypeDef
*hdsi
, uint32_t ActiveErrors
)
475 hdsi
->Instance
->IER
[0U] = 0U;
476 hdsi
->Instance
->IER
[1U] = 0U;
478 /* Store active errors to the handle */
479 hdsi
->ErrorMsk
= ActiveErrors
;
481 if ((ActiveErrors
& HAL_DSI_ERROR_ACK
) != 0U)
483 /* Enable the interrupt generation on selected errors */
484 hdsi
->Instance
->IER
[0U] |= DSI_ERROR_ACK_MASK
;
487 if ((ActiveErrors
& HAL_DSI_ERROR_PHY
) != 0U)
489 /* Enable the interrupt generation on selected errors */
490 hdsi
->Instance
->IER
[0U] |= DSI_ERROR_PHY_MASK
;
493 if ((ActiveErrors
& HAL_DSI_ERROR_TX
) != 0U)
495 /* Enable the interrupt generation on selected errors */
496 hdsi
->Instance
->IER
[1U] |= DSI_ERROR_TX_MASK
;
499 if ((ActiveErrors
& HAL_DSI_ERROR_RX
) != 0U)
501 /* Enable the interrupt generation on selected errors */
502 hdsi
->Instance
->IER
[1U] |= DSI_ERROR_RX_MASK
;
505 if ((ActiveErrors
& HAL_DSI_ERROR_ECC
) != 0U)
507 /* Enable the interrupt generation on selected errors */
508 hdsi
->Instance
->IER
[1U] |= DSI_ERROR_ECC_MASK
;
511 if ((ActiveErrors
& HAL_DSI_ERROR_CRC
) != 0U)
513 /* Enable the interrupt generation on selected errors */
514 hdsi
->Instance
->IER
[1U] |= DSI_ERROR_CRC_MASK
;
517 if ((ActiveErrors
& HAL_DSI_ERROR_PSE
) != 0U)
519 /* Enable the interrupt generation on selected errors */
520 hdsi
->Instance
->IER
[1U] |= DSI_ERROR_PSE_MASK
;
523 if ((ActiveErrors
& HAL_DSI_ERROR_EOT
) != 0U)
525 /* Enable the interrupt generation on selected errors */
526 hdsi
->Instance
->IER
[1U] |= DSI_ERROR_EOT_MASK
;
529 if ((ActiveErrors
& HAL_DSI_ERROR_OVF
) != 0U)
531 /* Enable the interrupt generation on selected errors */
532 hdsi
->Instance
->IER
[1U] |= DSI_ERROR_OVF_MASK
;
535 if ((ActiveErrors
& HAL_DSI_ERROR_GEN
) != 0U)
537 /* Enable the interrupt generation on selected errors */
538 hdsi
->Instance
->IER
[1U] |= DSI_ERROR_GEN_MASK
;
541 /* Process Unlocked */
548 * @brief Initializes the DSI MSP.
549 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
550 * the configuration information for the DSI.
553 __weak
void HAL_DSI_MspInit(DSI_HandleTypeDef
*hdsi
)
555 /* Prevent unused argument(s) compilation warning */
557 /* NOTE : This function Should not be modified, when the callback is needed,
558 the HAL_DSI_MspInit could be implemented in the user file
563 * @brief De-initializes the DSI MSP.
564 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
565 * the configuration information for the DSI.
568 __weak
void HAL_DSI_MspDeInit(DSI_HandleTypeDef
*hdsi
)
570 /* Prevent unused argument(s) compilation warning */
572 /* NOTE : This function Should not be modified, when the callback is needed,
573 the HAL_DSI_MspDeInit could be implemented in the user file
577 #if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
579 * @brief Register a User DSI Callback
580 * To be used instead of the weak predefined callback
581 * @param hdsi dsi handle
582 * @param CallbackID ID of the callback to be registered
583 * This parameter can be one of the following values:
584 * @arg @ref HAL_DSI_TEARING_EFFECT_CB_ID Tearing Effect Callback ID
585 * @arg @ref HAL_DSI_ENDOF_REFRESH_CB_ID End Of Refresh Callback ID
586 * @arg @ref HAL_DSI_ERROR_CB_ID Error Callback ID
587 * @arg @ref HAL_DSI_MSPINIT_CB_ID MspInit callback ID
588 * @arg @ref HAL_DSI_MSPDEINIT_CB_ID MspDeInit callback ID
589 * @param pCallback pointer to the Callback function
592 HAL_StatusTypeDef
HAL_DSI_RegisterCallback(DSI_HandleTypeDef
*hdsi
, HAL_DSI_CallbackIDTypeDef CallbackID
,
593 pDSI_CallbackTypeDef pCallback
)
595 HAL_StatusTypeDef status
= HAL_OK
;
597 if (pCallback
== NULL
)
599 /* Update the error code */
600 hdsi
->ErrorCode
|= HAL_DSI_ERROR_INVALID_CALLBACK
;
607 if (hdsi
->State
== HAL_DSI_STATE_READY
)
611 case HAL_DSI_TEARING_EFFECT_CB_ID
:
612 hdsi
->TearingEffectCallback
= pCallback
;
615 case HAL_DSI_ENDOF_REFRESH_CB_ID
:
616 hdsi
->EndOfRefreshCallback
= pCallback
;
619 case HAL_DSI_ERROR_CB_ID
:
620 hdsi
->ErrorCallback
= pCallback
;
623 case HAL_DSI_MSPINIT_CB_ID
:
624 hdsi
->MspInitCallback
= pCallback
;
627 case HAL_DSI_MSPDEINIT_CB_ID
:
628 hdsi
->MspDeInitCallback
= pCallback
;
632 /* Update the error code */
633 hdsi
->ErrorCode
|= HAL_DSI_ERROR_INVALID_CALLBACK
;
634 /* Return error status */
639 else if (hdsi
->State
== HAL_DSI_STATE_RESET
)
643 case HAL_DSI_MSPINIT_CB_ID
:
644 hdsi
->MspInitCallback
= pCallback
;
647 case HAL_DSI_MSPDEINIT_CB_ID
:
648 hdsi
->MspDeInitCallback
= pCallback
;
652 /* Update the error code */
653 hdsi
->ErrorCode
|= HAL_DSI_ERROR_INVALID_CALLBACK
;
654 /* Return error status */
661 /* Update the error code */
662 hdsi
->ErrorCode
|= HAL_DSI_ERROR_INVALID_CALLBACK
;
663 /* Return error status */
674 * @brief Unregister a DSI Callback
675 * DSI callabck is redirected to the weak predefined callback
676 * @param hdsi dsi handle
677 * @param CallbackID ID of the callback to be unregistered
678 * This parameter can be one of the following values:
679 * @arg @ref HAL_DSI_TEARING_EFFECT_CB_ID Tearing Effect Callback ID
680 * @arg @ref HAL_DSI_ENDOF_REFRESH_CB_ID End Of Refresh Callback ID
681 * @arg @ref HAL_DSI_ERROR_CB_ID Error Callback ID
682 * @arg @ref HAL_DSI_MSPINIT_CB_ID MspInit callback ID
683 * @arg @ref HAL_DSI_MSPDEINIT_CB_ID MspDeInit callback ID
686 HAL_StatusTypeDef
HAL_DSI_UnRegisterCallback(DSI_HandleTypeDef
*hdsi
, HAL_DSI_CallbackIDTypeDef CallbackID
)
688 HAL_StatusTypeDef status
= HAL_OK
;
693 if (hdsi
->State
== HAL_DSI_STATE_READY
)
697 case HAL_DSI_TEARING_EFFECT_CB_ID
:
698 hdsi
->TearingEffectCallback
= HAL_DSI_TearingEffectCallback
; /* Legacy weak TearingEffectCallback */
701 case HAL_DSI_ENDOF_REFRESH_CB_ID
:
702 hdsi
->EndOfRefreshCallback
= HAL_DSI_EndOfRefreshCallback
; /* Legacy weak EndOfRefreshCallback */
705 case HAL_DSI_ERROR_CB_ID
:
706 hdsi
->ErrorCallback
= HAL_DSI_ErrorCallback
; /* Legacy weak ErrorCallback */
709 case HAL_DSI_MSPINIT_CB_ID
:
710 hdsi
->MspInitCallback
= HAL_DSI_MspInit
; /* Legcay weak MspInit Callback */
713 case HAL_DSI_MSPDEINIT_CB_ID
:
714 hdsi
->MspDeInitCallback
= HAL_DSI_MspDeInit
; /* Legcay weak MspDeInit Callback */
718 /* Update the error code */
719 hdsi
->ErrorCode
|= HAL_DSI_ERROR_INVALID_CALLBACK
;
720 /* Return error status */
725 else if (hdsi
->State
== HAL_DSI_STATE_RESET
)
729 case HAL_DSI_MSPINIT_CB_ID
:
730 hdsi
->MspInitCallback
= HAL_DSI_MspInit
; /* Legcay weak MspInit Callback */
733 case HAL_DSI_MSPDEINIT_CB_ID
:
734 hdsi
->MspDeInitCallback
= HAL_DSI_MspDeInit
; /* Legcay weak MspDeInit Callback */
738 /* Update the error code */
739 hdsi
->ErrorCode
|= HAL_DSI_ERROR_INVALID_CALLBACK
;
740 /* Return error status */
747 /* Update the error code */
748 hdsi
->ErrorCode
|= HAL_DSI_ERROR_INVALID_CALLBACK
;
749 /* Return error status */
758 #endif /* USE_HAL_DSI_REGISTER_CALLBACKS */
764 /** @defgroup DSI_Group2 IO operation functions
765 * @brief IO operation functions
768 ===============================================================================
769 ##### IO operation functions #####
770 ===============================================================================
771 [..] This section provides function allowing to:
772 (+) Handle DSI interrupt request
778 * @brief Handles DSI interrupt request.
779 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
780 * the configuration information for the DSI.
783 void HAL_DSI_IRQHandler(DSI_HandleTypeDef
*hdsi
)
785 uint32_t ErrorStatus0
, ErrorStatus1
;
787 /* Tearing Effect Interrupt management ***************************************/
788 if (__HAL_DSI_GET_FLAG(hdsi
, DSI_FLAG_TE
) != 0U)
790 if (__HAL_DSI_GET_IT_SOURCE(hdsi
, DSI_IT_TE
) != 0U)
792 /* Clear the Tearing Effect Interrupt Flag */
793 __HAL_DSI_CLEAR_FLAG(hdsi
, DSI_FLAG_TE
);
795 /* Tearing Effect Callback */
796 #if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
797 /*Call registered Tearing Effect callback */
798 hdsi
->TearingEffectCallback(hdsi
);
800 /*Call legacy Tearing Effect callback*/
801 HAL_DSI_TearingEffectCallback(hdsi
);
802 #endif /* USE_HAL_DSI_REGISTER_CALLBACKS */
806 /* End of Refresh Interrupt management ***************************************/
807 if (__HAL_DSI_GET_FLAG(hdsi
, DSI_FLAG_ER
) != 0U)
809 if (__HAL_DSI_GET_IT_SOURCE(hdsi
, DSI_IT_ER
) != 0U)
811 /* Clear the End of Refresh Interrupt Flag */
812 __HAL_DSI_CLEAR_FLAG(hdsi
, DSI_FLAG_ER
);
814 /* End of Refresh Callback */
815 #if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
816 /*Call registered End of refresh callback */
817 hdsi
->EndOfRefreshCallback(hdsi
);
819 /*Call Legacy End of refresh callback */
820 HAL_DSI_EndOfRefreshCallback(hdsi
);
821 #endif /* USE_HAL_DSI_REGISTER_CALLBACKS */
825 /* Error Interrupts management ***********************************************/
826 if (hdsi
->ErrorMsk
!= 0U)
828 ErrorStatus0
= hdsi
->Instance
->ISR
[0U];
829 ErrorStatus0
&= hdsi
->Instance
->IER
[0U];
830 ErrorStatus1
= hdsi
->Instance
->ISR
[1U];
831 ErrorStatus1
&= hdsi
->Instance
->IER
[1U];
833 if ((ErrorStatus0
& DSI_ERROR_ACK_MASK
) != 0U)
835 hdsi
->ErrorCode
|= HAL_DSI_ERROR_ACK
;
838 if ((ErrorStatus0
& DSI_ERROR_PHY_MASK
) != 0U)
840 hdsi
->ErrorCode
|= HAL_DSI_ERROR_PHY
;
843 if ((ErrorStatus1
& DSI_ERROR_TX_MASK
) != 0U)
845 hdsi
->ErrorCode
|= HAL_DSI_ERROR_TX
;
848 if ((ErrorStatus1
& DSI_ERROR_RX_MASK
) != 0U)
850 hdsi
->ErrorCode
|= HAL_DSI_ERROR_RX
;
853 if ((ErrorStatus1
& DSI_ERROR_ECC_MASK
) != 0U)
855 hdsi
->ErrorCode
|= HAL_DSI_ERROR_ECC
;
858 if ((ErrorStatus1
& DSI_ERROR_CRC_MASK
) != 0U)
860 hdsi
->ErrorCode
|= HAL_DSI_ERROR_CRC
;
863 if ((ErrorStatus1
& DSI_ERROR_PSE_MASK
) != 0U)
865 hdsi
->ErrorCode
|= HAL_DSI_ERROR_PSE
;
868 if ((ErrorStatus1
& DSI_ERROR_EOT_MASK
) != 0U)
870 hdsi
->ErrorCode
|= HAL_DSI_ERROR_EOT
;
873 if ((ErrorStatus1
& DSI_ERROR_OVF_MASK
) != 0U)
875 hdsi
->ErrorCode
|= HAL_DSI_ERROR_OVF
;
878 if ((ErrorStatus1
& DSI_ERROR_GEN_MASK
) != 0U)
880 hdsi
->ErrorCode
|= HAL_DSI_ERROR_GEN
;
883 /* Check only selected errors */
884 if (hdsi
->ErrorCode
!= HAL_DSI_ERROR_NONE
)
886 /* DSI error interrupt callback */
887 #if (USE_HAL_DSI_REGISTER_CALLBACKS == 1)
888 /*Call registered Error callback */
889 hdsi
->ErrorCallback(hdsi
);
891 /*Call Legacy Error callback */
892 HAL_DSI_ErrorCallback(hdsi
);
893 #endif /* USE_HAL_DSI_REGISTER_CALLBACKS */
899 * @brief Tearing Effect DSI callback.
900 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
901 * the configuration information for the DSI.
904 __weak
void HAL_DSI_TearingEffectCallback(DSI_HandleTypeDef
*hdsi
)
906 /* Prevent unused argument(s) compilation warning */
908 /* NOTE : This function Should not be modified, when the callback is needed,
909 the HAL_DSI_TearingEffectCallback could be implemented in the user file
914 * @brief End of Refresh DSI callback.
915 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
916 * the configuration information for the DSI.
919 __weak
void HAL_DSI_EndOfRefreshCallback(DSI_HandleTypeDef
*hdsi
)
921 /* Prevent unused argument(s) compilation warning */
923 /* NOTE : This function Should not be modified, when the callback is needed,
924 the HAL_DSI_EndOfRefreshCallback could be implemented in the user file
929 * @brief Operation Error DSI callback.
930 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
931 * the configuration information for the DSI.
934 __weak
void HAL_DSI_ErrorCallback(DSI_HandleTypeDef
*hdsi
)
936 /* Prevent unused argument(s) compilation warning */
938 /* NOTE : This function Should not be modified, when the callback is needed,
939 the HAL_DSI_ErrorCallback could be implemented in the user file
947 /** @defgroup DSI_Group3 Peripheral Control functions
948 * @brief Peripheral Control functions
951 ===============================================================================
952 ##### Peripheral Control functions #####
953 ===============================================================================
954 [..] This section provides functions allowing to:
955 (+) Configure the Generic interface read-back Virtual Channel ID
956 (+) Select video mode and configure the corresponding parameters
957 (+) Configure command transmission mode: High-speed or Low-power
958 (+) Configure the flow control
959 (+) Configure the DSI PHY timer
960 (+) Configure the DSI HOST timeout
961 (+) Configure the DSI HOST timeout
962 (+) Start/Stop the DSI module
963 (+) Refresh the display in command mode
964 (+) Controls the display color mode in Video mode
965 (+) Control the display shutdown in Video mode
966 (+) write short DCS or short Generic command
967 (+) write long DCS or long Generic command
968 (+) Read command (DCS or generic)
969 (+) Enter/Exit the Ultra Low Power Mode on data only (D-PHY PLL running)
970 (+) Enter/Exit the Ultra Low Power Mode on data only and clock (D-PHY PLL turned off)
971 (+) Start/Stop test pattern generation
972 (+) Slew-Rate And Delay Tuning
973 (+) Low-Power Reception Filter Tuning
974 (+) Activate an additional current path on all lanes to meet the SDDTx parameter
975 (+) Custom lane pins configuration
976 (+) Set custom timing for the PHY
977 (+) Force the Clock/Data Lane in TX Stop Mode
978 (+) Force LP Receiver in Low-Power Mode
979 (+) Force Data Lanes in RX Mode after a BTA
980 (+) Enable a pull-down on the lanes to prevent from floating states when unused
981 (+) Switch off the contention detection on data lanes
988 * @brief Configure the Generic interface read-back Virtual Channel ID.
989 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
990 * the configuration information for the DSI.
991 * @param VirtualChannelID Virtual channel ID
994 HAL_StatusTypeDef
HAL_DSI_SetGenericVCID(DSI_HandleTypeDef
*hdsi
, uint32_t VirtualChannelID
)
999 /* Update the GVCID register */
1000 hdsi
->Instance
->GVCIDR
&= ~DSI_GVCIDR_VCID
;
1001 hdsi
->Instance
->GVCIDR
|= VirtualChannelID
;
1003 /* Process unlocked */
1010 * @brief Select video mode and configure the corresponding parameters
1011 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1012 * the configuration information for the DSI.
1013 * @param VidCfg pointer to a DSI_VidCfgTypeDef structure that contains
1014 * the DSI video mode configuration parameters
1015 * @retval HAL status
1017 HAL_StatusTypeDef
HAL_DSI_ConfigVideoMode(DSI_HandleTypeDef
*hdsi
, DSI_VidCfgTypeDef
*VidCfg
)
1019 /* Process locked */
1022 /* Check the parameters */
1023 assert_param(IS_DSI_COLOR_CODING(VidCfg
->ColorCoding
));
1024 assert_param(IS_DSI_VIDEO_MODE_TYPE(VidCfg
->Mode
));
1025 assert_param(IS_DSI_LP_COMMAND(VidCfg
->LPCommandEnable
));
1026 assert_param(IS_DSI_LP_HFP(VidCfg
->LPHorizontalFrontPorchEnable
));
1027 assert_param(IS_DSI_LP_HBP(VidCfg
->LPHorizontalBackPorchEnable
));
1028 assert_param(IS_DSI_LP_VACTIVE(VidCfg
->LPVerticalActiveEnable
));
1029 assert_param(IS_DSI_LP_VFP(VidCfg
->LPVerticalFrontPorchEnable
));
1030 assert_param(IS_DSI_LP_VBP(VidCfg
->LPVerticalBackPorchEnable
));
1031 assert_param(IS_DSI_LP_VSYNC(VidCfg
->LPVerticalSyncActiveEnable
));
1032 assert_param(IS_DSI_FBTAA(VidCfg
->FrameBTAAcknowledgeEnable
));
1033 assert_param(IS_DSI_DE_POLARITY(VidCfg
->DEPolarity
));
1034 assert_param(IS_DSI_VSYNC_POLARITY(VidCfg
->VSPolarity
));
1035 assert_param(IS_DSI_HSYNC_POLARITY(VidCfg
->HSPolarity
));
1036 /* Check the LooselyPacked variant only in 18-bit mode */
1037 if (VidCfg
->ColorCoding
== DSI_RGB666
)
1039 assert_param(IS_DSI_LOOSELY_PACKED(VidCfg
->LooselyPacked
));
1042 /* Select video mode by resetting CMDM and DSIM bits */
1043 hdsi
->Instance
->MCR
&= ~DSI_MCR_CMDM
;
1044 hdsi
->Instance
->WCFGR
&= ~DSI_WCFGR_DSIM
;
1046 /* Configure the video mode transmission type */
1047 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_VMT
;
1048 hdsi
->Instance
->VMCR
|= VidCfg
->Mode
;
1050 /* Configure the video packet size */
1051 hdsi
->Instance
->VPCR
&= ~DSI_VPCR_VPSIZE
;
1052 hdsi
->Instance
->VPCR
|= VidCfg
->PacketSize
;
1054 /* Set the chunks number to be transmitted through the DSI link */
1055 hdsi
->Instance
->VCCR
&= ~DSI_VCCR_NUMC
;
1056 hdsi
->Instance
->VCCR
|= VidCfg
->NumberOfChunks
;
1058 /* Set the size of the null packet */
1059 hdsi
->Instance
->VNPCR
&= ~DSI_VNPCR_NPSIZE
;
1060 hdsi
->Instance
->VNPCR
|= VidCfg
->NullPacketSize
;
1062 /* Select the virtual channel for the LTDC interface traffic */
1063 hdsi
->Instance
->LVCIDR
&= ~DSI_LVCIDR_VCID
;
1064 hdsi
->Instance
->LVCIDR
|= VidCfg
->VirtualChannelID
;
1066 /* Configure the polarity of control signals */
1067 hdsi
->Instance
->LPCR
&= ~(DSI_LPCR_DEP
| DSI_LPCR_VSP
| DSI_LPCR_HSP
);
1068 hdsi
->Instance
->LPCR
|= (VidCfg
->DEPolarity
| VidCfg
->VSPolarity
| VidCfg
->HSPolarity
);
1070 /* Select the color coding for the host */
1071 hdsi
->Instance
->LCOLCR
&= ~DSI_LCOLCR_COLC
;
1072 hdsi
->Instance
->LCOLCR
|= VidCfg
->ColorCoding
;
1074 /* Select the color coding for the wrapper */
1075 hdsi
->Instance
->WCFGR
&= ~DSI_WCFGR_COLMUX
;
1076 hdsi
->Instance
->WCFGR
|= ((VidCfg
->ColorCoding
) << 1U);
1078 /* Enable/disable the loosely packed variant to 18-bit configuration */
1079 if (VidCfg
->ColorCoding
== DSI_RGB666
)
1081 hdsi
->Instance
->LCOLCR
&= ~DSI_LCOLCR_LPE
;
1082 hdsi
->Instance
->LCOLCR
|= VidCfg
->LooselyPacked
;
1085 /* Set the Horizontal Synchronization Active (HSA) in lane byte clock cycles */
1086 hdsi
->Instance
->VHSACR
&= ~DSI_VHSACR_HSA
;
1087 hdsi
->Instance
->VHSACR
|= VidCfg
->HorizontalSyncActive
;
1089 /* Set the Horizontal Back Porch (HBP) in lane byte clock cycles */
1090 hdsi
->Instance
->VHBPCR
&= ~DSI_VHBPCR_HBP
;
1091 hdsi
->Instance
->VHBPCR
|= VidCfg
->HorizontalBackPorch
;
1093 /* Set the total line time (HLINE=HSA+HBP+HACT+HFP) in lane byte clock cycles */
1094 hdsi
->Instance
->VLCR
&= ~DSI_VLCR_HLINE
;
1095 hdsi
->Instance
->VLCR
|= VidCfg
->HorizontalLine
;
1097 /* Set the Vertical Synchronization Active (VSA) */
1098 hdsi
->Instance
->VVSACR
&= ~DSI_VVSACR_VSA
;
1099 hdsi
->Instance
->VVSACR
|= VidCfg
->VerticalSyncActive
;
1101 /* Set the Vertical Back Porch (VBP)*/
1102 hdsi
->Instance
->VVBPCR
&= ~DSI_VVBPCR_VBP
;
1103 hdsi
->Instance
->VVBPCR
|= VidCfg
->VerticalBackPorch
;
1105 /* Set the Vertical Front Porch (VFP)*/
1106 hdsi
->Instance
->VVFPCR
&= ~DSI_VVFPCR_VFP
;
1107 hdsi
->Instance
->VVFPCR
|= VidCfg
->VerticalFrontPorch
;
1109 /* Set the Vertical Active period*/
1110 hdsi
->Instance
->VVACR
&= ~DSI_VVACR_VA
;
1111 hdsi
->Instance
->VVACR
|= VidCfg
->VerticalActive
;
1113 /* Configure the command transmission mode */
1114 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPCE
;
1115 hdsi
->Instance
->VMCR
|= VidCfg
->LPCommandEnable
;
1117 /* Low power largest packet size */
1118 hdsi
->Instance
->LPMCR
&= ~DSI_LPMCR_LPSIZE
;
1119 hdsi
->Instance
->LPMCR
|= ((VidCfg
->LPLargestPacketSize
) << 16U);
1121 /* Low power VACT largest packet size */
1122 hdsi
->Instance
->LPMCR
&= ~DSI_LPMCR_VLPSIZE
;
1123 hdsi
->Instance
->LPMCR
|= VidCfg
->LPVACTLargestPacketSize
;
1125 /* Enable LP transition in HFP period */
1126 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPHFPE
;
1127 hdsi
->Instance
->VMCR
|= VidCfg
->LPHorizontalFrontPorchEnable
;
1129 /* Enable LP transition in HBP period */
1130 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPHBPE
;
1131 hdsi
->Instance
->VMCR
|= VidCfg
->LPHorizontalBackPorchEnable
;
1133 /* Enable LP transition in VACT period */
1134 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPVAE
;
1135 hdsi
->Instance
->VMCR
|= VidCfg
->LPVerticalActiveEnable
;
1137 /* Enable LP transition in VFP period */
1138 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPVFPE
;
1139 hdsi
->Instance
->VMCR
|= VidCfg
->LPVerticalFrontPorchEnable
;
1141 /* Enable LP transition in VBP period */
1142 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPVBPE
;
1143 hdsi
->Instance
->VMCR
|= VidCfg
->LPVerticalBackPorchEnable
;
1145 /* Enable LP transition in vertical sync period */
1146 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPVSAE
;
1147 hdsi
->Instance
->VMCR
|= VidCfg
->LPVerticalSyncActiveEnable
;
1149 /* Enable the request for an acknowledge response at the end of a frame */
1150 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_FBTAAE
;
1151 hdsi
->Instance
->VMCR
|= VidCfg
->FrameBTAAcknowledgeEnable
;
1153 /* Process unlocked */
1160 * @brief Select adapted command mode and configure the corresponding parameters
1161 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1162 * the configuration information for the DSI.
1163 * @param CmdCfg pointer to a DSI_CmdCfgTypeDef structure that contains
1164 * the DSI command mode configuration parameters
1165 * @retval HAL status
1167 HAL_StatusTypeDef
HAL_DSI_ConfigAdaptedCommandMode(DSI_HandleTypeDef
*hdsi
, DSI_CmdCfgTypeDef
*CmdCfg
)
1169 /* Process locked */
1172 /* Check the parameters */
1173 assert_param(IS_DSI_COLOR_CODING(CmdCfg
->ColorCoding
));
1174 assert_param(IS_DSI_TE_SOURCE(CmdCfg
->TearingEffectSource
));
1175 assert_param(IS_DSI_TE_POLARITY(CmdCfg
->TearingEffectPolarity
));
1176 assert_param(IS_DSI_AUTOMATIC_REFRESH(CmdCfg
->AutomaticRefresh
));
1177 assert_param(IS_DSI_VS_POLARITY(CmdCfg
->VSyncPol
));
1178 assert_param(IS_DSI_TE_ACK_REQUEST(CmdCfg
->TEAcknowledgeRequest
));
1179 assert_param(IS_DSI_DE_POLARITY(CmdCfg
->DEPolarity
));
1180 assert_param(IS_DSI_VSYNC_POLARITY(CmdCfg
->VSPolarity
));
1181 assert_param(IS_DSI_HSYNC_POLARITY(CmdCfg
->HSPolarity
));
1183 /* Select command mode by setting CMDM and DSIM bits */
1184 hdsi
->Instance
->MCR
|= DSI_MCR_CMDM
;
1185 hdsi
->Instance
->WCFGR
&= ~DSI_WCFGR_DSIM
;
1186 hdsi
->Instance
->WCFGR
|= DSI_WCFGR_DSIM
;
1188 /* Select the virtual channel for the LTDC interface traffic */
1189 hdsi
->Instance
->LVCIDR
&= ~DSI_LVCIDR_VCID
;
1190 hdsi
->Instance
->LVCIDR
|= CmdCfg
->VirtualChannelID
;
1192 /* Configure the polarity of control signals */
1193 hdsi
->Instance
->LPCR
&= ~(DSI_LPCR_DEP
| DSI_LPCR_VSP
| DSI_LPCR_HSP
);
1194 hdsi
->Instance
->LPCR
|= (CmdCfg
->DEPolarity
| CmdCfg
->VSPolarity
| CmdCfg
->HSPolarity
);
1196 /* Select the color coding for the host */
1197 hdsi
->Instance
->LCOLCR
&= ~DSI_LCOLCR_COLC
;
1198 hdsi
->Instance
->LCOLCR
|= CmdCfg
->ColorCoding
;
1200 /* Select the color coding for the wrapper */
1201 hdsi
->Instance
->WCFGR
&= ~DSI_WCFGR_COLMUX
;
1202 hdsi
->Instance
->WCFGR
|= ((CmdCfg
->ColorCoding
) << 1U);
1204 /* Configure the maximum allowed size for write memory command */
1205 hdsi
->Instance
->LCCR
&= ~DSI_LCCR_CMDSIZE
;
1206 hdsi
->Instance
->LCCR
|= CmdCfg
->CommandSize
;
1208 /* Configure the tearing effect source and polarity and select the refresh mode */
1209 hdsi
->Instance
->WCFGR
&= ~(DSI_WCFGR_TESRC
| DSI_WCFGR_TEPOL
| DSI_WCFGR_AR
| DSI_WCFGR_VSPOL
);
1210 hdsi
->Instance
->WCFGR
|= (CmdCfg
->TearingEffectSource
| CmdCfg
->TearingEffectPolarity
| CmdCfg
->AutomaticRefresh
|
1213 /* Configure the tearing effect acknowledge request */
1214 hdsi
->Instance
->CMCR
&= ~DSI_CMCR_TEARE
;
1215 hdsi
->Instance
->CMCR
|= CmdCfg
->TEAcknowledgeRequest
;
1217 /* Enable the Tearing Effect interrupt */
1218 __HAL_DSI_ENABLE_IT(hdsi
, DSI_IT_TE
);
1220 /* Enable the End of Refresh interrupt */
1221 __HAL_DSI_ENABLE_IT(hdsi
, DSI_IT_ER
);
1223 /* Process unlocked */
1230 * @brief Configure command transmission mode: High-speed or Low-power
1231 * and enable/disable acknowledge request after packet transmission
1232 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1233 * the configuration information for the DSI.
1234 * @param LPCmd pointer to a DSI_LPCmdTypeDef structure that contains
1235 * the DSI command transmission mode configuration parameters
1236 * @retval HAL status
1238 HAL_StatusTypeDef
HAL_DSI_ConfigCommand(DSI_HandleTypeDef
*hdsi
, DSI_LPCmdTypeDef
*LPCmd
)
1240 /* Process locked */
1243 assert_param(IS_DSI_LP_GSW0P(LPCmd
->LPGenShortWriteNoP
));
1244 assert_param(IS_DSI_LP_GSW1P(LPCmd
->LPGenShortWriteOneP
));
1245 assert_param(IS_DSI_LP_GSW2P(LPCmd
->LPGenShortWriteTwoP
));
1246 assert_param(IS_DSI_LP_GSR0P(LPCmd
->LPGenShortReadNoP
));
1247 assert_param(IS_DSI_LP_GSR1P(LPCmd
->LPGenShortReadOneP
));
1248 assert_param(IS_DSI_LP_GSR2P(LPCmd
->LPGenShortReadTwoP
));
1249 assert_param(IS_DSI_LP_GLW(LPCmd
->LPGenLongWrite
));
1250 assert_param(IS_DSI_LP_DSW0P(LPCmd
->LPDcsShortWriteNoP
));
1251 assert_param(IS_DSI_LP_DSW1P(LPCmd
->LPDcsShortWriteOneP
));
1252 assert_param(IS_DSI_LP_DSR0P(LPCmd
->LPDcsShortReadNoP
));
1253 assert_param(IS_DSI_LP_DLW(LPCmd
->LPDcsLongWrite
));
1254 assert_param(IS_DSI_LP_MRDP(LPCmd
->LPMaxReadPacket
));
1255 assert_param(IS_DSI_ACK_REQUEST(LPCmd
->AcknowledgeRequest
));
1257 /* Select High-speed or Low-power for command transmission */
1258 hdsi
->Instance
->CMCR
&= ~(DSI_CMCR_GSW0TX
| \
1270 hdsi
->Instance
->CMCR
|= (LPCmd
->LPGenShortWriteNoP
| \
1271 LPCmd
->LPGenShortWriteOneP
| \
1272 LPCmd
->LPGenShortWriteTwoP
| \
1273 LPCmd
->LPGenShortReadNoP
| \
1274 LPCmd
->LPGenShortReadOneP
| \
1275 LPCmd
->LPGenShortReadTwoP
| \
1276 LPCmd
->LPGenLongWrite
| \
1277 LPCmd
->LPDcsShortWriteNoP
| \
1278 LPCmd
->LPDcsShortWriteOneP
| \
1279 LPCmd
->LPDcsShortReadNoP
| \
1280 LPCmd
->LPDcsLongWrite
| \
1281 LPCmd
->LPMaxReadPacket
);
1283 /* Configure the acknowledge request after each packet transmission */
1284 hdsi
->Instance
->CMCR
&= ~DSI_CMCR_ARE
;
1285 hdsi
->Instance
->CMCR
|= LPCmd
->AcknowledgeRequest
;
1287 /* Process unlocked */
1294 * @brief Configure the flow control parameters
1295 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1296 * the configuration information for the DSI.
1297 * @param FlowControl flow control feature(s) to be enabled.
1298 * This parameter can be any combination of @ref DSI_FlowControl.
1299 * @retval HAL status
1301 HAL_StatusTypeDef
HAL_DSI_ConfigFlowControl(DSI_HandleTypeDef
*hdsi
, uint32_t FlowControl
)
1303 /* Process locked */
1306 /* Check the parameters */
1307 assert_param(IS_DSI_FLOW_CONTROL(FlowControl
));
1309 /* Set the DSI Host Protocol Configuration Register */
1310 hdsi
->Instance
->PCR
&= ~DSI_FLOW_CONTROL_ALL
;
1311 hdsi
->Instance
->PCR
|= FlowControl
;
1313 /* Process unlocked */
1320 * @brief Configure the DSI PHY timer parameters
1321 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1322 * the configuration information for the DSI.
1323 * @param PhyTimers DSI_PHY_TimerTypeDef structure that contains
1324 * the DSI PHY timing parameters
1325 * @retval HAL status
1327 HAL_StatusTypeDef
HAL_DSI_ConfigPhyTimer(DSI_HandleTypeDef
*hdsi
, DSI_PHY_TimerTypeDef
*PhyTimers
)
1330 /* Process locked */
1333 maxTime
= (PhyTimers
->ClockLaneLP2HSTime
> PhyTimers
->ClockLaneHS2LPTime
) ? PhyTimers
->ClockLaneLP2HSTime
:
1334 PhyTimers
->ClockLaneHS2LPTime
;
1336 /* Clock lane timer configuration */
1338 /* In Automatic Clock Lane control mode, the DSI Host can turn off the clock lane between two
1339 High-Speed transmission.
1340 To do so, the DSI Host calculates the time required for the clock lane to change from HighSpeed
1341 to Low-Power and from Low-Power to High-Speed.
1342 This timings are configured by the HS2LP_TIME and LP2HS_TIME in the DSI Host Clock Lane Timer Configuration Register (DSI_CLTCR).
1343 But the DSI Host is not calculating LP2HS_TIME + HS2LP_TIME but 2 x HS2LP_TIME.
1345 Workaround : Configure HS2LP_TIME and LP2HS_TIME with the same value being the max of HS2LP_TIME or LP2HS_TIME.
1347 hdsi
->Instance
->CLTCR
&= ~(DSI_CLTCR_LP2HS_TIME
| DSI_CLTCR_HS2LP_TIME
);
1348 hdsi
->Instance
->CLTCR
|= (maxTime
| ((maxTime
) << 16U));
1350 /* Data lane timer configuration */
1351 hdsi
->Instance
->DLTCR
&= ~(DSI_DLTCR_MRD_TIME
| DSI_DLTCR_LP2HS_TIME
| DSI_DLTCR_HS2LP_TIME
);
1352 hdsi
->Instance
->DLTCR
|= (PhyTimers
->DataLaneMaxReadTime
| ((PhyTimers
->DataLaneLP2HSTime
) << 16U) | ((
1353 PhyTimers
->DataLaneHS2LPTime
) << 24U));
1355 /* Configure the wait period to request HS transmission after a stop state */
1356 hdsi
->Instance
->PCONFR
&= ~DSI_PCONFR_SW_TIME
;
1357 hdsi
->Instance
->PCONFR
|= ((PhyTimers
->StopWaitTime
) << 8U);
1359 /* Process unlocked */
1366 * @brief Configure the DSI HOST timeout parameters
1367 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1368 * the configuration information for the DSI.
1369 * @param HostTimeouts DSI_HOST_TimeoutTypeDef structure that contains
1370 * the DSI host timeout parameters
1371 * @retval HAL status
1373 HAL_StatusTypeDef
HAL_DSI_ConfigHostTimeouts(DSI_HandleTypeDef
*hdsi
, DSI_HOST_TimeoutTypeDef
*HostTimeouts
)
1375 /* Process locked */
1378 /* Set the timeout clock division factor */
1379 hdsi
->Instance
->CCR
&= ~DSI_CCR_TOCKDIV
;
1380 hdsi
->Instance
->CCR
|= ((HostTimeouts
->TimeoutCkdiv
) << 8U);
1382 /* High-speed transmission timeout */
1383 hdsi
->Instance
->TCCR
[0U] &= ~DSI_TCCR0_HSTX_TOCNT
;
1384 hdsi
->Instance
->TCCR
[0U] |= ((HostTimeouts
->HighSpeedTransmissionTimeout
) << 16U);
1386 /* Low-power reception timeout */
1387 hdsi
->Instance
->TCCR
[0U] &= ~DSI_TCCR0_LPRX_TOCNT
;
1388 hdsi
->Instance
->TCCR
[0U] |= HostTimeouts
->LowPowerReceptionTimeout
;
1390 /* High-speed read timeout */
1391 hdsi
->Instance
->TCCR
[1U] &= ~DSI_TCCR1_HSRD_TOCNT
;
1392 hdsi
->Instance
->TCCR
[1U] |= HostTimeouts
->HighSpeedReadTimeout
;
1394 /* Low-power read timeout */
1395 hdsi
->Instance
->TCCR
[2U] &= ~DSI_TCCR2_LPRD_TOCNT
;
1396 hdsi
->Instance
->TCCR
[2U] |= HostTimeouts
->LowPowerReadTimeout
;
1398 /* High-speed write timeout */
1399 hdsi
->Instance
->TCCR
[3U] &= ~DSI_TCCR3_HSWR_TOCNT
;
1400 hdsi
->Instance
->TCCR
[3U] |= HostTimeouts
->HighSpeedWriteTimeout
;
1402 /* High-speed write presp mode */
1403 hdsi
->Instance
->TCCR
[3U] &= ~DSI_TCCR3_PM
;
1404 hdsi
->Instance
->TCCR
[3U] |= HostTimeouts
->HighSpeedWritePrespMode
;
1406 /* Low-speed write timeout */
1407 hdsi
->Instance
->TCCR
[4U] &= ~DSI_TCCR4_LPWR_TOCNT
;
1408 hdsi
->Instance
->TCCR
[4U] |= HostTimeouts
->LowPowerWriteTimeout
;
1411 hdsi
->Instance
->TCCR
[5U] &= ~DSI_TCCR5_BTA_TOCNT
;
1412 hdsi
->Instance
->TCCR
[5U] |= HostTimeouts
->BTATimeout
;
1414 /* Process unlocked */
1421 * @brief Start the DSI module
1422 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1423 * the configuration information for the DSI.
1424 * @retval HAL status
1426 HAL_StatusTypeDef
HAL_DSI_Start(DSI_HandleTypeDef
*hdsi
)
1428 /* Process locked */
1431 /* Enable the DSI host */
1432 __HAL_DSI_ENABLE(hdsi
);
1434 /* Enable the DSI wrapper */
1435 __HAL_DSI_WRAPPER_ENABLE(hdsi
);
1437 /* Process unlocked */
1444 * @brief Stop the DSI module
1445 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1446 * the configuration information for the DSI.
1447 * @retval HAL status
1449 HAL_StatusTypeDef
HAL_DSI_Stop(DSI_HandleTypeDef
*hdsi
)
1451 /* Process locked */
1454 /* Disable the DSI host */
1455 __HAL_DSI_DISABLE(hdsi
);
1457 /* Disable the DSI wrapper */
1458 __HAL_DSI_WRAPPER_DISABLE(hdsi
);
1460 /* Process unlocked */
1467 * @brief Refresh the display in command mode
1468 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1469 * the configuration information for the DSI.
1470 * @retval HAL status
1472 HAL_StatusTypeDef
HAL_DSI_Refresh(DSI_HandleTypeDef
*hdsi
)
1474 /* Process locked */
1477 /* Update the display */
1478 hdsi
->Instance
->WCR
|= DSI_WCR_LTDCEN
;
1480 /* Process unlocked */
1487 * @brief Controls the display color mode in Video mode
1488 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1489 * the configuration information for the DSI.
1490 * @param ColorMode Color mode (full or 8-colors).
1491 * This parameter can be any value of @ref DSI_Color_Mode
1492 * @retval HAL status
1494 HAL_StatusTypeDef
HAL_DSI_ColorMode(DSI_HandleTypeDef
*hdsi
, uint32_t ColorMode
)
1496 /* Process locked */
1499 /* Check the parameters */
1500 assert_param(IS_DSI_COLOR_MODE(ColorMode
));
1502 /* Update the display color mode */
1503 hdsi
->Instance
->WCR
&= ~DSI_WCR_COLM
;
1504 hdsi
->Instance
->WCR
|= ColorMode
;
1506 /* Process unlocked */
1513 * @brief Control the display shutdown in Video mode
1514 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1515 * the configuration information for the DSI.
1516 * @param Shutdown Shut-down (Display-ON or Display-OFF).
1517 * This parameter can be any value of @ref DSI_ShutDown
1518 * @retval HAL status
1520 HAL_StatusTypeDef
HAL_DSI_Shutdown(DSI_HandleTypeDef
*hdsi
, uint32_t Shutdown
)
1522 /* Process locked */
1525 /* Check the parameters */
1526 assert_param(IS_DSI_SHUT_DOWN(Shutdown
));
1528 /* Update the display Shutdown */
1529 hdsi
->Instance
->WCR
&= ~DSI_WCR_SHTDN
;
1530 hdsi
->Instance
->WCR
|= Shutdown
;
1532 /* Process unlocked */
1539 * @brief write short DCS or short Generic command
1540 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1541 * the configuration information for the DSI.
1542 * @param ChannelID Virtual channel ID.
1543 * @param Mode DSI short packet data type.
1544 * This parameter can be any value of @ref DSI_SHORT_WRITE_PKT_Data_Type.
1545 * @param Param1 DSC command or first generic parameter.
1546 * This parameter can be any value of @ref DSI_DCS_Command or a
1547 * generic command code.
1548 * @param Param2 DSC parameter or second generic parameter.
1549 * @retval HAL status
1551 HAL_StatusTypeDef
HAL_DSI_ShortWrite(DSI_HandleTypeDef
*hdsi
,
1557 HAL_StatusTypeDef status
;
1558 /* Check the parameters */
1559 assert_param(IS_DSI_SHORT_WRITE_PACKET_TYPE(Mode
));
1561 /* Process locked */
1564 status
= DSI_ShortWrite(hdsi
, ChannelID
, Mode
, Param1
, Param2
);
1566 /* Process unlocked */
1573 * @brief write long DCS or long Generic command
1574 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1575 * the configuration information for the DSI.
1576 * @param ChannelID Virtual channel ID.
1577 * @param Mode DSI long packet data type.
1578 * This parameter can be any value of @ref DSI_LONG_WRITE_PKT_Data_Type.
1579 * @param NbParams Number of parameters.
1580 * @param Param1 DSC command or first generic parameter.
1581 * This parameter can be any value of @ref DSI_DCS_Command or a
1582 * generic command code
1583 * @param ParametersTable Pointer to parameter values table.
1584 * @retval HAL status
1586 HAL_StatusTypeDef
HAL_DSI_LongWrite(DSI_HandleTypeDef
*hdsi
,
1591 uint8_t *ParametersTable
)
1593 uint32_t uicounter
, nbBytes
, count
;
1596 uint8_t *pparams
= ParametersTable
;
1598 /* Process locked */
1601 /* Check the parameters */
1602 assert_param(IS_DSI_LONG_WRITE_PACKET_TYPE(Mode
));
1605 tickstart
= HAL_GetTick();
1607 /* Wait for Command FIFO Empty */
1608 while ((hdsi
->Instance
->GPSR
& DSI_GPSR_CMDFE
) == 0U)
1610 /* Check for the Timeout */
1611 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1613 /* Process Unlocked */
1620 /* Set the DCS code on payload byte 1, and the other parameters on the write FIFO command*/
1622 nbBytes
= (NbParams
< 3U) ? NbParams
: 3U;
1624 for (count
= 0U; count
< nbBytes
; count
++)
1626 fifoword
|= (((uint32_t)(*(pparams
+ count
))) << (8U + (8U * count
)));
1628 hdsi
->Instance
->GPDR
= fifoword
;
1630 uicounter
= NbParams
- nbBytes
;
1632 /* Set the Next parameters on the write FIFO command*/
1633 while (uicounter
!= 0U)
1635 nbBytes
= (uicounter
< 4U) ? uicounter
: 4U;
1637 for (count
= 0U; count
< nbBytes
; count
++)
1639 fifoword
|= (((uint32_t)(*(pparams
+ count
))) << (8U * count
));
1641 hdsi
->Instance
->GPDR
= fifoword
;
1643 uicounter
-= nbBytes
;
1647 /* Configure the packet to send a long DCS command */
1648 DSI_ConfigPacketHeader(hdsi
->Instance
,
1651 ((NbParams
+ 1U) & 0x00FFU
),
1652 (((NbParams
+ 1U) & 0xFF00U
) >> 8U));
1654 /* Process unlocked */
1661 * @brief Read command (DCS or generic)
1662 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1663 * the configuration information for the DSI.
1664 * @param ChannelNbr Virtual channel ID
1665 * @param Array pointer to a buffer to store the payload of a read back operation.
1666 * @param Size Data size to be read (in byte).
1667 * @param Mode DSI read packet data type.
1668 * This parameter can be any value of @ref DSI_SHORT_READ_PKT_Data_Type.
1669 * @param DCSCmd DCS get/read command.
1670 * @param ParametersTable Pointer to parameter values table.
1671 * @retval HAL status
1673 HAL_StatusTypeDef
HAL_DSI_Read(DSI_HandleTypeDef
*hdsi
,
1674 uint32_t ChannelNbr
,
1679 uint8_t *ParametersTable
)
1682 uint8_t *pdata
= Array
;
1683 uint32_t datasize
= Size
;
1688 /* Process locked */
1691 /* Check the parameters */
1692 assert_param(IS_DSI_READ_PACKET_TYPE(Mode
));
1696 /* set max return packet size */
1697 if (DSI_ShortWrite(hdsi
, ChannelNbr
, DSI_MAX_RETURN_PKT_SIZE
, ((datasize
) & 0xFFU
),
1698 (((datasize
) >> 8U) & 0xFFU
)) != HAL_OK
)
1700 /* Process Unlocked */
1707 /* Configure the packet to read command */
1708 if (Mode
== DSI_DCS_SHORT_PKT_READ
)
1710 DSI_ConfigPacketHeader(hdsi
->Instance
, ChannelNbr
, Mode
, DCSCmd
, 0U);
1712 else if (Mode
== DSI_GEN_SHORT_PKT_READ_P0
)
1714 DSI_ConfigPacketHeader(hdsi
->Instance
, ChannelNbr
, Mode
, 0U, 0U);
1716 else if (Mode
== DSI_GEN_SHORT_PKT_READ_P1
)
1718 DSI_ConfigPacketHeader(hdsi
->Instance
, ChannelNbr
, Mode
, ParametersTable
[0U], 0U);
1720 else if (Mode
== DSI_GEN_SHORT_PKT_READ_P2
)
1722 DSI_ConfigPacketHeader(hdsi
->Instance
, ChannelNbr
, Mode
, ParametersTable
[0U], ParametersTable
[1U]);
1726 /* Process Unlocked */
1733 tickstart
= HAL_GetTick();
1735 /* If DSI fifo is not empty, read requested bytes */
1736 while (((int32_t)(datasize
)) > 0)
1738 if ((hdsi
->Instance
->GPSR
& DSI_GPSR_PRDFE
) == 0U)
1740 fifoword
= hdsi
->Instance
->GPDR
;
1741 nbbytes
= (datasize
< 4U) ? datasize
: 4U;
1743 for (count
= 0U; count
< nbbytes
; count
++)
1745 *pdata
= (uint8_t)(fifoword
>> (8U * count
));
1751 /* Check for the Timeout */
1752 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1754 /* Process Unlocked */
1761 /* Process unlocked */
1768 * @brief Enter the ULPM (Ultra Low Power Mode) with the D-PHY PLL running
1769 * (only data lanes are in ULPM)
1770 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1771 * the configuration information for the DSI.
1772 * @retval HAL status
1774 HAL_StatusTypeDef
HAL_DSI_EnterULPMData(DSI_HandleTypeDef
*hdsi
)
1778 /* Process locked */
1781 /* ULPS Request on Data Lanes */
1782 hdsi
->Instance
->PUCR
|= DSI_PUCR_URDL
;
1785 tickstart
= HAL_GetTick();
1787 /* Wait until the D-PHY active lanes enter into ULPM */
1788 if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_ONE_DATA_LANE
)
1790 while ((hdsi
->Instance
->PSR
& DSI_PSR_UAN0
) != 0U)
1792 /* Check for the Timeout */
1793 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1795 /* Process Unlocked */
1802 else if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_TWO_DATA_LANES
)
1804 while ((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UAN1
)) != 0U)
1806 /* Check for the Timeout */
1807 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1809 /* Process Unlocked */
1818 /* Process unlocked */
1824 /* Process unlocked */
1831 * @brief Exit the ULPM (Ultra Low Power Mode) with the D-PHY PLL running
1832 * (only data lanes are in ULPM)
1833 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1834 * the configuration information for the DSI.
1835 * @retval HAL status
1837 HAL_StatusTypeDef
HAL_DSI_ExitULPMData(DSI_HandleTypeDef
*hdsi
)
1841 /* Process locked */
1844 /* Exit ULPS on Data Lanes */
1845 hdsi
->Instance
->PUCR
|= DSI_PUCR_UEDL
;
1848 tickstart
= HAL_GetTick();
1850 /* Wait until all active lanes exit ULPM */
1851 if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_ONE_DATA_LANE
)
1853 while ((hdsi
->Instance
->PSR
& DSI_PSR_UAN0
) != DSI_PSR_UAN0
)
1855 /* Check for the Timeout */
1856 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1858 /* Process Unlocked */
1865 else if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_TWO_DATA_LANES
)
1867 while ((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UAN1
)) != (DSI_PSR_UAN0
| DSI_PSR_UAN1
))
1869 /* Check for the Timeout */
1870 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1872 /* Process Unlocked */
1881 /* Process unlocked */
1890 /* De-assert the ULPM requests and the ULPM exit bits */
1891 hdsi
->Instance
->PUCR
= 0U;
1893 /* Process unlocked */
1900 * @brief Enter the ULPM (Ultra Low Power Mode) with the D-PHY PLL turned off
1901 * (both data and clock lanes are in ULPM)
1902 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1903 * the configuration information for the DSI.
1904 * @retval HAL status
1906 HAL_StatusTypeDef
HAL_DSI_EnterULPM(DSI_HandleTypeDef
*hdsi
)
1910 /* Process locked */
1913 /* Clock lane configuration: no more HS request */
1914 hdsi
->Instance
->CLCR
&= ~DSI_CLCR_DPCC
;
1916 /* Use system PLL as byte lane clock source before stopping DSIPHY clock source */
1917 __HAL_RCC_DSI_CONFIG(RCC_DSICLKSOURCE_PLLR
);
1919 /* ULPS Request on Clock and Data Lanes */
1920 hdsi
->Instance
->PUCR
|= (DSI_PUCR_URCL
| DSI_PUCR_URDL
);
1923 tickstart
= HAL_GetTick();
1925 /* Wait until all active lanes exit ULPM */
1926 if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_ONE_DATA_LANE
)
1928 while ((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UANC
)) != 0U)
1930 /* Check for the Timeout */
1931 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1933 /* Process Unlocked */
1940 else if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_TWO_DATA_LANES
)
1942 while ((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UAN1
| DSI_PSR_UANC
)) != 0U)
1944 /* Check for the Timeout */
1945 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1947 /* Process Unlocked */
1956 /* Process unlocked */
1962 /* Turn off the DSI PLL */
1963 __HAL_DSI_PLL_DISABLE(hdsi
);
1965 /* Process unlocked */
1972 * @brief Exit the ULPM (Ultra Low Power Mode) with the D-PHY PLL turned off
1973 * (both data and clock lanes are in ULPM)
1974 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
1975 * the configuration information for the DSI.
1976 * @retval HAL status
1978 HAL_StatusTypeDef
HAL_DSI_ExitULPM(DSI_HandleTypeDef
*hdsi
)
1982 /* Process locked */
1985 /* Turn on the DSI PLL */
1986 __HAL_DSI_PLL_ENABLE(hdsi
);
1989 tickstart
= HAL_GetTick();
1991 /* Wait for the lock of the PLL */
1992 while (__HAL_DSI_GET_FLAG(hdsi
, DSI_FLAG_PLLLS
) == 0U)
1994 /* Check for the Timeout */
1995 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1997 /* Process Unlocked */
2004 /* Exit ULPS on Clock and Data Lanes */
2005 hdsi
->Instance
->PUCR
|= (DSI_PUCR_UECL
| DSI_PUCR_UEDL
);
2008 tickstart
= HAL_GetTick();
2010 /* Wait until all active lanes exit ULPM */
2011 if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_ONE_DATA_LANE
)
2013 while ((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UANC
)) != (DSI_PSR_UAN0
| DSI_PSR_UANC
))
2015 /* Check for the Timeout */
2016 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
2018 /* Process Unlocked */
2025 else if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_TWO_DATA_LANES
)
2027 while ((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UAN1
| DSI_PSR_UANC
)) != (DSI_PSR_UAN0
| DSI_PSR_UAN1
|
2030 /* Check for the Timeout */
2031 if ((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
2033 /* Process Unlocked */
2042 /* Process unlocked */
2051 /* De-assert the ULPM requests and the ULPM exit bits */
2052 hdsi
->Instance
->PUCR
= 0U;
2054 /* Switch the lanbyteclock source in the RCC from system PLL to D-PHY */
2055 __HAL_RCC_DSI_CONFIG(RCC_DSICLKSOURCE_DSIPHY
);
2057 /* Restore clock lane configuration to HS */
2058 hdsi
->Instance
->CLCR
|= DSI_CLCR_DPCC
;
2060 /* Process unlocked */
2067 * @brief Start test pattern generation
2068 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2069 * the configuration information for the DSI.
2070 * @param Mode Pattern generator mode
2071 * This parameter can be one of the following values:
2072 * 0 : Color bars (horizontal or vertical)
2073 * 1 : BER pattern (vertical only)
2074 * @param Orientation Pattern generator orientation
2075 * This parameter can be one of the following values:
2076 * 0 : Vertical color bars
2077 * 1 : Horizontal color bars
2078 * @retval HAL status
2080 HAL_StatusTypeDef
HAL_DSI_PatternGeneratorStart(DSI_HandleTypeDef
*hdsi
, uint32_t Mode
, uint32_t Orientation
)
2082 /* Process locked */
2085 /* Configure pattern generator mode and orientation */
2086 hdsi
->Instance
->VMCR
&= ~(DSI_VMCR_PGM
| DSI_VMCR_PGO
);
2087 hdsi
->Instance
->VMCR
|= ((Mode
<< 20U) | (Orientation
<< 24U));
2089 /* Enable pattern generator by setting PGE bit */
2090 hdsi
->Instance
->VMCR
|= DSI_VMCR_PGE
;
2092 /* Process unlocked */
2099 * @brief Stop test pattern generation
2100 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2101 * the configuration information for the DSI.
2102 * @retval HAL status
2104 HAL_StatusTypeDef
HAL_DSI_PatternGeneratorStop(DSI_HandleTypeDef
*hdsi
)
2106 /* Process locked */
2109 /* Disable pattern generator by clearing PGE bit */
2110 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_PGE
;
2112 /* Process unlocked */
2119 * @brief Set Slew-Rate And Delay Tuning
2120 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2121 * the configuration information for the DSI.
2122 * @param CommDelay Communication delay to be adjusted.
2123 * This parameter can be any value of @ref DSI_Communication_Delay
2124 * @param Lane select between clock or data lanes.
2125 * This parameter can be any value of @ref DSI_Lane_Group
2126 * @param Value Custom value of the slew-rate or delay
2127 * @retval HAL status
2129 HAL_StatusTypeDef
HAL_DSI_SetSlewRateAndDelayTuning(DSI_HandleTypeDef
*hdsi
, uint32_t CommDelay
, uint32_t Lane
,
2132 /* Process locked */
2135 /* Check function parameters */
2136 assert_param(IS_DSI_COMMUNICATION_DELAY(CommDelay
));
2137 assert_param(IS_DSI_LANE_GROUP(Lane
));
2141 case DSI_SLEW_RATE_HSTX
:
2142 if (Lane
== DSI_CLOCK_LANE
)
2144 /* High-Speed Transmission Slew Rate Control on Clock Lane */
2145 hdsi
->Instance
->WPCR
[1U] &= ~DSI_WPCR1_HSTXSRCCL
;
2146 hdsi
->Instance
->WPCR
[1U] |= Value
<< 16U;
2148 else if (Lane
== DSI_DATA_LANES
)
2150 /* High-Speed Transmission Slew Rate Control on Data Lanes */
2151 hdsi
->Instance
->WPCR
[1U] &= ~DSI_WPCR1_HSTXSRCDL
;
2152 hdsi
->Instance
->WPCR
[1U] |= Value
<< 18U;
2156 /* Process unlocked */
2162 case DSI_SLEW_RATE_LPTX
:
2163 if (Lane
== DSI_CLOCK_LANE
)
2165 /* Low-Power transmission Slew Rate Compensation on Clock Lane */
2166 hdsi
->Instance
->WPCR
[1U] &= ~DSI_WPCR1_LPSRCCL
;
2167 hdsi
->Instance
->WPCR
[1U] |= Value
<< 6U;
2169 else if (Lane
== DSI_DATA_LANES
)
2171 /* Low-Power transmission Slew Rate Compensation on Data Lanes */
2172 hdsi
->Instance
->WPCR
[1U] &= ~DSI_WPCR1_LPSRCDL
;
2173 hdsi
->Instance
->WPCR
[1U] |= Value
<< 8U;
2177 /* Process unlocked */
2184 if (Lane
== DSI_CLOCK_LANE
)
2186 /* High-Speed Transmission Delay on Clock Lane */
2187 hdsi
->Instance
->WPCR
[1U] &= ~DSI_WPCR1_HSTXDCL
;
2188 hdsi
->Instance
->WPCR
[1U] |= Value
;
2190 else if (Lane
== DSI_DATA_LANES
)
2192 /* High-Speed Transmission Delay on Data Lanes */
2193 hdsi
->Instance
->WPCR
[1U] &= ~DSI_WPCR1_HSTXDDL
;
2194 hdsi
->Instance
->WPCR
[1U] |= Value
<< 2U;
2198 /* Process unlocked */
2208 /* Process unlocked */
2215 * @brief Low-Power Reception Filter Tuning
2216 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2217 * the configuration information for the DSI.
2218 * @param Frequency cutoff frequency of low-pass filter at the input of LPRX
2219 * @retval HAL status
2221 HAL_StatusTypeDef
HAL_DSI_SetLowPowerRXFilter(DSI_HandleTypeDef
*hdsi
, uint32_t Frequency
)
2223 /* Process locked */
2226 /* Low-Power RX low-pass Filtering Tuning */
2227 hdsi
->Instance
->WPCR
[1U] &= ~DSI_WPCR1_LPRXFT
;
2228 hdsi
->Instance
->WPCR
[1U] |= Frequency
<< 25U;
2230 /* Process unlocked */
2237 * @brief Activate an additional current path on all lanes to meet the SDDTx parameter
2238 * defined in the MIPI D-PHY specification
2239 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2240 * the configuration information for the DSI.
2241 * @param State ENABLE or DISABLE
2242 * @retval HAL status
2244 HAL_StatusTypeDef
HAL_DSI_SetSDD(DSI_HandleTypeDef
*hdsi
, FunctionalState State
)
2246 /* Process locked */
2249 /* Check function parameters */
2250 assert_param(IS_FUNCTIONAL_STATE(State
));
2252 /* Activate/Disactivate additional current path on all lanes */
2253 hdsi
->Instance
->WPCR
[1U] &= ~DSI_WPCR1_SDDC
;
2254 hdsi
->Instance
->WPCR
[1U] |= ((uint32_t)State
<< 12U);
2256 /* Process unlocked */
2263 * @brief Custom lane pins configuration
2264 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2265 * the configuration information for the DSI.
2266 * @param CustomLane Function to be applyed on selected lane.
2267 * This parameter can be any value of @ref DSI_CustomLane
2268 * @param Lane select between clock or data lane 0 or data lane 1.
2269 * This parameter can be any value of @ref DSI_Lane_Select
2270 * @param State ENABLE or DISABLE
2271 * @retval HAL status
2273 HAL_StatusTypeDef
HAL_DSI_SetLanePinsConfiguration(DSI_HandleTypeDef
*hdsi
, uint32_t CustomLane
, uint32_t Lane
,
2274 FunctionalState State
)
2276 /* Process locked */
2279 /* Check function parameters */
2280 assert_param(IS_DSI_CUSTOM_LANE(CustomLane
));
2281 assert_param(IS_DSI_LANE(Lane
));
2282 assert_param(IS_FUNCTIONAL_STATE(State
));
2286 case DSI_SWAP_LANE_PINS
:
2287 if (Lane
== DSI_CLK_LANE
)
2289 /* Swap pins on clock lane */
2290 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_SWCL
;
2291 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 6U);
2293 else if (Lane
== DSI_DATA_LANE0
)
2295 /* Swap pins on data lane 0 */
2296 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_SWDL0
;
2297 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 7U);
2299 else if (Lane
== DSI_DATA_LANE1
)
2301 /* Swap pins on data lane 1 */
2302 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_SWDL1
;
2303 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 8U);
2307 /* Process unlocked */
2313 case DSI_INVERT_HS_SIGNAL
:
2314 if (Lane
== DSI_CLK_LANE
)
2316 /* Invert HS signal on clock lane */
2317 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_HSICL
;
2318 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 9U);
2320 else if (Lane
== DSI_DATA_LANE0
)
2322 /* Invert HS signal on data lane 0 */
2323 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_HSIDL0
;
2324 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 10U);
2326 else if (Lane
== DSI_DATA_LANE1
)
2328 /* Invert HS signal on data lane 1 */
2329 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_HSIDL1
;
2330 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 11U);
2334 /* Process unlocked */
2344 /* Process unlocked */
2351 * @brief Set custom timing for the PHY
2352 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2353 * the configuration information for the DSI.
2354 * @param Timing PHY timing to be adjusted.
2355 * This parameter can be any value of @ref DSI_PHY_Timing
2356 * @param State ENABLE or DISABLE
2357 * @param Value Custom value of the timing
2358 * @retval HAL status
2360 HAL_StatusTypeDef
HAL_DSI_SetPHYTimings(DSI_HandleTypeDef
*hdsi
, uint32_t Timing
, FunctionalState State
, uint32_t Value
)
2362 /* Process locked */
2365 /* Check function parameters */
2366 assert_param(IS_DSI_PHY_TIMING(Timing
));
2367 assert_param(IS_FUNCTIONAL_STATE(State
));
2372 /* Enable/Disable custom timing setting */
2373 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_TCLKPOSTEN
;
2374 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 27U);
2376 if (State
!= DISABLE
)
2378 /* Set custom value */
2379 hdsi
->Instance
->WPCR
[4U] &= ~DSI_WPCR4_TCLKPOST
;
2380 hdsi
->Instance
->WPCR
[4U] |= Value
& DSI_WPCR4_TCLKPOST
;
2385 /* Enable/Disable custom timing setting */
2386 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_TLPXCEN
;
2387 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 26U);
2389 if (State
!= DISABLE
)
2391 /* Set custom value */
2392 hdsi
->Instance
->WPCR
[3U] &= ~DSI_WPCR3_TLPXC
;
2393 hdsi
->Instance
->WPCR
[3U] |= (Value
<< 24U) & DSI_WPCR3_TLPXC
;
2398 /* Enable/Disable custom timing setting */
2399 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_THSEXITEN
;
2400 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 25U);
2402 if (State
!= DISABLE
)
2404 /* Set custom value */
2405 hdsi
->Instance
->WPCR
[3U] &= ~DSI_WPCR3_THSEXIT
;
2406 hdsi
->Instance
->WPCR
[3U] |= (Value
<< 16U) & DSI_WPCR3_THSEXIT
;
2411 /* Enable/Disable custom timing setting */
2412 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_TLPXDEN
;
2413 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 24U);
2415 if (State
!= DISABLE
)
2417 /* Set custom value */
2418 hdsi
->Instance
->WPCR
[3U] &= ~DSI_WPCR3_TLPXD
;
2419 hdsi
->Instance
->WPCR
[3U] |= (Value
<< 8U) & DSI_WPCR3_TLPXD
;
2424 /* Enable/Disable custom timing setting */
2425 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_THSZEROEN
;
2426 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 23U);
2428 if (State
!= DISABLE
)
2430 /* Set custom value */
2431 hdsi
->Instance
->WPCR
[3U] &= ~DSI_WPCR3_THSZERO
;
2432 hdsi
->Instance
->WPCR
[3U] |= Value
& DSI_WPCR3_THSZERO
;
2437 /* Enable/Disable custom timing setting */
2438 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_THSTRAILEN
;
2439 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 22U);
2441 if (State
!= DISABLE
)
2443 /* Set custom value */
2444 hdsi
->Instance
->WPCR
[2U] &= ~DSI_WPCR2_THSTRAIL
;
2445 hdsi
->Instance
->WPCR
[2U] |= (Value
<< 24U) & DSI_WPCR2_THSTRAIL
;
2449 case DSI_THS_PREPARE
:
2450 /* Enable/Disable custom timing setting */
2451 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_THSPREPEN
;
2452 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 21U);
2454 if (State
!= DISABLE
)
2456 /* Set custom value */
2457 hdsi
->Instance
->WPCR
[2U] &= ~DSI_WPCR2_THSPREP
;
2458 hdsi
->Instance
->WPCR
[2U] |= (Value
<< 16U) & DSI_WPCR2_THSPREP
;
2463 /* Enable/Disable custom timing setting */
2464 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_TCLKZEROEN
;
2465 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 20U);
2467 if (State
!= DISABLE
)
2469 /* Set custom value */
2470 hdsi
->Instance
->WPCR
[2U] &= ~DSI_WPCR2_TCLKZERO
;
2471 hdsi
->Instance
->WPCR
[2U] |= (Value
<< 8U) & DSI_WPCR2_TCLKZERO
;
2475 case DSI_TCLK_PREPARE
:
2476 /* Enable/Disable custom timing setting */
2477 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_TCLKPREPEN
;
2478 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 19U);
2480 if (State
!= DISABLE
)
2482 /* Set custom value */
2483 hdsi
->Instance
->WPCR
[2U] &= ~DSI_WPCR2_TCLKPREP
;
2484 hdsi
->Instance
->WPCR
[2U] |= Value
& DSI_WPCR2_TCLKPREP
;
2492 /* Process unlocked */
2499 * @brief Force the Clock/Data Lane in TX Stop Mode
2500 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2501 * the configuration information for the DSI.
2502 * @param Lane select between clock or data lanes.
2503 * This parameter can be any value of @ref DSI_Lane_Group
2504 * @param State ENABLE or DISABLE
2505 * @retval HAL status
2507 HAL_StatusTypeDef
HAL_DSI_ForceTXStopMode(DSI_HandleTypeDef
*hdsi
, uint32_t Lane
, FunctionalState State
)
2509 /* Process locked */
2512 /* Check function parameters */
2513 assert_param(IS_DSI_LANE_GROUP(Lane
));
2514 assert_param(IS_FUNCTIONAL_STATE(State
));
2516 if (Lane
== DSI_CLOCK_LANE
)
2518 /* Force/Unforce the Clock Lane in TX Stop Mode */
2519 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_FTXSMCL
;
2520 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 12U);
2522 else if (Lane
== DSI_DATA_LANES
)
2524 /* Force/Unforce the Data Lanes in TX Stop Mode */
2525 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_FTXSMDL
;
2526 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 13U);
2530 /* Process unlocked */
2536 /* Process unlocked */
2543 * @brief Force LP Receiver in Low-Power Mode
2544 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2545 * the configuration information for the DSI.
2546 * @param State ENABLE or DISABLE
2547 * @retval HAL status
2549 HAL_StatusTypeDef
HAL_DSI_ForceRXLowPower(DSI_HandleTypeDef
*hdsi
, FunctionalState State
)
2551 /* Process locked */
2554 /* Check function parameters */
2555 assert_param(IS_FUNCTIONAL_STATE(State
));
2557 /* Force/Unforce LP Receiver in Low-Power Mode */
2558 hdsi
->Instance
->WPCR
[1U] &= ~DSI_WPCR1_FLPRXLPM
;
2559 hdsi
->Instance
->WPCR
[1U] |= ((uint32_t)State
<< 22U);
2561 /* Process unlocked */
2568 * @brief Force Data Lanes in RX Mode after a BTA
2569 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2570 * the configuration information for the DSI.
2571 * @param State ENABLE or DISABLE
2572 * @retval HAL status
2574 HAL_StatusTypeDef
HAL_DSI_ForceDataLanesInRX(DSI_HandleTypeDef
*hdsi
, FunctionalState State
)
2576 /* Process locked */
2579 /* Check function parameters */
2580 assert_param(IS_FUNCTIONAL_STATE(State
));
2582 /* Force Data Lanes in RX Mode */
2583 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_TDDL
;
2584 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 16U);
2586 /* Process unlocked */
2593 * @brief Enable a pull-down on the lanes to prevent from floating states when unused
2594 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2595 * the configuration information for the DSI.
2596 * @param State ENABLE or DISABLE
2597 * @retval HAL status
2599 HAL_StatusTypeDef
HAL_DSI_SetPullDown(DSI_HandleTypeDef
*hdsi
, FunctionalState State
)
2601 /* Process locked */
2604 /* Check function parameters */
2605 assert_param(IS_FUNCTIONAL_STATE(State
));
2607 /* Enable/Disable pull-down on lanes */
2608 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_PDEN
;
2609 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 18U);
2611 /* Process unlocked */
2618 * @brief Switch off the contention detection on data lanes
2619 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2620 * the configuration information for the DSI.
2621 * @param State ENABLE or DISABLE
2622 * @retval HAL status
2624 HAL_StatusTypeDef
HAL_DSI_SetContentionDetectionOff(DSI_HandleTypeDef
*hdsi
, FunctionalState State
)
2626 /* Process locked */
2629 /* Check function parameters */
2630 assert_param(IS_FUNCTIONAL_STATE(State
));
2632 /* Contention Detection on Data Lanes OFF */
2633 hdsi
->Instance
->WPCR
[0U] &= ~DSI_WPCR0_CDOFFDL
;
2634 hdsi
->Instance
->WPCR
[0U] |= ((uint32_t)State
<< 14U);
2636 /* Process unlocked */
2646 /** @defgroup DSI_Group4 Peripheral State and Errors functions
2647 * @brief Peripheral State and Errors functions
2650 ===============================================================================
2651 ##### Peripheral State and Errors functions #####
2652 ===============================================================================
2654 This subsection provides functions allowing to
2655 (+) Check the DSI state.
2663 * @brief Return the DSI state
2664 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2665 * the configuration information for the DSI.
2668 HAL_DSI_StateTypeDef
HAL_DSI_GetState(DSI_HandleTypeDef
*hdsi
)
2674 * @brief Return the DSI error code
2675 * @param hdsi pointer to a DSI_HandleTypeDef structure that contains
2676 * the configuration information for the DSI.
2677 * @retval DSI Error Code
2679 uint32_t HAL_DSI_GetError(DSI_HandleTypeDef
*hdsi
)
2681 /* Get the error code */
2682 return hdsi
->ErrorCode
;
2699 #endif /* HAL_DSI_MODULE_ENABLED */
2705 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/