2 ******************************************************************************
3 * @file stm32f7xx_hal_dsi.c
4 * @author MCD Application Team
7 * @brief DSI HAL module driver.
8 * This file provides firmware functions to manage the following
9 * functionalities of the DSI peripheral:
10 * + Initialization and de-initialization functions
11 * + IO operation functions
12 * + Peripheral Control functions
13 * + Peripheral State and Errors functions
14 ******************************************************************************
17 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
19 * Redistribution and use in source and binary forms, with or without modification,
20 * are permitted provided that the following conditions are met:
21 * 1. Redistributions of source code must retain the above copyright notice,
22 * this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright notice,
24 * this list of conditions and the following disclaimer in the documentation
25 * and/or other materials provided with the distribution.
26 * 3. Neither the name of STMicroelectronics nor the names of its contributors
27 * may be used to endorse or promote products derived from this software
28 * without specific prior written permission.
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 ******************************************************************************
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32f7xx_hal.h"
47 /** @addtogroup STM32F7xx_HAL_Driver
54 #ifdef HAL_DSI_MODULE_ENABLED
56 #if defined (STM32F769xx) || defined (STM32F779xx)
58 /* Private types -------------------------------------------------------------*/
59 /* Private defines -----------------------------------------------------------*/
60 /** @addtogroup DSI_Private_Constants
63 #define DSI_TIMEOUT_VALUE ((uint32_t)1000) /* 1s */
65 #define DSI_ERROR_ACK_MASK (DSI_ISR0_AE0 | DSI_ISR0_AE1 | DSI_ISR0_AE2 | DSI_ISR0_AE3 | \
66 DSI_ISR0_AE4 | DSI_ISR0_AE5 | DSI_ISR0_AE6 | DSI_ISR0_AE7 | \
67 DSI_ISR0_AE8 | DSI_ISR0_AE9 | DSI_ISR0_AE10 | DSI_ISR0_AE11 | \
68 DSI_ISR0_AE12 | DSI_ISR0_AE13 | DSI_ISR0_AE14 | DSI_ISR0_AE15)
69 #define DSI_ERROR_PHY_MASK (DSI_ISR0_PE0 | DSI_ISR0_PE1 | DSI_ISR0_PE2 | DSI_ISR0_PE3 | DSI_ISR0_PE4)
70 #define DSI_ERROR_TX_MASK DSI_ISR1_TOHSTX
71 #define DSI_ERROR_RX_MASK DSI_ISR1_TOLPRX
72 #define DSI_ERROR_ECC_MASK (DSI_ISR1_ECCSE | DSI_ISR1_ECCME)
73 #define DSI_ERROR_CRC_MASK DSI_ISR1_CRCE
74 #define DSI_ERROR_PSE_MASK DSI_ISR1_PSE
75 #define DSI_ERROR_EOT_MASK DSI_ISR1_EOTPE
76 #define DSI_ERROR_OVF_MASK DSI_ISR1_LPWRE
77 #define DSI_ERROR_GEN_MASK (DSI_ISR1_GCWRE | DSI_ISR1_GPWRE | DSI_ISR1_GPTXE | DSI_ISR1_GPRDE | DSI_ISR1_GPRXE)
82 /* Private variables ---------------------------------------------------------*/
83 /* Private constants ---------------------------------------------------------*/
84 /* Private macros ------------------------------------------------------------*/
85 /* Private function prototypes -----------------------------------------------*/
86 static void DSI_ConfigPacketHeader(DSI_TypeDef
*DSIx
, uint32_t ChannelID
, uint32_t DataType
, uint32_t Data0
, uint32_t Data1
);
88 /* Private functions ---------------------------------------------------------*/
90 * @brief Generic DSI packet header configuration
91 * @param DSIx: Pointer to DSI register base
92 * @param ChannelID: Virtual channel ID of the header packet
93 * @param DataType: Packet data type of the header packet
94 * This parameter can be any value of :
95 * @ref DSI_SHORT_WRITE_PKT_Data_Type
96 * or @ref DSI_LONG_WRITE_PKT_Data_Type
97 * or @ref DSI_SHORT_READ_PKT_Data_Type
98 * or DSI_MAX_RETURN_PKT_SIZE
99 * @param Data0: Word count LSB
100 * @param Data1: Word count MSB
103 static void DSI_ConfigPacketHeader(DSI_TypeDef
*DSIx
,
109 /* Update the DSI packet header with new information */
110 DSIx
->GHCR
= (DataType
| (ChannelID
<<6) | (Data0
<<8) | (Data1
<<16));
113 /* Exported functions --------------------------------------------------------*/
114 /** @addtogroup DSI_Exported_Functions
118 /** @defgroup DSI_Group1 Initialization and Configuration functions
119 * @brief Initialization and Configuration functions
122 ===============================================================================
123 ##### Initialization and Configuration functions #####
124 ===============================================================================
125 [..] This section provides functions allowing to:
126 (+) Initialize and configure the DSI
127 (+) De-initialize the DSI
134 * @brief Initializes the DSI according to the specified
135 * parameters in the DSI_InitTypeDef and create the associated handle.
136 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
137 * the configuration information for the DSI.
138 * @param PLLInit: pointer to a DSI_PLLInitTypeDef structure that contains
139 * the PLL Clock structure definition for the DSI.
142 HAL_StatusTypeDef
HAL_DSI_Init(DSI_HandleTypeDef
*hdsi
, DSI_PLLInitTypeDef
*PLLInit
)
144 uint32_t tickstart
= 0;
145 uint32_t unitIntervalx4
= 0;
146 uint32_t tempIDF
= 0;
148 /* Check the DSI handle allocation */
154 /* Check function parameters */
155 assert_param(IS_DSI_PLL_NDIV(PLLInit
->PLLNDIV
));
156 assert_param(IS_DSI_PLL_IDF(PLLInit
->PLLIDF
));
157 assert_param(IS_DSI_PLL_ODF(PLLInit
->PLLODF
));
158 assert_param(IS_DSI_AUTO_CLKLANE_CONTROL(hdsi
->Init
.AutomaticClockLaneControl
));
159 assert_param(IS_DSI_NUMBER_OF_LANES(hdsi
->Init
.NumberOfLanes
));
161 if(hdsi
->State
== HAL_DSI_STATE_RESET
)
163 /* Initialize the low level hardware */
164 HAL_DSI_MspInit(hdsi
);
167 /* Change DSI peripheral state */
168 hdsi
->State
= HAL_DSI_STATE_BUSY
;
170 /**************** Turn on the regulator and enable the DSI PLL ****************/
172 /* Enable the regulator */
173 __HAL_DSI_REG_ENABLE(hdsi
);
176 tickstart
= HAL_GetTick();
178 /* Wait until the regulator is ready */
179 while(__HAL_DSI_GET_FLAG(hdsi
, DSI_FLAG_RRS
) == RESET
)
181 /* Check for the Timeout */
182 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
188 /* Set the PLL division factors */
189 hdsi
->Instance
->WRPCR
&= ~(DSI_WRPCR_PLL_NDIV
| DSI_WRPCR_PLL_IDF
| DSI_WRPCR_PLL_ODF
);
190 hdsi
->Instance
->WRPCR
|= (((PLLInit
->PLLNDIV
)<<2) | ((PLLInit
->PLLIDF
)<<11) | ((PLLInit
->PLLODF
)<<16));
192 /* Enable the DSI PLL */
193 __HAL_DSI_PLL_ENABLE(hdsi
);
196 tickstart
= HAL_GetTick();
198 /* Wait for the lock of the PLL */
199 while(__HAL_DSI_GET_FLAG(hdsi
, DSI_FLAG_PLLLS
) == RESET
)
201 /* Check for the Timeout */
202 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
208 /*************************** Set the PHY parameters ***************************/
210 /* D-PHY clock and digital enable*/
211 hdsi
->Instance
->PCTLR
|= (DSI_PCTLR_CKE
| DSI_PCTLR_DEN
);
213 /* Clock lane configuration */
214 hdsi
->Instance
->CLCR
&= ~(DSI_CLCR_DPCC
| DSI_CLCR_ACR
);
215 hdsi
->Instance
->CLCR
|= (DSI_CLCR_DPCC
| hdsi
->Init
.AutomaticClockLaneControl
);
217 /* Configure the number of active data lanes */
218 hdsi
->Instance
->PCONFR
&= ~DSI_PCONFR_NL
;
219 hdsi
->Instance
->PCONFR
|= hdsi
->Init
.NumberOfLanes
;
221 /************************ Set the DSI clock parameters ************************/
223 /* Set the TX escape clock division factor */
224 hdsi
->Instance
->CCR
&= ~DSI_CCR_TXECKDIV
;
225 hdsi
->Instance
->CCR
= hdsi
->Init
.TXEscapeCkdiv
;
227 /* Calculate the bit period in high-speed mode in unit of 0.25 ns (UIX4) */
228 /* The equation is : UIX4 = IntegerPart( (1000/F_PHY_Mhz) * 4 ) */
229 /* Where : F_PHY_Mhz = (NDIV * HSE_Mhz) / (IDF * ODF) */
230 tempIDF
= (PLLInit
->PLLIDF
> 0) ? PLLInit
->PLLIDF
: 1;
231 unitIntervalx4
= (4000000 * tempIDF
* (1 << PLLInit
->PLLODF
)) / ((HSE_VALUE
/1000) * PLLInit
->PLLNDIV
);
233 /* Set the bit period in high-speed mode */
234 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_UIX4
;
235 hdsi
->Instance
->WPCR
[0] |= unitIntervalx4
;
237 /****************************** Error management *****************************/
239 /* Disable all error interrupts and reset the Error Mask */
240 hdsi
->Instance
->IER
[0] = 0;
241 hdsi
->Instance
->IER
[1] = 0;
244 /* Initialise the error code */
245 hdsi
->ErrorCode
= HAL_DSI_ERROR_NONE
;
247 /* Initialize the DSI state*/
248 hdsi
->State
= HAL_DSI_STATE_READY
;
254 * @brief De-initializes the DSI peripheral registers to their default reset
256 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
257 * the configuration information for the DSI.
260 HAL_StatusTypeDef
HAL_DSI_DeInit(DSI_HandleTypeDef
*hdsi
)
262 /* Check the DSI handle allocation */
268 /* Change DSI peripheral state */
269 hdsi
->State
= HAL_DSI_STATE_BUSY
;
271 /* Disable the DSI wrapper */
272 __HAL_DSI_WRAPPER_DISABLE(hdsi
);
274 /* Disable the DSI host */
275 __HAL_DSI_DISABLE(hdsi
);
277 /* D-PHY clock and digital disable */
278 hdsi
->Instance
->PCTLR
&= ~(DSI_PCTLR_CKE
| DSI_PCTLR_DEN
);
280 /* Turn off the DSI PLL */
281 __HAL_DSI_PLL_DISABLE(hdsi
);
283 /* Disable the regulator */
284 __HAL_DSI_REG_DISABLE(hdsi
);
286 /* DeInit the low level hardware */
287 HAL_DSI_MspDeInit(hdsi
);
289 /* Initialise the error code */
290 hdsi
->ErrorCode
= HAL_DSI_ERROR_NONE
;
292 /* Initialize the DSI state*/
293 hdsi
->State
= HAL_DSI_STATE_RESET
;
302 * @brief Return the DSI error code
303 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
304 * the configuration information for the DSI.
305 * @retval DSI Error Code
307 uint32_t HAL_DSI_GetError(DSI_HandleTypeDef
*hdsi
)
309 /* Get the error code */
310 return hdsi
->ErrorCode
;
314 * @brief Enable the error monitor flags
315 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
316 * the configuration information for the DSI.
317 * @param ActiveErrors: indicates which error interrupts will be enabled.
318 * This parameter can be any combination of @ref DSI_Error_Data_Type.
321 HAL_StatusTypeDef
HAL_DSI_ConfigErrorMonitor(DSI_HandleTypeDef
*hdsi
, uint32_t ActiveErrors
)
326 hdsi
->Instance
->IER
[0] = 0;
327 hdsi
->Instance
->IER
[1] = 0;
329 /* Store active errors to the handle */
330 hdsi
->ErrorMsk
= ActiveErrors
;
332 if((ActiveErrors
& HAL_DSI_ERROR_ACK
) != RESET
)
334 /* Enable the interrupt generation on selected errors */
335 hdsi
->Instance
->IER
[0] |= DSI_ERROR_ACK_MASK
;
338 if((ActiveErrors
& HAL_DSI_ERROR_PHY
) != RESET
)
340 /* Enable the interrupt generation on selected errors */
341 hdsi
->Instance
->IER
[0] |= DSI_ERROR_PHY_MASK
;
344 if((ActiveErrors
& HAL_DSI_ERROR_TX
) != RESET
)
346 /* Enable the interrupt generation on selected errors */
347 hdsi
->Instance
->IER
[1] |= DSI_ERROR_TX_MASK
;
350 if((ActiveErrors
& HAL_DSI_ERROR_RX
) != RESET
)
352 /* Enable the interrupt generation on selected errors */
353 hdsi
->Instance
->IER
[1] |= DSI_ERROR_RX_MASK
;
356 if((ActiveErrors
& HAL_DSI_ERROR_ECC
) != RESET
)
358 /* Enable the interrupt generation on selected errors */
359 hdsi
->Instance
->IER
[1] |= DSI_ERROR_ECC_MASK
;
362 if((ActiveErrors
& HAL_DSI_ERROR_CRC
) != RESET
)
364 /* Enable the interrupt generation on selected errors */
365 hdsi
->Instance
->IER
[1] |= DSI_ERROR_CRC_MASK
;
368 if((ActiveErrors
& HAL_DSI_ERROR_PSE
) != RESET
)
370 /* Enable the interrupt generation on selected errors */
371 hdsi
->Instance
->IER
[1] |= DSI_ERROR_PSE_MASK
;
374 if((ActiveErrors
& HAL_DSI_ERROR_EOT
) != RESET
)
376 /* Enable the interrupt generation on selected errors */
377 hdsi
->Instance
->IER
[1] |= DSI_ERROR_EOT_MASK
;
380 if((ActiveErrors
& HAL_DSI_ERROR_OVF
) != RESET
)
382 /* Enable the interrupt generation on selected errors */
383 hdsi
->Instance
->IER
[1] |= DSI_ERROR_OVF_MASK
;
386 if((ActiveErrors
& HAL_DSI_ERROR_GEN
) != RESET
)
388 /* Enable the interrupt generation on selected errors */
389 hdsi
->Instance
->IER
[1] |= DSI_ERROR_GEN_MASK
;
392 /* Process Unlocked */
399 * @brief Initializes the DSI MSP.
400 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
401 * the configuration information for the DSI.
404 __weak
void HAL_DSI_MspInit(DSI_HandleTypeDef
* hdsi
)
406 /* Prevent unused argument(s) compilation warning */
409 /* NOTE : This function Should not be modified, when the callback is needed,
410 the HAL_DSI_MspInit could be implemented in the user file
415 * @brief De-initializes the DSI MSP.
416 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
417 * the configuration information for the DSI.
420 __weak
void HAL_DSI_MspDeInit(DSI_HandleTypeDef
* hdsi
)
422 /* Prevent unused argument(s) compilation warning */
425 /* NOTE : This function Should not be modified, when the callback is needed,
426 the HAL_DSI_MspDeInit could be implemented in the user file
434 /** @defgroup DSI_Group2 IO operation functions
435 * @brief IO operation functions
438 ===============================================================================
439 ##### IO operation functions #####
440 ===============================================================================
441 [..] This section provides function allowing to:
442 (+) Handle DSI interrupt request
448 * @brief Handles DSI interrupt request.
449 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
450 * the configuration information for the DSI.
453 void HAL_DSI_IRQHandler(DSI_HandleTypeDef
*hdsi
)
455 uint32_t ErrorStatus0
, ErrorStatus1
;
457 /* Tearing Effect Interrupt management ***************************************/
458 if(__HAL_DSI_GET_FLAG(hdsi
, DSI_FLAG_TE
) != RESET
)
460 if(__HAL_DSI_GET_IT_SOURCE(hdsi
, DSI_IT_TE
) != RESET
)
462 /* Clear the Tearing Effect Interrupt Flag */
463 __HAL_DSI_CLEAR_FLAG(hdsi
, DSI_FLAG_TE
);
465 /* Tearing Effect Callback */
466 HAL_DSI_TearingEffectCallback(hdsi
);
470 /* End of Refresh Interrupt management ***************************************/
471 if(__HAL_DSI_GET_FLAG(hdsi
, DSI_FLAG_ER
) != RESET
)
473 if(__HAL_DSI_GET_IT_SOURCE(hdsi
, DSI_IT_ER
) != RESET
)
475 /* Clear the End of Refresh Interrupt Flag */
476 __HAL_DSI_CLEAR_FLAG(hdsi
, DSI_FLAG_ER
);
478 /* End of Refresh Callback */
479 HAL_DSI_EndOfRefreshCallback(hdsi
);
483 /* Error Interrupts management ***********************************************/
484 if(hdsi
->ErrorMsk
!= 0)
486 ErrorStatus0
= hdsi
->Instance
->ISR
[0];
487 ErrorStatus0
&= hdsi
->Instance
->IER
[0];
488 ErrorStatus1
= hdsi
->Instance
->ISR
[1];
489 ErrorStatus1
&= hdsi
->Instance
->IER
[1];
491 if((ErrorStatus0
& DSI_ERROR_ACK_MASK
) != RESET
)
493 hdsi
->ErrorCode
|= HAL_DSI_ERROR_ACK
;
496 if((ErrorStatus0
& DSI_ERROR_PHY_MASK
) != RESET
)
498 hdsi
->ErrorCode
|= HAL_DSI_ERROR_PHY
;
501 if((ErrorStatus1
& DSI_ERROR_TX_MASK
) != RESET
)
503 hdsi
->ErrorCode
|= HAL_DSI_ERROR_TX
;
506 if((ErrorStatus1
& DSI_ERROR_RX_MASK
) != RESET
)
508 hdsi
->ErrorCode
|= HAL_DSI_ERROR_RX
;
511 if((ErrorStatus1
& DSI_ERROR_ECC_MASK
) != RESET
)
513 hdsi
->ErrorCode
|= HAL_DSI_ERROR_ECC
;
516 if((ErrorStatus1
& DSI_ERROR_CRC_MASK
) != RESET
)
518 hdsi
->ErrorCode
|= HAL_DSI_ERROR_CRC
;
521 if((ErrorStatus1
& DSI_ERROR_PSE_MASK
) != RESET
)
523 hdsi
->ErrorCode
|= HAL_DSI_ERROR_PSE
;
526 if((ErrorStatus1
& DSI_ERROR_EOT_MASK
) != RESET
)
528 hdsi
->ErrorCode
|= HAL_DSI_ERROR_EOT
;
531 if((ErrorStatus1
& DSI_ERROR_OVF_MASK
) != RESET
)
533 hdsi
->ErrorCode
|= HAL_DSI_ERROR_OVF
;
536 if((ErrorStatus1
& DSI_ERROR_GEN_MASK
) != RESET
)
538 hdsi
->ErrorCode
|= HAL_DSI_ERROR_GEN
;
541 /* Check only selected errors */
542 if(hdsi
->ErrorCode
!= HAL_DSI_ERROR_NONE
)
544 /* DSI error interrupt user callback */
545 HAL_DSI_ErrorCallback(hdsi
);
551 * @brief Tearing Effect DSI callback.
552 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
553 * the configuration information for the DSI.
556 __weak
void HAL_DSI_TearingEffectCallback(DSI_HandleTypeDef
*hdsi
)
558 /* Prevent unused argument(s) compilation warning */
561 /* NOTE : This function Should not be modified, when the callback is needed,
562 the HAL_DSI_TearingEffectCallback could be implemented in the user file
567 * @brief End of Refresh DSI callback.
568 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
569 * the configuration information for the DSI.
572 __weak
void HAL_DSI_EndOfRefreshCallback(DSI_HandleTypeDef
*hdsi
)
574 /* Prevent unused argument(s) compilation warning */
577 /* NOTE : This function Should not be modified, when the callback is needed,
578 the HAL_DSI_EndOfRefreshCallback could be implemented in the user file
583 * @brief Operation Error DSI callback.
584 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
585 * the configuration information for the DSI.
588 __weak
void HAL_DSI_ErrorCallback(DSI_HandleTypeDef
*hdsi
)
590 /* Prevent unused argument(s) compilation warning */
593 /* NOTE : This function Should not be modified, when the callback is needed,
594 the HAL_DSI_ErrorCallback could be implemented in the user file
602 /** @defgroup DSI_Group3 Peripheral Control functions
603 * @brief Peripheral Control functions
606 ===============================================================================
607 ##### Peripheral Control functions #####
608 ===============================================================================
609 [..] This section provides functions allowing to:
619 * @brief Configure the Generic interface read-back Virtual Channel ID.
620 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
621 * the configuration information for the DSI.
622 * @param VirtualChannelID: Virtual channel ID
625 HAL_StatusTypeDef
HAL_DSI_SetGenericVCID(DSI_HandleTypeDef
*hdsi
, uint32_t VirtualChannelID
)
630 /* Update the GVCID register */
631 hdsi
->Instance
->GVCIDR
&= ~DSI_GVCIDR_VCID
;
632 hdsi
->Instance
->GVCIDR
|= VirtualChannelID
;
634 /* Process unlocked */
641 * @brief Select video mode and configure the corresponding parameters
642 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
643 * the configuration information for the DSI.
644 * @param VidCfg: pointer to a DSI_VidCfgTypeDef structure that contains
645 * the DSI video mode configuration parameters
648 HAL_StatusTypeDef
HAL_DSI_ConfigVideoMode(DSI_HandleTypeDef
*hdsi
, DSI_VidCfgTypeDef
*VidCfg
)
653 /* Check the parameters */
654 assert_param(IS_DSI_COLOR_CODING(VidCfg
->ColorCoding
));
655 assert_param(IS_DSI_VIDEO_MODE_TYPE(VidCfg
->Mode
));
656 assert_param(IS_DSI_LP_COMMAND(VidCfg
->LPCommandEnable
));
657 assert_param(IS_DSI_LP_HFP(VidCfg
->LPHorizontalFrontPorchEnable
));
658 assert_param(IS_DSI_LP_HBP(VidCfg
->LPHorizontalBackPorchEnable
));
659 assert_param(IS_DSI_LP_VACTIVE(VidCfg
->LPVerticalActiveEnable
));
660 assert_param(IS_DSI_LP_VFP(VidCfg
->LPVerticalFrontPorchEnable
));
661 assert_param(IS_DSI_LP_VBP(VidCfg
->LPVerticalBackPorchEnable
));
662 assert_param(IS_DSI_LP_VSYNC(VidCfg
->LPVerticalSyncActiveEnable
));
663 assert_param(IS_DSI_FBTAA(VidCfg
->FrameBTAAcknowledgeEnable
));
664 assert_param(IS_DSI_DE_POLARITY(VidCfg
->DEPolarity
));
665 assert_param(IS_DSI_VSYNC_POLARITY(VidCfg
->VSPolarity
));
666 assert_param(IS_DSI_HSYNC_POLARITY(VidCfg
->HSPolarity
));
667 /* Check the LooselyPacked variant only in 18-bit mode */
668 if(VidCfg
->ColorCoding
== DSI_RGB666
)
670 assert_param(IS_DSI_LOOSELY_PACKED(VidCfg
->LooselyPacked
));
673 /* Select video mode by resetting CMDM and DSIM bits */
674 hdsi
->Instance
->MCR
&= ~DSI_MCR_CMDM
;
675 hdsi
->Instance
->WCFGR
&= ~DSI_WCFGR_DSIM
;
677 /* Configure the video mode transmission type */
678 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_VMT
;
679 hdsi
->Instance
->VMCR
|= VidCfg
->Mode
;
681 /* Configure the video packet size */
682 hdsi
->Instance
->VPCR
&= ~DSI_VPCR_VPSIZE
;
683 hdsi
->Instance
->VPCR
|= VidCfg
->PacketSize
;
685 /* Set the chunks number to be transmitted through the DSI link */
686 hdsi
->Instance
->VCCR
&= ~DSI_VCCR_NUMC
;
687 hdsi
->Instance
->VCCR
|= VidCfg
->NumberOfChunks
;
689 /* Set the size of the null packet */
690 hdsi
->Instance
->VNPCR
&= ~DSI_VNPCR_NPSIZE
;
691 hdsi
->Instance
->VNPCR
|= VidCfg
->NullPacketSize
;
693 /* Select the virtual channel for the LTDC interface traffic */
694 hdsi
->Instance
->LVCIDR
&= ~DSI_LVCIDR_VCID
;
695 hdsi
->Instance
->LVCIDR
|= VidCfg
->VirtualChannelID
;
697 /* Configure the polarity of control signals */
698 hdsi
->Instance
->LPCR
&= ~(DSI_LPCR_DEP
| DSI_LPCR_VSP
| DSI_LPCR_HSP
);
699 hdsi
->Instance
->LPCR
|= (VidCfg
->DEPolarity
| VidCfg
->VSPolarity
| VidCfg
->HSPolarity
);
701 /* Select the color coding for the host */
702 hdsi
->Instance
->LCOLCR
&= ~DSI_LCOLCR_COLC
;
703 hdsi
->Instance
->LCOLCR
|= VidCfg
->ColorCoding
;
705 /* Select the color coding for the wrapper */
706 hdsi
->Instance
->WCFGR
&= ~DSI_WCFGR_COLMUX
;
707 hdsi
->Instance
->WCFGR
|= ((VidCfg
->ColorCoding
)<<1);
709 /* Enable/disable the loosely packed variant to 18-bit configuration */
710 if(VidCfg
->ColorCoding
== DSI_RGB666
)
712 hdsi
->Instance
->LCOLCR
&= ~DSI_LCOLCR_LPE
;
713 hdsi
->Instance
->LCOLCR
|= VidCfg
->LooselyPacked
;
716 /* Set the Horizontal Synchronization Active (HSA) in lane byte clock cycles */
717 hdsi
->Instance
->VHSACR
&= ~DSI_VHSACR_HSA
;
718 hdsi
->Instance
->VHSACR
|= VidCfg
->HorizontalSyncActive
;
720 /* Set the Horizontal Back Porch (HBP) in lane byte clock cycles */
721 hdsi
->Instance
->VHBPCR
&= ~DSI_VHBPCR_HBP
;
722 hdsi
->Instance
->VHBPCR
|= VidCfg
->HorizontalBackPorch
;
724 /* Set the total line time (HLINE=HSA+HBP+HACT+HFP) in lane byte clock cycles */
725 hdsi
->Instance
->VLCR
&= ~DSI_VLCR_HLINE
;
726 hdsi
->Instance
->VLCR
|= VidCfg
->HorizontalLine
;
728 /* Set the Vertical Synchronization Active (VSA) */
729 hdsi
->Instance
->VVSACR
&= ~DSI_VVSACR_VSA
;
730 hdsi
->Instance
->VVSACR
|= VidCfg
->VerticalSyncActive
;
732 /* Set the Vertical Back Porch (VBP)*/
733 hdsi
->Instance
->VVBPCR
&= ~DSI_VVBPCR_VBP
;
734 hdsi
->Instance
->VVBPCR
|= VidCfg
->VerticalBackPorch
;
736 /* Set the Vertical Front Porch (VFP)*/
737 hdsi
->Instance
->VVFPCR
&= ~DSI_VVFPCR_VFP
;
738 hdsi
->Instance
->VVFPCR
|= VidCfg
->VerticalFrontPorch
;
740 /* Set the Vertical Active period*/
741 hdsi
->Instance
->VVACR
&= ~DSI_VVACR_VA
;
742 hdsi
->Instance
->VVACR
|= VidCfg
->VerticalActive
;
744 /* Configure the command transmission mode */
745 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPCE
;
746 hdsi
->Instance
->VMCR
|= VidCfg
->LPCommandEnable
;
748 /* Low power largest packet size */
749 hdsi
->Instance
->LPMCR
&= ~DSI_LPMCR_LPSIZE
;
750 hdsi
->Instance
->LPMCR
|= ((VidCfg
->LPLargestPacketSize
)<<16);
752 /* Low power VACT largest packet size */
753 hdsi
->Instance
->LPMCR
&= ~DSI_LPMCR_VLPSIZE
;
754 hdsi
->Instance
->LPMCR
|= VidCfg
->LPVACTLargestPacketSize
;
756 /* Enable LP transition in HFP period */
757 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPHFPE
;
758 hdsi
->Instance
->VMCR
|= VidCfg
->LPHorizontalFrontPorchEnable
;
760 /* Enable LP transition in HBP period */
761 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPHBPE
;
762 hdsi
->Instance
->VMCR
|= VidCfg
->LPHorizontalBackPorchEnable
;
764 /* Enable LP transition in VACT period */
765 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPVAE
;
766 hdsi
->Instance
->VMCR
|= VidCfg
->LPVerticalActiveEnable
;
768 /* Enable LP transition in VFP period */
769 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPVFPE
;
770 hdsi
->Instance
->VMCR
|= VidCfg
->LPVerticalFrontPorchEnable
;
772 /* Enable LP transition in VBP period */
773 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPVBPE
;
774 hdsi
->Instance
->VMCR
|= VidCfg
->LPVerticalBackPorchEnable
;
776 /* Enable LP transition in vertical sync period */
777 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_LPVSAE
;
778 hdsi
->Instance
->VMCR
|= VidCfg
->LPVerticalSyncActiveEnable
;
780 /* Enable the request for an acknowledge response at the end of a frame */
781 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_FBTAAE
;
782 hdsi
->Instance
->VMCR
|= VidCfg
->FrameBTAAcknowledgeEnable
;
784 /* Process unlocked */
791 * @brief Select adapted command mode and configure the corresponding parameters
792 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
793 * the configuration information for the DSI.
794 * @param CmdCfg: pointer to a DSI_CmdCfgTypeDef structure that contains
795 * the DSI command mode configuration parameters
798 HAL_StatusTypeDef
HAL_DSI_ConfigAdaptedCommandMode(DSI_HandleTypeDef
*hdsi
, DSI_CmdCfgTypeDef
*CmdCfg
)
803 /* Check the parameters */
804 assert_param(IS_DSI_COLOR_CODING(CmdCfg
->ColorCoding
));
805 assert_param(IS_DSI_TE_SOURCE(CmdCfg
->TearingEffectSource
));
806 assert_param(IS_DSI_TE_POLARITY(CmdCfg
->TearingEffectPolarity
));
807 assert_param(IS_DSI_AUTOMATIC_REFRESH(CmdCfg
->AutomaticRefresh
));
808 assert_param(IS_DSI_VS_POLARITY(CmdCfg
->VSyncPol
));
809 assert_param(IS_DSI_TE_ACK_REQUEST(CmdCfg
->TEAcknowledgeRequest
));
810 assert_param(IS_DSI_DE_POLARITY(CmdCfg
->DEPolarity
));
811 assert_param(IS_DSI_VSYNC_POLARITY(CmdCfg
->VSPolarity
));
812 assert_param(IS_DSI_HSYNC_POLARITY(CmdCfg
->HSPolarity
));
814 /* Select command mode by setting CMDM and DSIM bits */
815 hdsi
->Instance
->MCR
|= DSI_MCR_CMDM
;
816 hdsi
->Instance
->WCFGR
&= ~DSI_WCFGR_DSIM
;
817 hdsi
->Instance
->WCFGR
|= DSI_WCFGR_DSIM
;
819 /* Select the virtual channel for the LTDC interface traffic */
820 hdsi
->Instance
->LVCIDR
&= ~DSI_LVCIDR_VCID
;
821 hdsi
->Instance
->LVCIDR
|= CmdCfg
->VirtualChannelID
;
823 /* Configure the polarity of control signals */
824 hdsi
->Instance
->LPCR
&= ~(DSI_LPCR_DEP
| DSI_LPCR_VSP
| DSI_LPCR_HSP
);
825 hdsi
->Instance
->LPCR
|= (CmdCfg
->DEPolarity
| CmdCfg
->VSPolarity
| CmdCfg
->HSPolarity
);
827 /* Select the color coding for the host */
828 hdsi
->Instance
->LCOLCR
&= ~DSI_LCOLCR_COLC
;
829 hdsi
->Instance
->LCOLCR
|= CmdCfg
->ColorCoding
;
831 /* Select the color coding for the wrapper */
832 hdsi
->Instance
->WCFGR
&= ~DSI_WCFGR_COLMUX
;
833 hdsi
->Instance
->WCFGR
|= ((CmdCfg
->ColorCoding
)<<1);
835 /* Configure the maximum allowed size for write memory command */
836 hdsi
->Instance
->LCCR
&= ~DSI_LCCR_CMDSIZE
;
837 hdsi
->Instance
->LCCR
|= CmdCfg
->CommandSize
;
839 /* Configure the tearing effect source and polarity and select the refresh mode */
840 hdsi
->Instance
->WCFGR
&= ~(DSI_WCFGR_TESRC
| DSI_WCFGR_TEPOL
| DSI_WCFGR_AR
| DSI_WCFGR_VSPOL
);
841 hdsi
->Instance
->WCFGR
|= (CmdCfg
->TearingEffectSource
| CmdCfg
->TearingEffectPolarity
| CmdCfg
->AutomaticRefresh
| CmdCfg
->VSyncPol
);
843 /* Configure the tearing effect acknowledge request */
844 hdsi
->Instance
->CMCR
&= ~DSI_CMCR_TEARE
;
845 hdsi
->Instance
->CMCR
|= CmdCfg
->TEAcknowledgeRequest
;
847 /* Enable the Tearing Effect interrupt */
848 __HAL_DSI_ENABLE_IT(hdsi
, DSI_IT_TE
);
850 /* Enable the End of Refresh interrupt */
851 __HAL_DSI_ENABLE_IT(hdsi
, DSI_IT_ER
);
853 /* Process unlocked */
860 * @brief Configure command transmission mode: High-speed or Low-power
861 * and enable/disable acknowledge request after packet transmission
862 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
863 * the configuration information for the DSI.
864 * @param LPCmd: pointer to a DSI_LPCmdTypeDef structure that contains
865 * the DSI command transmission mode configuration parameters
868 HAL_StatusTypeDef
HAL_DSI_ConfigCommand(DSI_HandleTypeDef
*hdsi
, DSI_LPCmdTypeDef
*LPCmd
)
873 assert_param(IS_DSI_LP_GSW0P(LPCmd
->LPGenShortWriteNoP
));
874 assert_param(IS_DSI_LP_GSW1P(LPCmd
->LPGenShortWriteOneP
));
875 assert_param(IS_DSI_LP_GSW2P(LPCmd
->LPGenShortWriteTwoP
));
876 assert_param(IS_DSI_LP_GSR0P(LPCmd
->LPGenShortReadNoP
));
877 assert_param(IS_DSI_LP_GSR1P(LPCmd
->LPGenShortReadOneP
));
878 assert_param(IS_DSI_LP_GSR2P(LPCmd
->LPGenShortReadTwoP
));
879 assert_param(IS_DSI_LP_GLW(LPCmd
->LPGenLongWrite
));
880 assert_param(IS_DSI_LP_DSW0P(LPCmd
->LPDcsShortWriteNoP
));
881 assert_param(IS_DSI_LP_DSW1P(LPCmd
->LPDcsShortWriteOneP
));
882 assert_param(IS_DSI_LP_DSR0P(LPCmd
->LPDcsShortReadNoP
));
883 assert_param(IS_DSI_LP_DLW(LPCmd
->LPDcsLongWrite
));
884 assert_param(IS_DSI_LP_MRDP(LPCmd
->LPMaxReadPacket
));
885 assert_param(IS_DSI_ACK_REQUEST(LPCmd
->AcknowledgeRequest
));
887 /* Select High-speed or Low-power for command transmission */
888 hdsi
->Instance
->CMCR
&= ~(DSI_CMCR_GSW0TX
|\
900 hdsi
->Instance
->CMCR
|= (LPCmd
->LPGenShortWriteNoP
|\
901 LPCmd
->LPGenShortWriteOneP
|\
902 LPCmd
->LPGenShortWriteTwoP
|\
903 LPCmd
->LPGenShortReadNoP
|\
904 LPCmd
->LPGenShortReadOneP
|\
905 LPCmd
->LPGenShortReadTwoP
|\
906 LPCmd
->LPGenLongWrite
|\
907 LPCmd
->LPDcsShortWriteNoP
|\
908 LPCmd
->LPDcsShortWriteOneP
|\
909 LPCmd
->LPDcsShortReadNoP
|\
910 LPCmd
->LPDcsLongWrite
|\
911 LPCmd
->LPMaxReadPacket
);
913 /* Configure the acknowledge request after each packet transmission */
914 hdsi
->Instance
->CMCR
&= ~DSI_CMCR_ARE
;
915 hdsi
->Instance
->CMCR
|= LPCmd
->AcknowledgeRequest
;
917 /* Process unlocked */
924 * @brief Configure the flow control parameters
925 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
926 * the configuration information for the DSI.
927 * @param FlowControl: flow control feature(s) to be enabled.
928 * This parameter can be any combination of @ref DSI_FlowControl.
931 HAL_StatusTypeDef
HAL_DSI_ConfigFlowControl(DSI_HandleTypeDef
*hdsi
, uint32_t FlowControl
)
936 /* Check the parameters */
937 assert_param(IS_DSI_FLOW_CONTROL(FlowControl
));
939 /* Set the DSI Host Protocol Configuration Register */
940 hdsi
->Instance
->PCR
&= ~DSI_FLOW_CONTROL_ALL
;
941 hdsi
->Instance
->PCR
|= FlowControl
;
943 /* Process unlocked */
950 * @brief Configure the DSI PHY timer parameters
951 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
952 * the configuration information for the DSI.
953 * @param PhyTimers: DSI_PHY_TimerTypeDef structure that contains
954 * the DSI PHY timing parameters
957 HAL_StatusTypeDef
HAL_DSI_ConfigPhyTimer(DSI_HandleTypeDef
*hdsi
, DSI_PHY_TimerTypeDef
*PhyTimers
)
963 maxTime
= (PhyTimers
->ClockLaneLP2HSTime
> PhyTimers
->ClockLaneHS2LPTime
)? PhyTimers
->ClockLaneLP2HSTime
: PhyTimers
->ClockLaneHS2LPTime
;
965 /* Clock lane timer configuration */
967 /* In Automatic Clock Lane control mode, the DSI Host can turn off the clock lane between two
968 High-Speed transmission.
969 To do so, the DSI Host calculates the time required for the clock lane to change from HighSpeed
970 to Low-Power and from Low-Power to High-Speed.
971 This timings are configured by the HS2LP_TIME and LP2HS_TIME in the DSI Host Clock Lane Timer Configuration Register (DSI_CLTCR).
972 But the DSI Host is not calculating LP2HS_TIME + HS2LP_TIME but 2 x HS2LP_TIME.
974 Workaround : Configure HS2LP_TIME and LP2HS_TIME with the same value being the max of HS2LP_TIME or LP2HS_TIME.
976 hdsi
->Instance
->CLTCR
&= ~(DSI_CLTCR_LP2HS_TIME
| DSI_CLTCR_HS2LP_TIME
);
977 hdsi
->Instance
->CLTCR
|= (maxTime
| ((maxTime
)<<16));
979 /* Data lane timer configuration */
980 hdsi
->Instance
->DLTCR
&= ~(DSI_DLTCR_MRD_TIME
| DSI_DLTCR_LP2HS_TIME
| DSI_DLTCR_HS2LP_TIME
);
981 hdsi
->Instance
->DLTCR
|= (PhyTimers
->DataLaneMaxReadTime
| ((PhyTimers
->DataLaneLP2HSTime
)<<16) | ((PhyTimers
->DataLaneHS2LPTime
)<<24));
983 /* Configure the wait period to request HS transmission after a stop state */
984 hdsi
->Instance
->PCONFR
&= ~DSI_PCONFR_SW_TIME
;
985 hdsi
->Instance
->PCONFR
|= ((PhyTimers
->StopWaitTime
)<<8);
987 /* Process unlocked */
994 * @brief Configure the DSI HOST timeout parameters
995 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
996 * the configuration information for the DSI.
997 * @param HostTimeouts: DSI_HOST_TimeoutTypeDef structure that contains
998 * the DSI host timeout parameters
1001 HAL_StatusTypeDef
HAL_DSI_ConfigHostTimeouts(DSI_HandleTypeDef
*hdsi
, DSI_HOST_TimeoutTypeDef
*HostTimeouts
)
1003 /* Process locked */
1006 /* Set the timeout clock division factor */
1007 hdsi
->Instance
->CCR
&= ~DSI_CCR_TOCKDIV
;
1008 hdsi
->Instance
->CCR
= ((HostTimeouts
->TimeoutCkdiv
)<<8);
1010 /* High-speed transmission timeout */
1011 hdsi
->Instance
->TCCR
[0] &= ~DSI_TCCR0_HSTX_TOCNT
;
1012 hdsi
->Instance
->TCCR
[0] |= ((HostTimeouts
->HighSpeedTransmissionTimeout
)<<16);
1014 /* Low-power reception timeout */
1015 hdsi
->Instance
->TCCR
[0] &= ~DSI_TCCR0_LPRX_TOCNT
;
1016 hdsi
->Instance
->TCCR
[0] |= HostTimeouts
->LowPowerReceptionTimeout
;
1018 /* High-speed read timeout */
1019 hdsi
->Instance
->TCCR
[1] &= ~DSI_TCCR1_HSRD_TOCNT
;
1020 hdsi
->Instance
->TCCR
[1] |= HostTimeouts
->HighSpeedReadTimeout
;
1022 /* Low-power read timeout */
1023 hdsi
->Instance
->TCCR
[2] &= ~DSI_TCCR2_LPRD_TOCNT
;
1024 hdsi
->Instance
->TCCR
[2] |= HostTimeouts
->LowPowerReadTimeout
;
1026 /* High-speed write timeout */
1027 hdsi
->Instance
->TCCR
[3] &= ~DSI_TCCR3_HSWR_TOCNT
;
1028 hdsi
->Instance
->TCCR
[3] |= HostTimeouts
->HighSpeedWriteTimeout
;
1030 /* High-speed write presp mode */
1031 hdsi
->Instance
->TCCR
[3] &= ~DSI_TCCR3_PM
;
1032 hdsi
->Instance
->TCCR
[3] |= HostTimeouts
->HighSpeedWritePrespMode
;
1034 /* Low-speed write timeout */
1035 hdsi
->Instance
->TCCR
[4] &= ~DSI_TCCR4_LPWR_TOCNT
;
1036 hdsi
->Instance
->TCCR
[4] |= HostTimeouts
->LowPowerWriteTimeout
;
1039 hdsi
->Instance
->TCCR
[5] &= ~DSI_TCCR5_BTA_TOCNT
;
1040 hdsi
->Instance
->TCCR
[5] |= HostTimeouts
->BTATimeout
;
1042 /* Process unlocked */
1049 * @brief Start the DSI module
1050 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1051 * the configuration information for the DSI.
1052 * @retval HAL status
1054 HAL_StatusTypeDef
HAL_DSI_Start(DSI_HandleTypeDef
*hdsi
)
1056 /* Process locked */
1059 /* Enable the DSI host */
1060 __HAL_DSI_ENABLE(hdsi
);
1062 /* Enable the DSI wrapper */
1063 __HAL_DSI_WRAPPER_ENABLE(hdsi
);
1065 /* Process unlocked */
1072 * @brief Stop the DSI module
1073 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1074 * the configuration information for the DSI.
1075 * @retval HAL status
1077 HAL_StatusTypeDef
HAL_DSI_Stop(DSI_HandleTypeDef
*hdsi
)
1079 /* Process locked */
1082 /* Disable the DSI host */
1083 __HAL_DSI_DISABLE(hdsi
);
1085 /* Disable the DSI wrapper */
1086 __HAL_DSI_WRAPPER_DISABLE(hdsi
);
1088 /* Process unlocked */
1095 * @brief Refresh the display in command mode
1096 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1097 * the configuration information for the DSI.
1098 * @retval HAL status
1100 HAL_StatusTypeDef
HAL_DSI_Refresh(DSI_HandleTypeDef
*hdsi
)
1102 /* Process locked */
1105 /* Update the display */
1106 hdsi
->Instance
->WCR
|= DSI_WCR_LTDCEN
;
1108 /* Process unlocked */
1115 * @brief Controls the display color mode in Video mode
1116 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1117 * the configuration information for the DSI.
1118 * @param ColorMode: Color mode (full or 8-colors).
1119 * This parameter can be any value of @ref DSI_Color_Mode
1120 * @retval HAL status
1122 HAL_StatusTypeDef
HAL_DSI_ColorMode(DSI_HandleTypeDef
*hdsi
, uint32_t ColorMode
)
1124 /* Process locked */
1127 /* Check the parameters */
1128 assert_param(IS_DSI_COLOR_MODE(ColorMode
));
1130 /* Update the display color mode */
1131 hdsi
->Instance
->WCR
&= ~DSI_WCR_COLM
;
1132 hdsi
->Instance
->WCR
|= ColorMode
;
1134 /* Process unlocked */
1141 * @brief Control the display shutdown in Video mode
1142 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1143 * the configuration information for the DSI.
1144 * @param Shutdown: Shut-down (Display-ON or Display-OFF).
1145 * This parameter can be any value of @ref DSI_ShutDown
1146 * @retval HAL status
1148 HAL_StatusTypeDef
HAL_DSI_Shutdown(DSI_HandleTypeDef
*hdsi
, uint32_t Shutdown
)
1150 /* Process locked */
1153 /* Check the parameters */
1154 assert_param(IS_DSI_SHUT_DOWN(Shutdown
));
1156 /* Update the display Shutdown */
1157 hdsi
->Instance
->WCR
&= ~DSI_WCR_SHTDN
;
1158 hdsi
->Instance
->WCR
|= Shutdown
;
1160 /* Process unlocked */
1167 * @brief DCS or Generic short write command
1168 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1169 * the configuration information for the DSI.
1170 * @param ChannelID: Virtual channel ID.
1171 * @param Mode: DSI short packet data type.
1172 * This parameter can be any value of @ref DSI_SHORT_WRITE_PKT_Data_Type.
1173 * @param Param1: DSC command or first generic parameter.
1174 * This parameter can be any value of @ref DSI_DCS_Command or a
1175 * generic command code.
1176 * @param Param2: DSC parameter or second generic parameter.
1177 * @retval HAL status
1179 HAL_StatusTypeDef
HAL_DSI_ShortWrite(DSI_HandleTypeDef
*hdsi
,
1185 uint32_t tickstart
= 0;
1187 /* Process locked */
1190 /* Check the parameters */
1191 assert_param(IS_DSI_SHORT_WRITE_PACKET_TYPE(Mode
));
1194 tickstart
= HAL_GetTick();
1196 /* Wait for Command FIFO Empty */
1197 while((hdsi
->Instance
->GPSR
& DSI_GPSR_CMDFE
) == 0)
1199 /* Check for the Timeout */
1200 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1202 /* Process Unlocked */
1209 /* Configure the packet to send a short DCS command with 0 or 1 parameter */
1210 DSI_ConfigPacketHeader(hdsi
->Instance
,
1216 /* Process unlocked */
1223 * @brief DCS or Generic long write command
1224 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1225 * the configuration information for the DSI.
1226 * @param ChannelID: Virtual channel ID.
1227 * @param Mode: DSI long packet data type.
1228 * This parameter can be any value of @ref DSI_LONG_WRITE_PKT_Data_Type.
1229 * @param NbParams: Number of parameters.
1230 * @param Param1: DSC command or first generic parameter.
1231 * This parameter can be any value of @ref DSI_DCS_Command or a
1232 * generic command code
1233 * @param ParametersTable: Pointer to parameter values table.
1234 * @retval HAL status
1236 HAL_StatusTypeDef
HAL_DSI_LongWrite(DSI_HandleTypeDef
*hdsi
,
1241 uint8_t* ParametersTable
)
1243 uint32_t uicounter
= 0;
1244 uint32_t tickstart
= 0;
1246 /* Process locked */
1249 /* Check the parameters */
1250 assert_param(IS_DSI_LONG_WRITE_PACKET_TYPE(Mode
));
1253 tickstart
= HAL_GetTick();
1255 /* Wait for Command FIFO Empty */
1256 while((hdsi
->Instance
->GPSR
& DSI_GPSR_CMDFE
) == RESET
)
1258 /* Check for the Timeout */
1259 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1261 /* Process Unlocked */
1268 /* Set the DCS code hexadecimal on payload byte 1, and the other parameters on the write FIFO command*/
1269 while(uicounter
< NbParams
)
1271 if(uicounter
== 0x00)
1273 hdsi
->Instance
->GPDR
=(Param1
| \
1274 ((uint32_t)(*(ParametersTable
+ uicounter
)) << 8) | \
1275 ((uint32_t)(*(ParametersTable
+ uicounter
+1))<<16) | \
1276 ((uint32_t)(*(ParametersTable
+ uicounter
+2))<<24));
1281 hdsi
->Instance
->GPDR
=((uint32_t)(*(ParametersTable
+ uicounter
)) | \
1282 ((uint32_t)(*(ParametersTable
+ uicounter
+1)) << 8) | \
1283 ((uint32_t)(*(ParametersTable
+ uicounter
+2)) << 16) | \
1284 ((uint32_t)(*(ParametersTable
+ uicounter
+3)) << 24));
1289 /* Configure the packet to send a long DCS command */
1290 DSI_ConfigPacketHeader(hdsi
->Instance
,
1293 ((NbParams
+1)&0x00FF),
1294 (((NbParams
+1)&0xFF00)>>8));
1296 /* Process unlocked */
1303 * @brief Read command (DCS or generic)
1304 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1305 * the configuration information for the DSI.
1306 * @param ChannelNbr: Virtual channel ID
1307 * @param Array: pointer to a buffer to store the payload of a read back operation.
1308 * @param Size: Data size to be read (in byte).
1309 * @param Mode: DSI read packet data type.
1310 * This parameter can be any value of @ref DSI_SHORT_READ_PKT_Data_Type.
1311 * @param DCSCmd: DCS get/read command.
1312 * @param ParametersTable: Pointer to parameter values table.
1313 * @retval HAL status
1315 HAL_StatusTypeDef
HAL_DSI_Read(DSI_HandleTypeDef
*hdsi
,
1316 uint32_t ChannelNbr
,
1321 uint8_t* ParametersTable
)
1323 uint32_t tickstart
= 0;
1325 /* Process locked */
1328 /* Check the parameters */
1329 assert_param(IS_DSI_READ_PACKET_TYPE(Mode
));
1333 /* set max return packet size */
1334 HAL_DSI_ShortWrite(hdsi
, ChannelNbr
, DSI_MAX_RETURN_PKT_SIZE
, ((Size
)&0xFF), (((Size
)>>8)&0xFF));
1337 /* Configure the packet to read command */
1338 if (Mode
== DSI_DCS_SHORT_PKT_READ
)
1340 DSI_ConfigPacketHeader(hdsi
->Instance
, ChannelNbr
, Mode
, DCSCmd
, 0);
1342 else if (Mode
== DSI_GEN_SHORT_PKT_READ_P0
)
1344 DSI_ConfigPacketHeader(hdsi
->Instance
, ChannelNbr
, Mode
, 0, 0);
1346 else if (Mode
== DSI_GEN_SHORT_PKT_READ_P1
)
1348 DSI_ConfigPacketHeader(hdsi
->Instance
, ChannelNbr
, Mode
, ParametersTable
[0], 0);
1350 else if (Mode
== DSI_GEN_SHORT_PKT_READ_P2
)
1352 DSI_ConfigPacketHeader(hdsi
->Instance
, ChannelNbr
, Mode
, ParametersTable
[0], ParametersTable
[1]);
1356 /* Process Unlocked */
1363 tickstart
= HAL_GetTick();
1365 /* Check that the payload read FIFO is not empty */
1366 while((hdsi
->Instance
->GPSR
& DSI_GPSR_PRDFE
) == DSI_GPSR_PRDFE
)
1368 /* Check for the Timeout */
1369 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1371 /* Process Unlocked */
1378 /* Get the first byte */
1379 *((uint32_t *)Array
) = (hdsi
->Instance
->GPDR
);
1387 /* Process unlocked */
1394 tickstart
= HAL_GetTick();
1396 /* Get the remaining bytes if any */
1397 while(((int)(Size
)) > 0)
1399 if((hdsi
->Instance
->GPSR
& DSI_GPSR_PRDFE
) == 0)
1401 *((uint32_t *)Array
) = (hdsi
->Instance
->GPDR
);
1406 /* Check for the Timeout */
1407 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1409 /* Process Unlocked */
1416 /* Process unlocked */
1423 * @brief Enter the ULPM (Ultra Low Power Mode) with the D-PHY PLL running
1424 * (only data lanes are in ULPM)
1425 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1426 * the configuration information for the DSI.
1427 * @retval HAL status
1429 HAL_StatusTypeDef
HAL_DSI_EnterULPMData(DSI_HandleTypeDef
*hdsi
)
1431 uint32_t tickstart
= 0;
1433 /* Process locked */
1436 /* ULPS Request on Data Lanes */
1437 hdsi
->Instance
->PUCR
|= DSI_PUCR_URDL
;
1440 tickstart
= HAL_GetTick();
1442 /* Wait until the D-PHY active lanes enter into ULPM */
1443 if((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_ONE_DATA_LANE
)
1445 while((hdsi
->Instance
->PSR
& DSI_PSR_UAN0
) != RESET
)
1447 /* Check for the Timeout */
1448 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1450 /* Process Unlocked */
1457 else if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_TWO_DATA_LANES
)
1459 while((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UAN1
)) != RESET
)
1461 /* Check for the Timeout */
1462 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1464 /* Process Unlocked */
1472 /* Process unlocked */
1479 * @brief Exit the ULPM (Ultra Low Power Mode) with the D-PHY PLL running
1480 * (only data lanes are in ULPM)
1481 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1482 * the configuration information for the DSI.
1483 * @retval HAL status
1485 HAL_StatusTypeDef
HAL_DSI_ExitULPMData(DSI_HandleTypeDef
*hdsi
)
1487 uint32_t tickstart
= 0;
1489 /* Process locked */
1492 /* Exit ULPS on Data Lanes */
1493 hdsi
->Instance
->PUCR
|= DSI_PUCR_UEDL
;
1496 tickstart
= HAL_GetTick();
1498 /* Wait until all active lanes exit ULPM */
1499 if((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_ONE_DATA_LANE
)
1501 while((hdsi
->Instance
->PSR
& DSI_PSR_UAN0
) != DSI_PSR_UAN0
)
1503 /* Check for the Timeout */
1504 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1506 /* Process Unlocked */
1513 else if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_TWO_DATA_LANES
)
1515 while((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UAN1
)) != (DSI_PSR_UAN0
| DSI_PSR_UAN1
))
1517 /* Check for the Timeout */
1518 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1520 /* Process Unlocked */
1528 /* De-assert the ULPM requests and the ULPM exit bits */
1529 hdsi
->Instance
->PUCR
= 0;
1531 /* Process unlocked */
1538 * @brief Enter the ULPM (Ultra Low Power Mode) with the D-PHY PLL turned off
1539 * (both data and clock lanes are in ULPM)
1540 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1541 * the configuration information for the DSI.
1542 * @retval HAL status
1544 HAL_StatusTypeDef
HAL_DSI_EnterULPM(DSI_HandleTypeDef
*hdsi
)
1546 uint32_t tickstart
= 0;
1548 /* Process locked */
1551 /* Clock lane configuration: no more HS request */
1552 hdsi
->Instance
->CLCR
&= ~DSI_CLCR_DPCC
;
1554 /* Use system PLL as byte lane clock source before stopping DSIPHY clock source */
1555 __HAL_RCC_DSI_CONFIG(RCC_DSICLKSOURCE_PLLR
);
1557 /* ULPS Request on Clock and Data Lanes */
1558 hdsi
->Instance
->PUCR
|= (DSI_PUCR_URCL
| DSI_PUCR_URDL
);
1561 tickstart
= HAL_GetTick();
1563 /* Wait until all active lanes exit ULPM */
1564 if((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_ONE_DATA_LANE
)
1566 while((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UANC
)) != RESET
)
1568 /* Check for the Timeout */
1569 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1571 /* Process Unlocked */
1578 else if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_TWO_DATA_LANES
)
1580 while((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UAN1
| DSI_PSR_UANC
)) != RESET
)
1582 /* Check for the Timeout */
1583 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1585 /* Process Unlocked */
1593 /* Turn off the DSI PLL */
1594 __HAL_DSI_PLL_DISABLE(hdsi
);
1596 /* Process unlocked */
1603 * @brief Exit the ULPM (Ultra Low Power Mode) with the D-PHY PLL turned off
1604 * (both data and clock lanes are in ULPM)
1605 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1606 * the configuration information for the DSI.
1607 * @retval HAL status
1609 HAL_StatusTypeDef
HAL_DSI_ExitULPM(DSI_HandleTypeDef
*hdsi
)
1611 uint32_t tickstart
= 0;
1613 /* Process locked */
1616 /* Turn on the DSI PLL */
1617 __HAL_DSI_PLL_ENABLE(hdsi
);
1620 tickstart
= HAL_GetTick();
1622 /* Wait for the lock of the PLL */
1623 while(__HAL_DSI_GET_FLAG(hdsi
, DSI_FLAG_PLLLS
) == RESET
)
1625 /* Check for the Timeout */
1626 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1628 /* Process Unlocked */
1635 /* Exit ULPS on Clock and Data Lanes */
1636 hdsi
->Instance
->PUCR
|= (DSI_PUCR_UECL
| DSI_PUCR_UEDL
);
1639 tickstart
= HAL_GetTick();
1641 /* Wait until all active lanes exit ULPM */
1642 if((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_ONE_DATA_LANE
)
1644 while((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UANC
)) != (DSI_PSR_UAN0
| DSI_PSR_UANC
))
1646 /* Check for the Timeout */
1647 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1649 /* Process Unlocked */
1656 else if ((hdsi
->Instance
->PCONFR
& DSI_PCONFR_NL
) == DSI_TWO_DATA_LANES
)
1658 while((hdsi
->Instance
->PSR
& (DSI_PSR_UAN0
| DSI_PSR_UAN1
| DSI_PSR_UANC
)) != (DSI_PSR_UAN0
| DSI_PSR_UAN1
| DSI_PSR_UANC
))
1660 /* Check for the Timeout */
1661 if((HAL_GetTick() - tickstart
) > DSI_TIMEOUT_VALUE
)
1663 /* Process Unlocked */
1671 /* De-assert the ULPM requests and the ULPM exit bits */
1672 hdsi
->Instance
->PUCR
= 0;
1674 /* Switch the lanbyteclock source in the RCC from system PLL to D-PHY */
1675 __HAL_RCC_DSI_CONFIG(RCC_DSICLKSOURCE_DSIPHY
);
1677 /* Restore clock lane configuration to HS */
1678 hdsi
->Instance
->CLCR
|= DSI_CLCR_DPCC
;
1680 /* Process unlocked */
1687 * @brief Start test pattern generation
1688 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1689 * the configuration information for the DSI.
1690 * @param Mode: Pattern generator mode
1691 * This parameter can be one of the following values:
1692 * 0 : Color bars (horizontal or vertical)
1693 * 1 : BER pattern (vertical only)
1694 * @param Orientation: Pattern generator orientation
1695 * This parameter can be one of the following values:
1696 * 0 : Vertical color bars
1697 * 1 : Horizontal color bars
1698 * @retval HAL status
1700 HAL_StatusTypeDef
HAL_DSI_PatternGeneratorStart(DSI_HandleTypeDef
*hdsi
, uint32_t Mode
, uint32_t Orientation
)
1702 /* Process locked */
1705 /* Configure pattern generator mode and orientation */
1706 hdsi
->Instance
->VMCR
&= ~(DSI_VMCR_PGM
| DSI_VMCR_PGO
);
1707 hdsi
->Instance
->VMCR
|= ((Mode
<<20) | (Orientation
<<24));
1709 /* Enable pattern generator by setting PGE bit */
1710 hdsi
->Instance
->VMCR
|= DSI_VMCR_PGE
;
1712 /* Process unlocked */
1719 * @brief Stop test pattern generation
1720 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1721 * the configuration information for the DSI.
1722 * @retval HAL status
1724 HAL_StatusTypeDef
HAL_DSI_PatternGeneratorStop(DSI_HandleTypeDef
*hdsi
)
1726 /* Process locked */
1729 /* Disable pattern generator by clearing PGE bit */
1730 hdsi
->Instance
->VMCR
&= ~DSI_VMCR_PGE
;
1732 /* Process unlocked */
1739 * @brief Set Slew-Rate And Delay Tuning
1740 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1741 * the configuration information for the DSI.
1742 * @param CommDelay: Communication delay to be adjusted.
1743 * This parameter can be any value of @ref DSI_Communication_Delay
1744 * @param Lane: select between clock or data lanes.
1745 * This parameter can be any value of @ref DSI_Lane_Group
1746 * @param Value: Custom value of the slew-rate or delay
1747 * @retval HAL status
1749 HAL_StatusTypeDef
HAL_DSI_SetSlewRateAndDelayTuning(DSI_HandleTypeDef
*hdsi
, uint32_t CommDelay
, uint32_t Lane
, uint32_t Value
)
1751 /* Process locked */
1754 /* Check function parameters */
1755 assert_param(IS_DSI_COMMUNICATION_DELAY(CommDelay
));
1756 assert_param(IS_DSI_LANE_GROUP(Lane
));
1760 case DSI_SLEW_RATE_HSTX
:
1761 if(Lane
== DSI_CLOCK_LANE
)
1763 /* High-Speed Transmission Slew Rate Control on Clock Lane */
1764 hdsi
->Instance
->WPCR
[1] &= ~DSI_WPCR1_HSTXSRCCL
;
1765 hdsi
->Instance
->WPCR
[1] |= Value
<<16;
1767 else if(Lane
== DSI_DATA_LANES
)
1769 /* High-Speed Transmission Slew Rate Control on Data Lanes */
1770 hdsi
->Instance
->WPCR
[1] &= ~DSI_WPCR1_HSTXSRCDL
;
1771 hdsi
->Instance
->WPCR
[1] |= Value
<<18;
1774 case DSI_SLEW_RATE_LPTX
:
1775 if(Lane
== DSI_CLOCK_LANE
)
1777 /* Low-Power transmission Slew Rate Compensation on Clock Lane */
1778 hdsi
->Instance
->WPCR
[1] &= ~DSI_WPCR1_LPSRCCL
;
1779 hdsi
->Instance
->WPCR
[1] |= Value
<<6;
1781 else if(Lane
== DSI_DATA_LANES
)
1783 /* Low-Power transmission Slew Rate Compensation on Data Lanes */
1784 hdsi
->Instance
->WPCR
[1] &= ~DSI_WPCR1_LPSRCDL
;
1785 hdsi
->Instance
->WPCR
[1] |= Value
<<8;
1789 if(Lane
== DSI_CLOCK_LANE
)
1791 /* High-Speed Transmission Delay on Clock Lane */
1792 hdsi
->Instance
->WPCR
[1] &= ~DSI_WPCR1_HSTXDCL
;
1793 hdsi
->Instance
->WPCR
[1] |= Value
;
1795 else if(Lane
== DSI_DATA_LANES
)
1797 /* High-Speed Transmission Delay on Data Lanes */
1798 hdsi
->Instance
->WPCR
[1] &= ~DSI_WPCR1_HSTXDDL
;
1799 hdsi
->Instance
->WPCR
[1] |= Value
<<2;
1806 /* Process unlocked */
1813 * @brief Low-Power Reception Filter Tuning
1814 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1815 * the configuration information for the DSI.
1816 * @param Frequency: cutoff frequency of low-pass filter at the input of LPRX
1817 * @retval HAL status
1819 HAL_StatusTypeDef
HAL_DSI_SetLowPowerRXFilter(DSI_HandleTypeDef
*hdsi
, uint32_t Frequency
)
1821 /* Process locked */
1824 /* Low-Power RX low-pass Filtering Tuning */
1825 hdsi
->Instance
->WPCR
[1] &= ~DSI_WPCR1_LPRXFT
;
1826 hdsi
->Instance
->WPCR
[1] |= Frequency
<<25;
1828 /* Process unlocked */
1835 * @brief Activate an additional current path on all lanes to meet the SDDTx parameter
1836 * defined in the MIPI D-PHY specification
1837 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1838 * the configuration information for the DSI.
1839 * @param State: ENABLE or DISABLE
1840 * @retval HAL status
1842 HAL_StatusTypeDef
HAL_DSI_SetSDD(DSI_HandleTypeDef
*hdsi
, FunctionalState State
)
1844 /* Process locked */
1847 /* Check function parameters */
1848 assert_param(IS_FUNCTIONAL_STATE(State
));
1850 /* Activate/Disactivate additional current path on all lanes */
1851 hdsi
->Instance
->WPCR
[1] &= ~DSI_WPCR1_SDDC
;
1852 hdsi
->Instance
->WPCR
[1] |= ((uint32_t)State
<< 12);
1854 /* Process unlocked */
1861 * @brief Custom lane pins configuration
1862 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1863 * the configuration information for the DSI.
1864 * @param CustomLane: Function to be applyed on selected lane.
1865 * This parameter can be any value of @ref DSI_CustomLane
1866 * @param Lane: select between clock or data lane 0 or data lane 1.
1867 * This parameter can be any value of @ref DSI_Lane_Select
1868 * @param State: ENABLE or DISABLE
1869 * @retval HAL status
1871 HAL_StatusTypeDef
HAL_DSI_SetLanePinsConfiguration(DSI_HandleTypeDef
*hdsi
, uint32_t CustomLane
, uint32_t Lane
, FunctionalState State
)
1873 /* Process locked */
1876 /* Check function parameters */
1877 assert_param(IS_DSI_CUSTOM_LANE(CustomLane
));
1878 assert_param(IS_DSI_LANE(Lane
));
1879 assert_param(IS_FUNCTIONAL_STATE(State
));
1883 case DSI_SWAP_LANE_PINS
:
1884 if(Lane
== DSI_CLOCK_LANE
)
1886 /* Swap pins on clock lane */
1887 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_SWCL
;
1888 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 6);
1890 else if(Lane
== DSI_DATA_LANE0
)
1892 /* Swap pins on data lane 0 */
1893 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_SWDL0
;
1894 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 7);
1896 else if(Lane
== DSI_DATA_LANE1
)
1898 /* Swap pins on data lane 1 */
1899 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_SWDL1
;
1900 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 8);
1903 case DSI_INVERT_HS_SIGNAL
:
1904 if(Lane
== DSI_CLOCK_LANE
)
1906 /* Invert HS signal on clock lane */
1907 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_HSICL
;
1908 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 9);
1910 else if(Lane
== DSI_DATA_LANE0
)
1912 /* Invert HS signal on data lane 0 */
1913 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_HSIDL0
;
1914 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 10);
1916 else if(Lane
== DSI_DATA_LANE1
)
1918 /* Invert HS signal on data lane 1 */
1919 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_HSIDL1
;
1920 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 11);
1927 /* Process unlocked */
1934 * @brief Set custom timing for the PHY
1935 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
1936 * the configuration information for the DSI.
1937 * @param Timing: PHY timing to be adjusted.
1938 * This parameter can be any value of @ref DSI_PHY_Timing
1939 * @param State: ENABLE or DISABLE
1940 * @param Value: Custom value of the timing
1941 * @retval HAL status
1943 HAL_StatusTypeDef
HAL_DSI_SetPHYTimings(DSI_HandleTypeDef
*hdsi
, uint32_t Timing
, FunctionalState State
, uint32_t Value
)
1945 /* Process locked */
1948 /* Check function parameters */
1949 assert_param(IS_DSI_PHY_TIMING(Timing
));
1950 assert_param(IS_FUNCTIONAL_STATE(State
));
1955 /* Enable/Disable custom timing setting */
1956 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_TCLKPOSTEN
;
1957 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 27);
1961 /* Set custom value */
1962 hdsi
->Instance
->WPCR
[4] &= ~DSI_WPCR4_TCLKPOST
;
1963 hdsi
->Instance
->WPCR
[4] |= Value
& DSI_WPCR4_TCLKPOST
;
1968 /* Enable/Disable custom timing setting */
1969 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_TLPXCEN
;
1970 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 26);
1974 /* Set custom value */
1975 hdsi
->Instance
->WPCR
[3] &= ~DSI_WPCR3_TLPXC
;
1976 hdsi
->Instance
->WPCR
[3] |= (Value
<< 24) & DSI_WPCR3_TLPXC
;
1981 /* Enable/Disable custom timing setting */
1982 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_THSEXITEN
;
1983 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 25);
1987 /* Set custom value */
1988 hdsi
->Instance
->WPCR
[3] &= ~DSI_WPCR3_THSEXIT
;
1989 hdsi
->Instance
->WPCR
[3] |= (Value
<< 16) & DSI_WPCR3_THSEXIT
;
1994 /* Enable/Disable custom timing setting */
1995 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_TLPXDEN
;
1996 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 24);
2000 /* Set custom value */
2001 hdsi
->Instance
->WPCR
[3] &= ~DSI_WPCR3_TLPXD
;
2002 hdsi
->Instance
->WPCR
[3] |= (Value
<< 8) & DSI_WPCR3_TLPXD
;
2007 /* Enable/Disable custom timing setting */
2008 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_THSZEROEN
;
2009 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 23);
2013 /* Set custom value */
2014 hdsi
->Instance
->WPCR
[3] &= ~DSI_WPCR3_THSZERO
;
2015 hdsi
->Instance
->WPCR
[3] |= Value
& DSI_WPCR3_THSZERO
;
2020 /* Enable/Disable custom timing setting */
2021 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_THSTRAILEN
;
2022 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 22);
2026 /* Set custom value */
2027 hdsi
->Instance
->WPCR
[2] &= ~DSI_WPCR2_THSTRAIL
;
2028 hdsi
->Instance
->WPCR
[2] |= (Value
<< 24) & DSI_WPCR2_THSTRAIL
;
2032 case DSI_THS_PREPARE
:
2033 /* Enable/Disable custom timing setting */
2034 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_THSPREPEN
;
2035 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 21);
2039 /* Set custom value */
2040 hdsi
->Instance
->WPCR
[2] &= ~DSI_WPCR2_THSPREP
;
2041 hdsi
->Instance
->WPCR
[2] |= (Value
<< 16) & DSI_WPCR2_THSPREP
;
2046 /* Enable/Disable custom timing setting */
2047 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_TCLKZEROEN
;
2048 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 20);
2052 /* Set custom value */
2053 hdsi
->Instance
->WPCR
[2] &= ~DSI_WPCR2_TCLKZERO
;
2054 hdsi
->Instance
->WPCR
[2] |= (Value
<< 8) & DSI_WPCR2_TCLKZERO
;
2058 case DSI_TCLK_PREPARE
:
2059 /* Enable/Disable custom timing setting */
2060 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_TCLKPREPEN
;
2061 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 19);
2065 /* Set custom value */
2066 hdsi
->Instance
->WPCR
[2] &= ~DSI_WPCR2_TCLKPREP
;
2067 hdsi
->Instance
->WPCR
[2] |= Value
& DSI_WPCR2_TCLKPREP
;
2075 /* Process unlocked */
2082 * @brief Force the Clock/Data Lane in TX Stop Mode
2083 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
2084 * the configuration information for the DSI.
2085 * @param Lane: select between clock or data lanes.
2086 * This parameter can be any value of @ref DSI_Lane_Group
2087 * @param State: ENABLE or DISABLE
2088 * @retval HAL status
2090 HAL_StatusTypeDef
HAL_DSI_ForceTXStopMode(DSI_HandleTypeDef
*hdsi
, uint32_t Lane
, FunctionalState State
)
2092 /* Process locked */
2095 /* Check function parameters */
2096 assert_param(IS_DSI_LANE_GROUP(Lane
));
2097 assert_param(IS_FUNCTIONAL_STATE(State
));
2099 if(Lane
== DSI_CLOCK_LANE
)
2101 /* Force/Unforce the Clock Lane in TX Stop Mode */
2102 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_FTXSMCL
;
2103 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 12);
2105 else if(Lane
== DSI_DATA_LANES
)
2107 /* Force/Unforce the Data Lanes in TX Stop Mode */
2108 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_FTXSMDL
;
2109 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 13);
2112 /* Process unlocked */
2119 * @brief Forces LP Receiver in Low-Power Mode
2120 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
2121 * the configuration information for the DSI.
2122 * @param State: ENABLE or DISABLE
2123 * @retval HAL status
2125 HAL_StatusTypeDef
HAL_DSI_ForceRXLowPower(DSI_HandleTypeDef
*hdsi
, FunctionalState State
)
2127 /* Process locked */
2130 /* Check function parameters */
2131 assert_param(IS_FUNCTIONAL_STATE(State
));
2133 /* Force/Unforce LP Receiver in Low-Power Mode */
2134 hdsi
->Instance
->WPCR
[1] &= ~DSI_WPCR1_FLPRXLPM
;
2135 hdsi
->Instance
->WPCR
[1] |= ((uint32_t)State
<< 22);
2137 /* Process unlocked */
2144 * @brief Force Data Lanes in RX Mode after a BTA
2145 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
2146 * the configuration information for the DSI.
2147 * @param State: ENABLE or DISABLE
2148 * @retval HAL status
2150 HAL_StatusTypeDef
HAL_DSI_ForceDataLanesInRX(DSI_HandleTypeDef
*hdsi
, FunctionalState State
)
2152 /* Process locked */
2155 /* Check function parameters */
2156 assert_param(IS_FUNCTIONAL_STATE(State
));
2158 /* Force Data Lanes in RX Mode */
2159 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_TDDL
;
2160 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 16);
2162 /* Process unlocked */
2169 * @brief Enable a pull-down on the lanes to prevent from floating states when unused
2170 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
2171 * the configuration information for the DSI.
2172 * @param State: ENABLE or DISABLE
2173 * @retval HAL status
2175 HAL_StatusTypeDef
HAL_DSI_SetPullDown(DSI_HandleTypeDef
*hdsi
, FunctionalState State
)
2177 /* Process locked */
2180 /* Check function parameters */
2181 assert_param(IS_FUNCTIONAL_STATE(State
));
2183 /* Enable/Disable pull-down on lanes */
2184 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_PDEN
;
2185 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 18);
2187 /* Process unlocked */
2194 * @brief Switch off the contention detection on data lanes
2195 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
2196 * the configuration information for the DSI.
2197 * @param State: ENABLE or DISABLE
2198 * @retval HAL status
2200 HAL_StatusTypeDef
HAL_DSI_SetContentionDetectionOff(DSI_HandleTypeDef
*hdsi
, FunctionalState State
)
2202 /* Process locked */
2205 /* Check function parameters */
2206 assert_param(IS_FUNCTIONAL_STATE(State
));
2208 /* Contention Detection on Data Lanes OFF */
2209 hdsi
->Instance
->WPCR
[0] &= ~DSI_WPCR0_CDOFFDL
;
2210 hdsi
->Instance
->WPCR
[0] |= ((uint32_t)State
<< 14);
2212 /* Process unlocked */
2222 /** @defgroup DSI_Group4 Peripheral State and Errors functions
2223 * @brief Peripheral State and Errors functions
2226 ===============================================================================
2227 ##### Peripheral State and Errors functions #####
2228 ===============================================================================
2230 This subsection provides functions allowing to
2231 (+) Check the DSI state.
2239 * @brief Return the DSI state
2240 * @param hdsi: pointer to a DSI_HandleTypeDef structure that contains
2241 * the configuration information for the DSI.
2244 HAL_DSI_StateTypeDef
HAL_DSI_GetState(DSI_HandleTypeDef
*hdsi
)
2256 #endif /*STM32F769xx | STM32F779xx */
2257 #endif /* HAL_DSI_MODULE_ENABLED */
2266 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/