stm32l4xx_hal_dsi.h 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_dsi.h
  4. * @author MCD Application Team
  5. * @brief Header file of DSI HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L4xx_HAL_DSI_H
  37. #define __STM32L4xx_HAL_DSI_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l4xx_hal_def.h"
  43. #if defined(DSI)
  44. /** @addtogroup STM32L4xx_HAL_Driver
  45. * @{
  46. */
  47. /** @defgroup DSI DSI
  48. * @brief DSI HAL module driver
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /**
  53. * @brief DSI Init Structure definition
  54. */
  55. typedef struct
  56. {
  57. uint32_t AutomaticClockLaneControl; /*!< Automatic clock lane control
  58. This parameter can be any value of @ref DSI_Automatic_Clk_Lane_Control */
  59. uint32_t TXEscapeCkdiv; /*!< TX Escape clock division
  60. The values 0 and 1 stop the TX_ESC clock generation */
  61. uint32_t NumberOfLanes; /*!< Number of lanes
  62. This parameter can be any value of @ref DSI_Number_Of_Lanes */
  63. }DSI_InitTypeDef;
  64. /**
  65. * @brief DSI PLL Clock structure definition
  66. */
  67. typedef struct
  68. {
  69. uint32_t PLLNDIV; /*!< PLL Loop Division Factor
  70. This parameter must be a value between 10 and 125 */
  71. uint32_t PLLIDF; /*!< PLL Input Division Factor
  72. This parameter can be any value of @ref DSI_PLL_IDF */
  73. uint32_t PLLODF; /*!< PLL Output Division Factor
  74. This parameter can be any value of @ref DSI_PLL_ODF */
  75. }DSI_PLLInitTypeDef;
  76. /**
  77. * @brief DSI Video mode configuration
  78. */
  79. typedef struct
  80. {
  81. uint32_t VirtualChannelID; /*!< Virtual channel ID */
  82. uint32_t ColorCoding; /*!< Color coding for LTDC interface
  83. This parameter can be any value of @ref DSI_Color_Coding */
  84. uint32_t LooselyPacked; /*!< Enable or disable loosely packed stream (needed only when using
  85. 18-bit configuration).
  86. This parameter can be any value of @ref DSI_LooselyPacked */
  87. uint32_t Mode; /*!< Video mode type
  88. This parameter can be any value of @ref DSI_Video_Mode_Type */
  89. uint32_t PacketSize; /*!< Video packet size */
  90. uint32_t NumberOfChunks; /*!< Number of chunks */
  91. uint32_t NullPacketSize; /*!< Null packet size */
  92. uint32_t HSPolarity; /*!< HSYNC pin polarity
  93. This parameter can be any value of @ref DSI_HSYNC_Polarity */
  94. uint32_t VSPolarity; /*!< VSYNC pin polarity
  95. This parameter can be any value of @ref DSI_VSYNC_Active_Polarity */
  96. uint32_t DEPolarity; /*!< Data Enable pin polarity
  97. This parameter can be any value of @ref DSI_DATA_ENABLE_Polarity */
  98. uint32_t HorizontalSyncActive; /*!< Horizontal synchronism active duration (in lane byte clock cycles) */
  99. uint32_t HorizontalBackPorch; /*!< Horizontal back-porch duration (in lane byte clock cycles) */
  100. uint32_t HorizontalLine; /*!< Horizontal line duration (in lane byte clock cycles) */
  101. uint32_t VerticalSyncActive; /*!< Vertical synchronism active duration */
  102. uint32_t VerticalBackPorch; /*!< Vertical back-porch duration */
  103. uint32_t VerticalFrontPorch; /*!< Vertical front-porch duration */
  104. uint32_t VerticalActive; /*!< Vertical active duration */
  105. uint32_t LPCommandEnable; /*!< Low-power command enable
  106. This parameter can be any value of @ref DSI_LP_Command */
  107. uint32_t LPLargestPacketSize; /*!< The size, in bytes, of the low power largest packet that
  108. can fit in a line during VSA, VBP and VFP regions */
  109. uint32_t LPVACTLargestPacketSize; /*!< The size, in bytes, of the low power largest packet that
  110. can fit in a line during VACT region */
  111. uint32_t LPHorizontalFrontPorchEnable; /*!< Low-power horizontal front-porch enable
  112. This parameter can be any value of @ref DSI_LP_HFP */
  113. uint32_t LPHorizontalBackPorchEnable; /*!< Low-power horizontal back-porch enable
  114. This parameter can be any value of @ref DSI_LP_HBP */
  115. uint32_t LPVerticalActiveEnable; /*!< Low-power vertical active enable
  116. This parameter can be any value of @ref DSI_LP_VACT */
  117. uint32_t LPVerticalFrontPorchEnable; /*!< Low-power vertical front-porch enable
  118. This parameter can be any value of @ref DSI_LP_VFP */
  119. uint32_t LPVerticalBackPorchEnable; /*!< Low-power vertical back-porch enable
  120. This parameter can be any value of @ref DSI_LP_VBP */
  121. uint32_t LPVerticalSyncActiveEnable; /*!< Low-power vertical sync active enable
  122. This parameter can be any value of @ref DSI_LP_VSYNC */
  123. uint32_t FrameBTAAcknowledgeEnable; /*!< Frame bus-turn-around acknowledge enable
  124. This parameter can be any value of @ref DSI_FBTA_acknowledge */
  125. }DSI_VidCfgTypeDef;
  126. /**
  127. * @brief DSI Adapted command mode configuration
  128. */
  129. typedef struct
  130. {
  131. uint32_t VirtualChannelID; /*!< Virtual channel ID */
  132. uint32_t ColorCoding; /*!< Color coding for LTDC interface
  133. This parameter can be any value of @ref DSI_Color_Coding */
  134. uint32_t CommandSize; /*!< Maximum allowed size for an LTDC write memory command, measured in
  135. pixels. This parameter can be any value between 0x00 and 0xFFFFU */
  136. uint32_t TearingEffectSource; /*!< Tearing effect source
  137. This parameter can be any value of @ref DSI_TearingEffectSource */
  138. uint32_t TearingEffectPolarity; /*!< Tearing effect pin polarity
  139. This parameter can be any value of @ref DSI_TearingEffectPolarity */
  140. uint32_t HSPolarity; /*!< HSYNC pin polarity
  141. This parameter can be any value of @ref DSI_HSYNC_Polarity */
  142. uint32_t VSPolarity; /*!< VSYNC pin polarity
  143. This parameter can be any value of @ref DSI_VSYNC_Active_Polarity */
  144. uint32_t DEPolarity; /*!< Data Enable pin polarity
  145. This parameter can be any value of @ref DSI_DATA_ENABLE_Polarity */
  146. uint32_t VSyncPol; /*!< VSync edge on which the LTDC is halted
  147. This parameter can be any value of @ref DSI_Vsync_Polarity */
  148. uint32_t AutomaticRefresh; /*!< Automatic refresh mode
  149. This parameter can be any value of @ref DSI_AutomaticRefresh */
  150. uint32_t TEAcknowledgeRequest; /*!< Tearing Effect Acknowledge Request Enable
  151. This parameter can be any value of @ref DSI_TE_AcknowledgeRequest */
  152. }DSI_CmdCfgTypeDef;
  153. /**
  154. * @brief DSI command transmission mode configuration
  155. */
  156. typedef struct
  157. {
  158. uint32_t LPGenShortWriteNoP; /*!< Generic Short Write Zero parameters Transmission
  159. This parameter can be any value of @ref DSI_LP_LPGenShortWriteNoP */
  160. uint32_t LPGenShortWriteOneP; /*!< Generic Short Write One parameter Transmission
  161. This parameter can be any value of @ref DSI_LP_LPGenShortWriteOneP */
  162. uint32_t LPGenShortWriteTwoP; /*!< Generic Short Write Two parameters Transmission
  163. This parameter can be any value of @ref DSI_LP_LPGenShortWriteTwoP */
  164. uint32_t LPGenShortReadNoP; /*!< Generic Short Read Zero parameters Transmission
  165. This parameter can be any value of @ref DSI_LP_LPGenShortReadNoP */
  166. uint32_t LPGenShortReadOneP; /*!< Generic Short Read One parameter Transmission
  167. This parameter can be any value of @ref DSI_LP_LPGenShortReadOneP */
  168. uint32_t LPGenShortReadTwoP; /*!< Generic Short Read Two parameters Transmission
  169. This parameter can be any value of @ref DSI_LP_LPGenShortReadTwoP */
  170. uint32_t LPGenLongWrite; /*!< Generic Long Write Transmission
  171. This parameter can be any value of @ref DSI_LP_LPGenLongWrite */
  172. uint32_t LPDcsShortWriteNoP; /*!< DCS Short Write Zero parameters Transmission
  173. This parameter can be any value of @ref DSI_LP_LPDcsShortWriteNoP */
  174. uint32_t LPDcsShortWriteOneP; /*!< DCS Short Write One parameter Transmission
  175. This parameter can be any value of @ref DSI_LP_LPDcsShortWriteOneP */
  176. uint32_t LPDcsShortReadNoP; /*!< DCS Short Read Zero parameters Transmission
  177. This parameter can be any value of @ref DSI_LP_LPDcsShortReadNoP */
  178. uint32_t LPDcsLongWrite; /*!< DCS Long Write Transmission
  179. This parameter can be any value of @ref DSI_LP_LPDcsLongWrite */
  180. uint32_t LPMaxReadPacket; /*!< Maximum Read Packet Size Transmission
  181. This parameter can be any value of @ref DSI_LP_LPMaxReadPacket */
  182. uint32_t AcknowledgeRequest; /*!< Acknowledge Request Enable
  183. This parameter can be any value of @ref DSI_AcknowledgeRequest */
  184. }DSI_LPCmdTypeDef;
  185. /**
  186. * @brief DSI PHY Timings definition
  187. */
  188. typedef struct
  189. {
  190. uint32_t ClockLaneHS2LPTime; /*!< The maximum time that the D-PHY clock lane takes to go from high-speed
  191. to low-power transmission */
  192. uint32_t ClockLaneLP2HSTime; /*!< The maximum time that the D-PHY clock lane takes to go from low-power
  193. to high-speed transmission */
  194. uint32_t DataLaneHS2LPTime; /*!< The maximum time that the D-PHY data lanes takes to go from high-speed
  195. to low-power transmission */
  196. uint32_t DataLaneLP2HSTime; /*!< The maximum time that the D-PHY data lanes takes to go from low-power
  197. to high-speed transmission */
  198. uint32_t DataLaneMaxReadTime; /*!< The maximum time required to perform a read command */
  199. uint32_t StopWaitTime; /*!< The minimum wait period to request a High-Speed transmission after the
  200. Stop state */
  201. }DSI_PHY_TimerTypeDef;
  202. /**
  203. * @brief DSI HOST Timeouts definition
  204. */
  205. typedef struct
  206. {
  207. uint32_t TimeoutCkdiv; /*!< Time-out clock division */
  208. uint32_t HighSpeedTransmissionTimeout; /*!< High-speed transmission time-out */
  209. uint32_t LowPowerReceptionTimeout; /*!< Low-power reception time-out */
  210. uint32_t HighSpeedReadTimeout; /*!< High-speed read time-out */
  211. uint32_t LowPowerReadTimeout; /*!< Low-power read time-out */
  212. uint32_t HighSpeedWriteTimeout; /*!< High-speed write time-out */
  213. uint32_t HighSpeedWritePrespMode; /*!< High-speed write presp mode
  214. This parameter can be any value of @ref DSI_HS_PrespMode */
  215. uint32_t LowPowerWriteTimeout; /*!< Low-speed write time-out */
  216. uint32_t BTATimeout; /*!< BTA time-out */
  217. }DSI_HOST_TimeoutTypeDef;
  218. /**
  219. * @brief DSI States Structure definition
  220. */
  221. typedef enum
  222. {
  223. HAL_DSI_STATE_RESET = 0x00U,
  224. HAL_DSI_STATE_READY = 0x01U,
  225. HAL_DSI_STATE_ERROR = 0x02U,
  226. HAL_DSI_STATE_BUSY = 0x03U,
  227. HAL_DSI_STATE_TIMEOUT = 0x04U
  228. }HAL_DSI_StateTypeDef;
  229. /**
  230. * @brief DSI Handle Structure definition
  231. */
  232. typedef struct
  233. {
  234. DSI_TypeDef *Instance; /*!< Register base address */
  235. DSI_InitTypeDef Init; /*!< DSI required parameters */
  236. HAL_LockTypeDef Lock; /*!< DSI peripheral status */
  237. __IO HAL_DSI_StateTypeDef State; /*!< DSI communication state */
  238. __IO uint32_t ErrorCode; /*!< DSI Error code */
  239. uint32_t ErrorMsk; /*!< DSI Error monitoring mask */
  240. }DSI_HandleTypeDef;
  241. /* Exported constants --------------------------------------------------------*/
  242. /** @defgroup DSI_DCS_Command DSI DCS Command
  243. * @{
  244. */
  245. #define DSI_ENTER_IDLE_MODE 0x39U
  246. #define DSI_ENTER_INVERT_MODE 0x21U
  247. #define DSI_ENTER_NORMAL_MODE 0x13U
  248. #define DSI_ENTER_PARTIAL_MODE 0x12U
  249. #define DSI_ENTER_SLEEP_MODE 0x10U
  250. #define DSI_EXIT_IDLE_MODE 0x38U
  251. #define DSI_EXIT_INVERT_MODE 0x20U
  252. #define DSI_EXIT_SLEEP_MODE 0x11U
  253. #define DSI_GET_3D_CONTROL 0x3FU
  254. #define DSI_GET_ADDRESS_MODE 0x0BU
  255. #define DSI_GET_BLUE_CHANNEL 0x08U
  256. #define DSI_GET_DIAGNOSTIC_RESULT 0x0FU
  257. #define DSI_GET_DISPLAY_MODE 0x0DU
  258. #define DSI_GET_GREEN_CHANNEL 0x07U
  259. #define DSI_GET_PIXEL_FORMAT 0x0CU
  260. #define DSI_GET_POWER_MODE 0x0AU
  261. #define DSI_GET_RED_CHANNEL 0x06U
  262. #define DSI_GET_SCANLINE 0x45U
  263. #define DSI_GET_SIGNAL_MODE 0x0EU
  264. #define DSI_NOP 0x00U
  265. #define DSI_READ_DDB_CONTINUE 0xA8U
  266. #define DSI_READ_DDB_START 0xA1U
  267. #define DSI_READ_MEMORY_CONTINUE 0x3EU
  268. #define DSI_READ_MEMORY_START 0x2EU
  269. #define DSI_SET_3D_CONTROL 0x3DU
  270. #define DSI_SET_ADDRESS_MODE 0x36U
  271. #define DSI_SET_COLUMN_ADDRESS 0x2AU
  272. #define DSI_SET_DISPLAY_OFF 0x28U
  273. #define DSI_SET_DISPLAY_ON 0x29U
  274. #define DSI_SET_GAMMA_CURVE 0x26U
  275. #define DSI_SET_PAGE_ADDRESS 0x2BU
  276. #define DSI_SET_PARTIAL_COLUMNS 0x31U
  277. #define DSI_SET_PARTIAL_ROWS 0x30U
  278. #define DSI_SET_PIXEL_FORMAT 0x3AU
  279. #define DSI_SET_SCROLL_AREA 0x33U
  280. #define DSI_SET_SCROLL_START 0x37U
  281. #define DSI_SET_TEAR_OFF 0x34U
  282. #define DSI_SET_TEAR_ON 0x35U
  283. #define DSI_SET_TEAR_SCANLINE 0x44U
  284. #define DSI_SET_VSYNC_TIMING 0x40U
  285. #define DSI_SOFT_RESET 0x01U
  286. #define DSI_WRITE_LUT 0x2DU
  287. #define DSI_WRITE_MEMORY_CONTINUE 0x3CU
  288. #define DSI_WRITE_MEMORY_START 0x2CU
  289. /**
  290. * @}
  291. */
  292. /** @defgroup DSI_Video_Mode_Type DSI Video Mode Type
  293. * @{
  294. */
  295. #define DSI_VID_MODE_NB_PULSES 0U
  296. #define DSI_VID_MODE_NB_EVENTS 1U
  297. #define DSI_VID_MODE_BURST 2U
  298. /**
  299. * @}
  300. */
  301. /** @defgroup DSI_Color_Mode DSI Color Mode
  302. * @{
  303. */
  304. #define DSI_COLOR_MODE_FULL 0x00000000U
  305. #define DSI_COLOR_MODE_EIGHT DSI_WCR_COLM
  306. /**
  307. * @}
  308. */
  309. /** @defgroup DSI_ShutDown DSI ShutDown
  310. * @{
  311. */
  312. #define DSI_DISPLAY_ON 0x00000000U
  313. #define DSI_DISPLAY_OFF DSI_WCR_SHTDN
  314. /**
  315. * @}
  316. */
  317. /** @defgroup DSI_LP_Command DSI LP Command
  318. * @{
  319. */
  320. #define DSI_LP_COMMAND_DISABLE 0x00000000U
  321. #define DSI_LP_COMMAND_ENABLE DSI_VMCR_LPCE
  322. /**
  323. * @}
  324. */
  325. /** @defgroup DSI_LP_HFP DSI LP HFP
  326. * @{
  327. */
  328. #define DSI_LP_HFP_DISABLE 0x00000000U
  329. #define DSI_LP_HFP_ENABLE DSI_VMCR_LPHFPE
  330. /**
  331. * @}
  332. */
  333. /** @defgroup DSI_LP_HBP DSI LP HBP
  334. * @{
  335. */
  336. #define DSI_LP_HBP_DISABLE 0x00000000U
  337. #define DSI_LP_HBP_ENABLE DSI_VMCR_LPHBPE
  338. /**
  339. * @}
  340. */
  341. /** @defgroup DSI_LP_VACT DSI LP VACT
  342. * @{
  343. */
  344. #define DSI_LP_VACT_DISABLE 0x00000000U
  345. #define DSI_LP_VACT_ENABLE DSI_VMCR_LPVAE
  346. /**
  347. * @}
  348. */
  349. /** @defgroup DSI_LP_VFP DSI LP VFP
  350. * @{
  351. */
  352. #define DSI_LP_VFP_DISABLE 0x00000000U
  353. #define DSI_LP_VFP_ENABLE DSI_VMCR_LPVFPE
  354. /**
  355. * @}
  356. */
  357. /** @defgroup DSI_LP_VBP DSI LP VBP
  358. * @{
  359. */
  360. #define DSI_LP_VBP_DISABLE 0x00000000U
  361. #define DSI_LP_VBP_ENABLE DSI_VMCR_LPVBPE
  362. /**
  363. * @}
  364. */
  365. /** @defgroup DSI_LP_VSYNC DSI LP VSYNC
  366. * @{
  367. */
  368. #define DSI_LP_VSYNC_DISABLE 0x00000000U
  369. #define DSI_LP_VSYNC_ENABLE DSI_VMCR_LPVSAE
  370. /**
  371. * @}
  372. */
  373. /** @defgroup DSI_FBTA_acknowledge DSI FBTA Acknowledge
  374. * @{
  375. */
  376. #define DSI_FBTAA_DISABLE 0x00000000U
  377. #define DSI_FBTAA_ENABLE DSI_VMCR_FBTAAE
  378. /**
  379. * @}
  380. */
  381. /** @defgroup DSI_TearingEffectSource DSI Tearing Effect Source
  382. * @{
  383. */
  384. #define DSI_TE_DSILINK 0x00000000U
  385. #define DSI_TE_EXTERNAL DSI_WCFGR_TESRC
  386. /**
  387. * @}
  388. */
  389. /** @defgroup DSI_TearingEffectPolarity DSI Tearing Effect Polarity
  390. * @{
  391. */
  392. #define DSI_TE_RISING_EDGE 0x00000000U
  393. #define DSI_TE_FALLING_EDGE DSI_WCFGR_TEPOL
  394. /**
  395. * @}
  396. */
  397. /** @defgroup DSI_Vsync_Polarity DSI Vsync Polarity
  398. * @{
  399. */
  400. #define DSI_VSYNC_FALLING 0x00000000U
  401. #define DSI_VSYNC_RISING DSI_WCFGR_VSPOL
  402. /**
  403. * @}
  404. */
  405. /** @defgroup DSI_AutomaticRefresh DSI Automatic Refresh
  406. * @{
  407. */
  408. #define DSI_AR_DISABLE 0x00000000U
  409. #define DSI_AR_ENABLE DSI_WCFGR_AR
  410. /**
  411. * @}
  412. */
  413. /** @defgroup DSI_TE_AcknowledgeRequest DSI TE Acknowledge Request
  414. * @{
  415. */
  416. #define DSI_TE_ACKNOWLEDGE_DISABLE 0x00000000U
  417. #define DSI_TE_ACKNOWLEDGE_ENABLE DSI_CMCR_TEARE
  418. /**
  419. * @}
  420. */
  421. /** @defgroup DSI_AcknowledgeRequest DSI Acknowledge Request
  422. * @{
  423. */
  424. #define DSI_ACKNOWLEDGE_DISABLE 0x00000000U
  425. #define DSI_ACKNOWLEDGE_ENABLE DSI_CMCR_ARE
  426. /**
  427. * @}
  428. */
  429. /** @defgroup DSI_LP_LPGenShortWriteNoP DSI LP LPGen Short Write NoP
  430. * @{
  431. */
  432. #define DSI_LP_GSW0P_DISABLE 0x00000000U
  433. #define DSI_LP_GSW0P_ENABLE DSI_CMCR_GSW0TX
  434. /**
  435. * @}
  436. */
  437. /** @defgroup DSI_LP_LPGenShortWriteOneP DSI LP LPGen Short Write OneP
  438. * @{
  439. */
  440. #define DSI_LP_GSW1P_DISABLE 0x00000000U
  441. #define DSI_LP_GSW1P_ENABLE DSI_CMCR_GSW1TX
  442. /**
  443. * @}
  444. */
  445. /** @defgroup DSI_LP_LPGenShortWriteTwoP DSI LP LPGen Short Write TwoP
  446. * @{
  447. */
  448. #define DSI_LP_GSW2P_DISABLE 0x00000000U
  449. #define DSI_LP_GSW2P_ENABLE DSI_CMCR_GSW2TX
  450. /**
  451. * @}
  452. */
  453. /** @defgroup DSI_LP_LPGenShortReadNoP DSI LP LPGen Short Read NoP
  454. * @{
  455. */
  456. #define DSI_LP_GSR0P_DISABLE 0x00000000U
  457. #define DSI_LP_GSR0P_ENABLE DSI_CMCR_GSR0TX
  458. /**
  459. * @}
  460. */
  461. /** @defgroup DSI_LP_LPGenShortReadOneP DSI LP LPGen Short Read OneP
  462. * @{
  463. */
  464. #define DSI_LP_GSR1P_DISABLE 0x00000000U
  465. #define DSI_LP_GSR1P_ENABLE DSI_CMCR_GSR1TX
  466. /**
  467. * @}
  468. */
  469. /** @defgroup DSI_LP_LPGenShortReadTwoP DSI LP LPGen Short Read TwoP
  470. * @{
  471. */
  472. #define DSI_LP_GSR2P_DISABLE 0x00000000U
  473. #define DSI_LP_GSR2P_ENABLE DSI_CMCR_GSR2TX
  474. /**
  475. * @}
  476. */
  477. /** @defgroup DSI_LP_LPGenLongWrite DSI LP LPGen LongWrite
  478. * @{
  479. */
  480. #define DSI_LP_GLW_DISABLE 0x00000000U
  481. #define DSI_LP_GLW_ENABLE DSI_CMCR_GLWTX
  482. /**
  483. * @}
  484. */
  485. /** @defgroup DSI_LP_LPDcsShortWriteNoP DSI LP LPDcs Short Write NoP
  486. * @{
  487. */
  488. #define DSI_LP_DSW0P_DISABLE 0x00000000U
  489. #define DSI_LP_DSW0P_ENABLE DSI_CMCR_DSW0TX
  490. /**
  491. * @}
  492. */
  493. /** @defgroup DSI_LP_LPDcsShortWriteOneP DSI LP LPDcs Short Write OneP
  494. * @{
  495. */
  496. #define DSI_LP_DSW1P_DISABLE 0x00000000U
  497. #define DSI_LP_DSW1P_ENABLE DSI_CMCR_DSW1TX
  498. /**
  499. * @}
  500. */
  501. /** @defgroup DSI_LP_LPDcsShortReadNoP DSI LP LPDcs Short Read NoP
  502. * @{
  503. */
  504. #define DSI_LP_DSR0P_DISABLE 0x00000000U
  505. #define DSI_LP_DSR0P_ENABLE DSI_CMCR_DSR0TX
  506. /**
  507. * @}
  508. */
  509. /** @defgroup DSI_LP_LPDcsLongWrite DSI LP LPDcs Long Write
  510. * @{
  511. */
  512. #define DSI_LP_DLW_DISABLE 0x00000000U
  513. #define DSI_LP_DLW_ENABLE DSI_CMCR_DLWTX
  514. /**
  515. * @}
  516. */
  517. /** @defgroup DSI_LP_LPMaxReadPacket DSI LP LPMax Read Packet
  518. * @{
  519. */
  520. #define DSI_LP_MRDP_DISABLE 0x00000000U
  521. #define DSI_LP_MRDP_ENABLE DSI_CMCR_MRDPS
  522. /**
  523. * @}
  524. */
  525. /** @defgroup DSI_HS_PrespMode DSI HS Presp Mode
  526. * @{
  527. */
  528. #define DSI_HS_PM_DISABLE 0x00000000U
  529. #define DSI_HS_PM_ENABLE DSI_TCCR3_PM
  530. /**
  531. * @}
  532. */
  533. /** @defgroup DSI_Automatic_Clk_Lane_Control DSI Automatic Clk Lane Control
  534. * @{
  535. */
  536. #define DSI_AUTO_CLK_LANE_CTRL_DISABLE 0x00000000U
  537. #define DSI_AUTO_CLK_LANE_CTRL_ENABLE DSI_CLCR_ACR
  538. /**
  539. * @}
  540. */
  541. /** @defgroup DSI_Number_Of_Lanes DSI Number Of Lanes
  542. * @{
  543. */
  544. #define DSI_ONE_DATA_LANE 0U
  545. #define DSI_TWO_DATA_LANES 1U
  546. /**
  547. * @}
  548. */
  549. /** @defgroup DSI_FlowControl DSI Flow Control
  550. * @{
  551. */
  552. #define DSI_FLOW_CONTROL_CRC_RX DSI_PCR_CRCRXE
  553. #define DSI_FLOW_CONTROL_ECC_RX DSI_PCR_ECCRXE
  554. #define DSI_FLOW_CONTROL_BTA DSI_PCR_BTAE
  555. #define DSI_FLOW_CONTROL_EOTP_RX DSI_PCR_ETRXE
  556. #define DSI_FLOW_CONTROL_EOTP_TX DSI_PCR_ETTXE
  557. #define DSI_FLOW_CONTROL_ALL (DSI_FLOW_CONTROL_CRC_RX | DSI_FLOW_CONTROL_ECC_RX | \
  558. DSI_FLOW_CONTROL_BTA | DSI_FLOW_CONTROL_EOTP_RX | \
  559. DSI_FLOW_CONTROL_EOTP_TX)
  560. /**
  561. * @}
  562. */
  563. /** @defgroup DSI_Color_Coding DSI Color Coding
  564. * @{
  565. */
  566. #define DSI_RGB565 0x00000000U /*!< The values 0x00000001 and 0x00000002 can also be used for the RGB565 color mode configuration */
  567. #define DSI_RGB666 0x00000003U /*!< The value 0x00000004 can also be used for the RGB666 color mode configuration */
  568. #define DSI_RGB888 0x00000005U
  569. /**
  570. * @}
  571. */
  572. /** @defgroup DSI_LooselyPacked DSI Loosely Packed
  573. * @{
  574. */
  575. #define DSI_LOOSELY_PACKED_ENABLE DSI_LCOLCR_LPE
  576. #define DSI_LOOSELY_PACKED_DISABLE 0x00000000U
  577. /**
  578. * @}
  579. */
  580. /** @defgroup DSI_HSYNC_Polarity DSI HSYNC Polarity
  581. * @{
  582. */
  583. #define DSI_HSYNC_ACTIVE_HIGH 0x00000000U
  584. #define DSI_HSYNC_ACTIVE_LOW DSI_LPCR_HSP
  585. /**
  586. * @}
  587. */
  588. /** @defgroup DSI_VSYNC_Active_Polarity DSI VSYNC Active Polarity
  589. * @{
  590. */
  591. #define DSI_VSYNC_ACTIVE_HIGH 0x00000000U
  592. #define DSI_VSYNC_ACTIVE_LOW DSI_LPCR_VSP
  593. /**
  594. * @}
  595. */
  596. /** @defgroup DSI_DATA_ENABLE_Polarity DSI DATA ENABLE Polarity
  597. * @{
  598. */
  599. #define DSI_DATA_ENABLE_ACTIVE_HIGH 0x00000000U
  600. #define DSI_DATA_ENABLE_ACTIVE_LOW DSI_LPCR_DEP
  601. /**
  602. * @}
  603. */
  604. /** @defgroup DSI_PLL_IDF DSI PLL IDF
  605. * @{
  606. */
  607. #define DSI_PLL_IN_DIV1 0x00000001U
  608. #define DSI_PLL_IN_DIV2 0x00000002U
  609. #define DSI_PLL_IN_DIV3 0x00000003U
  610. #define DSI_PLL_IN_DIV4 0x00000004U
  611. #define DSI_PLL_IN_DIV5 0x00000005U
  612. #define DSI_PLL_IN_DIV6 0x00000006U
  613. #define DSI_PLL_IN_DIV7 0x00000007U
  614. /**
  615. * @}
  616. */
  617. /** @defgroup DSI_PLL_ODF DSI PLL ODF
  618. * @{
  619. */
  620. #define DSI_PLL_OUT_DIV1 0x00000000U
  621. #define DSI_PLL_OUT_DIV2 0x00000001U
  622. #define DSI_PLL_OUT_DIV4 0x00000002U
  623. #define DSI_PLL_OUT_DIV8 0x00000003U
  624. /**
  625. * @}
  626. */
  627. /** @defgroup DSI_Flags DSI Flags
  628. * @{
  629. */
  630. #define DSI_FLAG_TE DSI_WISR_TEIF
  631. #define DSI_FLAG_ER DSI_WISR_ERIF
  632. #define DSI_FLAG_BUSY DSI_WISR_BUSY
  633. #define DSI_FLAG_PLLLS DSI_WISR_PLLLS
  634. #define DSI_FLAG_PLLL DSI_WISR_PLLLIF
  635. #define DSI_FLAG_PLLU DSI_WISR_PLLUIF
  636. #define DSI_FLAG_RRS DSI_WISR_RRS
  637. #define DSI_FLAG_RR DSI_WISR_RRIF
  638. /**
  639. * @}
  640. */
  641. /** @defgroup DSI_Interrupts DSI Interrupts
  642. * @{
  643. */
  644. #define DSI_IT_TE DSI_WIER_TEIE
  645. #define DSI_IT_ER DSI_WIER_ERIE
  646. #define DSI_IT_PLLL DSI_WIER_PLLLIE
  647. #define DSI_IT_PLLU DSI_WIER_PLLUIE
  648. #define DSI_IT_RR DSI_WIER_RRIE
  649. /**
  650. * @}
  651. */
  652. /** @defgroup DSI_SHORT_WRITE_PKT_Data_Type DSI SHORT WRITE PKT Data Type
  653. * @{
  654. */
  655. #define DSI_DCS_SHORT_PKT_WRITE_P0 0x00000005U /*!< DCS short write, no parameters */
  656. #define DSI_DCS_SHORT_PKT_WRITE_P1 0x00000015U /*!< DCS short write, one parameter */
  657. #define DSI_GEN_SHORT_PKT_WRITE_P0 0x00000003U /*!< Generic short write, no parameters */
  658. #define DSI_GEN_SHORT_PKT_WRITE_P1 0x00000013U /*!< Generic short write, one parameter */
  659. #define DSI_GEN_SHORT_PKT_WRITE_P2 0x00000023U /*!< Generic short write, two parameters */
  660. /**
  661. * @}
  662. */
  663. /** @defgroup DSI_LONG_WRITE_PKT_Data_Type DSI LONG WRITE PKT Data Type
  664. * @{
  665. */
  666. #define DSI_DCS_LONG_PKT_WRITE 0x00000039U /*!< DCS long write */
  667. #define DSI_GEN_LONG_PKT_WRITE 0x00000029U /*!< Generic long write */
  668. /**
  669. * @}
  670. */
  671. /** @defgroup DSI_SHORT_READ_PKT_Data_Type DSI SHORT READ PKT Data Type
  672. * @{
  673. */
  674. #define DSI_DCS_SHORT_PKT_READ 0x00000006U /*!< DCS short read */
  675. #define DSI_GEN_SHORT_PKT_READ_P0 0x00000004U /*!< Generic short read, no parameters */
  676. #define DSI_GEN_SHORT_PKT_READ_P1 0x00000014U /*!< Generic short read, one parameter */
  677. #define DSI_GEN_SHORT_PKT_READ_P2 0x00000024U /*!< Generic short read, two parameters */
  678. /**
  679. * @}
  680. */
  681. /** @defgroup DSI_Error_Data_Type DSI Error Data Type
  682. * @{
  683. */
  684. #define HAL_DSI_ERROR_NONE 0U
  685. #define HAL_DSI_ERROR_ACK 0x00000001U /*!< acknowledge errors */
  686. #define HAL_DSI_ERROR_PHY 0x00000002U /*!< PHY related errors */
  687. #define HAL_DSI_ERROR_TX 0x00000004U /*!< transmission error */
  688. #define HAL_DSI_ERROR_RX 0x00000008U /*!< reception error */
  689. #define HAL_DSI_ERROR_ECC 0x00000010U /*!< ECC errors */
  690. #define HAL_DSI_ERROR_CRC 0x00000020U /*!< CRC error */
  691. #define HAL_DSI_ERROR_PSE 0x00000040U /*!< Packet Size error */
  692. #define HAL_DSI_ERROR_EOT 0x00000080U /*!< End Of Transmission error */
  693. #define HAL_DSI_ERROR_OVF 0x00000100U /*!< FIFO overflow error */
  694. #define HAL_DSI_ERROR_GEN 0x00000200U /*!< Generic FIFO related errors */
  695. /**
  696. * @}
  697. */
  698. /** @defgroup DSI_Lane_Group DSI Lane Group
  699. * @{
  700. */
  701. #define DSI_CLOCK_LANE 0x00000000U
  702. #define DSI_DATA_LANES 0x00000001U
  703. /**
  704. * @}
  705. */
  706. /** @defgroup DSI_Communication_Delay DSI Communication Delay
  707. * @{
  708. */
  709. #define DSI_SLEW_RATE_HSTX 0x00000000U
  710. #define DSI_SLEW_RATE_LPTX 0x00000001U
  711. #define DSI_HS_DELAY 0x00000002U
  712. /**
  713. * @}
  714. */
  715. /** @defgroup DSI_CustomLane DSI CustomLane
  716. * @{
  717. */
  718. #define DSI_SWAP_LANE_PINS 0x00000000U
  719. #define DSI_INVERT_HS_SIGNAL 0x00000001U
  720. /**
  721. * @}
  722. */
  723. /** @defgroup DSI_Lane_Select DSI Lane Select
  724. * @{
  725. */
  726. #define DSI_CLK_LANE 0x00000000U
  727. #define DSI_DATA_LANE0 0x00000001U
  728. #define DSI_DATA_LANE1 0x00000002U
  729. /**
  730. * @}
  731. */
  732. /** @defgroup DSI_PHY_Timing DSI PHY Timing
  733. * @{
  734. */
  735. #define DSI_TCLK_POST 0x00000000U
  736. #define DSI_TLPX_CLK 0x00000001U
  737. #define DSI_THS_EXIT 0x00000002U
  738. #define DSI_TLPX_DATA 0x00000003U
  739. #define DSI_THS_ZERO 0x00000004U
  740. #define DSI_THS_TRAIL 0x00000005U
  741. #define DSI_THS_PREPARE 0x00000006U
  742. #define DSI_TCLK_ZERO 0x00000007U
  743. #define DSI_TCLK_PREPARE 0x00000008U
  744. /**
  745. * @}
  746. */
  747. /* Exported macros -----------------------------------------------------------*/
  748. /**
  749. * @brief Reset DSI handle state.
  750. * @param __HANDLE__: DSI handle
  751. * @retval None
  752. */
  753. #define __HAL_DSI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DSI_STATE_RESET)
  754. /**
  755. * @brief Enables the DSI host.
  756. * @param __HANDLE__: DSI handle
  757. * @retval None.
  758. */
  759. #define __HAL_DSI_ENABLE(__HANDLE__) do { \
  760. __IO uint32_t tmpreg = 0x00U; \
  761. SET_BIT((__HANDLE__)->Instance->CR, DSI_CR_EN);\
  762. /* Delay after an DSI Host enabling */ \
  763. tmpreg = READ_BIT((__HANDLE__)->Instance->CR, DSI_CR_EN);\
  764. UNUSED(tmpreg); \
  765. }while(0U)
  766. /**
  767. * @brief Disables the DSI host.
  768. * @param __HANDLE__: DSI handle
  769. * @retval None.
  770. */
  771. #define __HAL_DSI_DISABLE(__HANDLE__) do { \
  772. __IO uint32_t tmpreg = 0x00U; \
  773. CLEAR_BIT((__HANDLE__)->Instance->CR, DSI_CR_EN);\
  774. /* Delay after an DSI Host disabling */ \
  775. tmpreg = READ_BIT((__HANDLE__)->Instance->CR, DSI_CR_EN);\
  776. UNUSED(tmpreg); \
  777. }while(0U)
  778. /**
  779. * @brief Enables the DSI wrapper.
  780. * @param __HANDLE__: DSI handle
  781. * @retval None.
  782. */
  783. #define __HAL_DSI_WRAPPER_ENABLE(__HANDLE__) do { \
  784. __IO uint32_t tmpreg = 0x00U; \
  785. SET_BIT((__HANDLE__)->Instance->WCR, DSI_WCR_DSIEN);\
  786. /* Delay after an DSI warpper enabling */ \
  787. tmpreg = READ_BIT((__HANDLE__)->Instance->WCR, DSI_WCR_DSIEN);\
  788. UNUSED(tmpreg); \
  789. }while(0U)
  790. /**
  791. * @brief Disable the DSI wrapper.
  792. * @param __HANDLE__: DSI handle
  793. * @retval None.
  794. */
  795. #define __HAL_DSI_WRAPPER_DISABLE(__HANDLE__) do { \
  796. __IO uint32_t tmpreg = 0x00U; \
  797. CLEAR_BIT((__HANDLE__)->Instance->WCR, DSI_WCR_DSIEN);\
  798. /* Delay after an DSI warpper disabling*/ \
  799. tmpreg = READ_BIT((__HANDLE__)->Instance->WCR, DSI_WCR_DSIEN);\
  800. UNUSED(tmpreg); \
  801. }while(0U)
  802. /**
  803. * @brief Enables the DSI PLL.
  804. * @param __HANDLE__: DSI handle
  805. * @retval None.
  806. */
  807. #define __HAL_DSI_PLL_ENABLE(__HANDLE__) do { \
  808. __IO uint32_t tmpreg = 0x00U; \
  809. SET_BIT((__HANDLE__)->Instance->WRPCR, DSI_WRPCR_PLLEN);\
  810. /* Delay after an DSI PLL enabling */ \
  811. tmpreg = READ_BIT((__HANDLE__)->Instance->WRPCR, DSI_WRPCR_PLLEN);\
  812. UNUSED(tmpreg); \
  813. }while(0U)
  814. /**
  815. * @brief Disables the DSI PLL.
  816. * @param __HANDLE__: DSI handle
  817. * @retval None.
  818. */
  819. #define __HAL_DSI_PLL_DISABLE(__HANDLE__) do { \
  820. __IO uint32_t tmpreg = 0x00U; \
  821. CLEAR_BIT((__HANDLE__)->Instance->WRPCR, DSI_WRPCR_PLLEN);\
  822. /* Delay after an DSI PLL disabling */ \
  823. tmpreg = READ_BIT((__HANDLE__)->Instance->WRPCR, DSI_WRPCR_PLLEN);\
  824. UNUSED(tmpreg); \
  825. }while(0U)
  826. /**
  827. * @brief Enables the DSI regulator.
  828. * @param __HANDLE__: DSI handle
  829. * @retval None.
  830. */
  831. #define __HAL_DSI_REG_ENABLE(__HANDLE__) do { \
  832. __IO uint32_t tmpreg = 0x00U; \
  833. SET_BIT((__HANDLE__)->Instance->WRPCR, DSI_WRPCR_REGEN);\
  834. /* Delay after an DSI regulator enabling */ \
  835. tmpreg = READ_BIT((__HANDLE__)->Instance->WRPCR, DSI_WRPCR_REGEN);\
  836. UNUSED(tmpreg); \
  837. }while(0U)
  838. /**
  839. * @brief Disables the DSI regulator.
  840. * @param __HANDLE__: DSI handle
  841. * @retval None.
  842. */
  843. #define __HAL_DSI_REG_DISABLE(__HANDLE__) do { \
  844. __IO uint32_t tmpreg = 0x00U; \
  845. CLEAR_BIT((__HANDLE__)->Instance->WRPCR, DSI_WRPCR_REGEN);\
  846. /* Delay after an DSI regulator disabling */ \
  847. tmpreg = READ_BIT((__HANDLE__)->Instance->WRPCR, DSI_WRPCR_REGEN);\
  848. UNUSED(tmpreg); \
  849. }while(0U)
  850. /**
  851. * @brief Get the DSI pending flags.
  852. * @param __HANDLE__: DSI handle.
  853. * @param __FLAG__: Get the specified flag.
  854. * This parameter can be any combination of the following values:
  855. * @arg DSI_FLAG_TE : Tearing Effect Interrupt Flag
  856. * @arg DSI_FLAG_ER : End of Refresh Interrupt Flag
  857. * @arg DSI_FLAG_BUSY : Busy Flag
  858. * @arg DSI_FLAG_PLLLS: PLL Lock Status
  859. * @arg DSI_FLAG_PLLL : PLL Lock Interrupt Flag
  860. * @arg DSI_FLAG_PLLU : PLL Unlock Interrupt Flag
  861. * @arg DSI_FLAG_RRS : Regulator Ready Flag
  862. * @arg DSI_FLAG_RR : Regulator Ready Interrupt Flag
  863. * @retval The state of FLAG (SET or RESET).
  864. */
  865. #define __HAL_DSI_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->WISR & (__FLAG__))
  866. /**
  867. * @brief Clears the DSI pending flags.
  868. * @param __HANDLE__: DSI handle.
  869. * @param __FLAG__: specifies the flag to clear.
  870. * This parameter can be any combination of the following values:
  871. * @arg DSI_FLAG_TE : Tearing Effect Interrupt Flag
  872. * @arg DSI_FLAG_ER : End of Refresh Interrupt Flag
  873. * @arg DSI_FLAG_PLLL : PLL Lock Interrupt Flag
  874. * @arg DSI_FLAG_PLLU : PLL Unlock Interrupt Flag
  875. * @arg DSI_FLAG_RR : Regulator Ready Interrupt Flag
  876. * @retval None
  877. */
  878. #define __HAL_DSI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->WIFCR = (__FLAG__))
  879. /**
  880. * @brief Enables the specified DSI interrupts.
  881. * @param __HANDLE__: DSI handle.
  882. * @param __INTERRUPT__: specifies the DSI interrupt sources to be enabled.
  883. * This parameter can be any combination of the following values:
  884. * @arg DSI_IT_TE : Tearing Effect Interrupt
  885. * @arg DSI_IT_ER : End of Refresh Interrupt
  886. * @arg DSI_IT_PLLL: PLL Lock Interrupt
  887. * @arg DSI_IT_PLLU: PLL Unlock Interrupt
  888. * @arg DSI_IT_RR : Regulator Ready Interrupt
  889. * @retval None
  890. */
  891. #define __HAL_DSI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->WIER |= (__INTERRUPT__))
  892. /**
  893. * @brief Disables the specified DSI interrupts.
  894. * @param __HANDLE__: DSI handle
  895. * @param __INTERRUPT__: specifies the DSI interrupt sources to be disabled.
  896. * This parameter can be any combination of the following values:
  897. * @arg DSI_IT_TE : Tearing Effect Interrupt
  898. * @arg DSI_IT_ER : End of Refresh Interrupt
  899. * @arg DSI_IT_PLLL: PLL Lock Interrupt
  900. * @arg DSI_IT_PLLU: PLL Unlock Interrupt
  901. * @arg DSI_IT_RR : Regulator Ready Interrupt
  902. * @retval None
  903. */
  904. #define __HAL_DSI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->WIER &= ~(__INTERRUPT__))
  905. /**
  906. * @brief Checks whether the specified DSI interrupt source is enabled or not.
  907. * @param __HANDLE__: DSI handle
  908. * @param __INTERRUPT__: specifies the DSI interrupt source to check.
  909. * This parameter can be one of the following values:
  910. * @arg DSI_IT_TE : Tearing Effect Interrupt
  911. * @arg DSI_IT_ER : End of Refresh Interrupt
  912. * @arg DSI_IT_PLLL: PLL Lock Interrupt
  913. * @arg DSI_IT_PLLU: PLL Unlock Interrupt
  914. * @arg DSI_IT_RR : Regulator Ready Interrupt
  915. * @retval The state of INTERRUPT (SET or RESET).
  916. */
  917. #define __HAL_DSI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->WIER & (__INTERRUPT__))
  918. /* Exported functions --------------------------------------------------------*/
  919. /** @defgroup DSI_Exported_Functions DSI Exported Functions
  920. * @{
  921. */
  922. HAL_StatusTypeDef HAL_DSI_Init(DSI_HandleTypeDef *hdsi, DSI_PLLInitTypeDef *PLLInit);
  923. HAL_StatusTypeDef HAL_DSI_DeInit(DSI_HandleTypeDef *hdsi);
  924. void HAL_DSI_MspInit(DSI_HandleTypeDef *hdsi);
  925. void HAL_DSI_MspDeInit(DSI_HandleTypeDef *hdsi);
  926. void HAL_DSI_IRQHandler(DSI_HandleTypeDef *hdsi);
  927. void HAL_DSI_TearingEffectCallback(DSI_HandleTypeDef *hdsi);
  928. void HAL_DSI_EndOfRefreshCallback(DSI_HandleTypeDef *hdsi);
  929. void HAL_DSI_ErrorCallback(DSI_HandleTypeDef *hdsi);
  930. HAL_StatusTypeDef HAL_DSI_SetGenericVCID(DSI_HandleTypeDef *hdsi, uint32_t VirtualChannelID);
  931. HAL_StatusTypeDef HAL_DSI_ConfigVideoMode(DSI_HandleTypeDef *hdsi, DSI_VidCfgTypeDef *VidCfg);
  932. HAL_StatusTypeDef HAL_DSI_ConfigAdaptedCommandMode(DSI_HandleTypeDef *hdsi, DSI_CmdCfgTypeDef *CmdCfg);
  933. HAL_StatusTypeDef HAL_DSI_ConfigCommand(DSI_HandleTypeDef *hdsi, DSI_LPCmdTypeDef *LPCmd);
  934. HAL_StatusTypeDef HAL_DSI_ConfigFlowControl(DSI_HandleTypeDef *hdsi, uint32_t FlowControl);
  935. HAL_StatusTypeDef HAL_DSI_ConfigPhyTimer(DSI_HandleTypeDef *hdsi, DSI_PHY_TimerTypeDef *PhyTimers);
  936. HAL_StatusTypeDef HAL_DSI_ConfigHostTimeouts(DSI_HandleTypeDef *hdsi, DSI_HOST_TimeoutTypeDef *HostTimeouts);
  937. HAL_StatusTypeDef HAL_DSI_Start(DSI_HandleTypeDef *hdsi);
  938. HAL_StatusTypeDef HAL_DSI_Stop(DSI_HandleTypeDef *hdsi);
  939. HAL_StatusTypeDef HAL_DSI_Refresh(DSI_HandleTypeDef *hdsi);
  940. HAL_StatusTypeDef HAL_DSI_ColorMode(DSI_HandleTypeDef *hdsi, uint32_t ColorMode);
  941. HAL_StatusTypeDef HAL_DSI_Shutdown(DSI_HandleTypeDef *hdsi, uint32_t Shutdown);
  942. HAL_StatusTypeDef HAL_DSI_ShortWrite(DSI_HandleTypeDef *hdsi,
  943. uint32_t ChannelID,
  944. uint32_t Mode,
  945. uint32_t Param1,
  946. uint32_t Param2);
  947. HAL_StatusTypeDef HAL_DSI_LongWrite(DSI_HandleTypeDef *hdsi,
  948. uint32_t ChannelID,
  949. uint32_t Mode,
  950. uint32_t NbParams,
  951. uint32_t Param1,
  952. uint8_t* ParametersTable);
  953. HAL_StatusTypeDef HAL_DSI_Read(DSI_HandleTypeDef *hdsi,
  954. uint32_t ChannelNbr,
  955. uint8_t* Array,
  956. uint32_t Size,
  957. uint32_t Mode,
  958. uint32_t DCSCmd,
  959. uint8_t* ParametersTable);
  960. HAL_StatusTypeDef HAL_DSI_EnterULPMData(DSI_HandleTypeDef *hdsi);
  961. HAL_StatusTypeDef HAL_DSI_ExitULPMData(DSI_HandleTypeDef *hdsi);
  962. HAL_StatusTypeDef HAL_DSI_EnterULPM(DSI_HandleTypeDef *hdsi);
  963. HAL_StatusTypeDef HAL_DSI_ExitULPM(DSI_HandleTypeDef *hdsi);
  964. HAL_StatusTypeDef HAL_DSI_PatternGeneratorStart(DSI_HandleTypeDef *hdsi, uint32_t Mode, uint32_t Orientation);
  965. HAL_StatusTypeDef HAL_DSI_PatternGeneratorStop(DSI_HandleTypeDef *hdsi);
  966. HAL_StatusTypeDef HAL_DSI_SetSlewRateAndDelayTuning(DSI_HandleTypeDef *hdsi, uint32_t CommDelay, uint32_t Lane, uint32_t Value);
  967. HAL_StatusTypeDef HAL_DSI_SetLowPowerRXFilter(DSI_HandleTypeDef *hdsi, uint32_t Frequency);
  968. HAL_StatusTypeDef HAL_DSI_SetSDD(DSI_HandleTypeDef *hdsi, FunctionalState State);
  969. HAL_StatusTypeDef HAL_DSI_SetLanePinsConfiguration(DSI_HandleTypeDef *hdsi, uint32_t CustomLane, uint32_t Lane, FunctionalState State);
  970. HAL_StatusTypeDef HAL_DSI_SetPHYTimings(DSI_HandleTypeDef *hdsi, uint32_t Timing, FunctionalState State, uint32_t Value);
  971. HAL_StatusTypeDef HAL_DSI_ForceTXStopMode(DSI_HandleTypeDef *hdsi, uint32_t Lane, FunctionalState State);
  972. HAL_StatusTypeDef HAL_DSI_ForceRXLowPower(DSI_HandleTypeDef *hdsi, FunctionalState State);
  973. HAL_StatusTypeDef HAL_DSI_ForceDataLanesInRX(DSI_HandleTypeDef *hdsi, FunctionalState State);
  974. HAL_StatusTypeDef HAL_DSI_SetPullDown(DSI_HandleTypeDef *hdsi, FunctionalState State);
  975. HAL_StatusTypeDef HAL_DSI_SetContentionDetectionOff(DSI_HandleTypeDef *hdsi, FunctionalState State);
  976. uint32_t HAL_DSI_GetError(DSI_HandleTypeDef *hdsi);
  977. HAL_StatusTypeDef HAL_DSI_ConfigErrorMonitor(DSI_HandleTypeDef *hdsi, uint32_t ActiveErrors);
  978. HAL_DSI_StateTypeDef HAL_DSI_GetState(DSI_HandleTypeDef *hdsi);
  979. /**
  980. * @}
  981. */
  982. /* Private types -------------------------------------------------------------*/
  983. /** @defgroup DSI_Private_Types DSI Private Types
  984. * @{
  985. */
  986. /**
  987. * @}
  988. */
  989. /* Private defines -----------------------------------------------------------*/
  990. /** @defgroup DSI_Private_Defines DSI Private Defines
  991. * @{
  992. */
  993. /**
  994. * @}
  995. */
  996. /* Private variables ---------------------------------------------------------*/
  997. /** @defgroup DSI_Private_Variables DSI Private Variables
  998. * @{
  999. */
  1000. /**
  1001. * @}
  1002. */
  1003. /* Private constants ---------------------------------------------------------*/
  1004. /** @defgroup DSI_Private_Constants DSI Private Constants
  1005. * @{
  1006. */
  1007. #define DSI_MAX_RETURN_PKT_SIZE (0x00000037U) /*!< Maximum return packet configuration */
  1008. /**
  1009. * @}
  1010. */
  1011. /* Private macros ------------------------------------------------------------*/
  1012. /** @defgroup DSI_Private_Macros DSI Private Macros
  1013. * @{
  1014. */
  1015. #define IS_DSI_PLL_NDIV(NDIV) ((10U <= (NDIV)) && ((NDIV) <= 125U))
  1016. #define IS_DSI_PLL_IDF(IDF) (((IDF) == DSI_PLL_IN_DIV1) || \
  1017. ((IDF) == DSI_PLL_IN_DIV2) || \
  1018. ((IDF) == DSI_PLL_IN_DIV3) || \
  1019. ((IDF) == DSI_PLL_IN_DIV4) || \
  1020. ((IDF) == DSI_PLL_IN_DIV5) || \
  1021. ((IDF) == DSI_PLL_IN_DIV6) || \
  1022. ((IDF) == DSI_PLL_IN_DIV7))
  1023. #define IS_DSI_PLL_ODF(ODF) (((ODF) == DSI_PLL_OUT_DIV1) || \
  1024. ((ODF) == DSI_PLL_OUT_DIV2) || \
  1025. ((ODF) == DSI_PLL_OUT_DIV4) || \
  1026. ((ODF) == DSI_PLL_OUT_DIV8))
  1027. #define IS_DSI_AUTO_CLKLANE_CONTROL(AutoClkLane) (((AutoClkLane) == DSI_AUTO_CLK_LANE_CTRL_DISABLE) || ((AutoClkLane) == DSI_AUTO_CLK_LANE_CTRL_ENABLE))
  1028. #define IS_DSI_NUMBER_OF_LANES(NumberOfLanes) (((NumberOfLanes) == DSI_ONE_DATA_LANE) || ((NumberOfLanes) == DSI_TWO_DATA_LANES))
  1029. #define IS_DSI_FLOW_CONTROL(FlowControl) (((FlowControl) | DSI_FLOW_CONTROL_ALL) == DSI_FLOW_CONTROL_ALL)
  1030. #define IS_DSI_COLOR_CODING(ColorCoding) ((ColorCoding) <= 5U)
  1031. #define IS_DSI_LOOSELY_PACKED(LooselyPacked) (((LooselyPacked) == DSI_LOOSELY_PACKED_ENABLE) || ((LooselyPacked) == DSI_LOOSELY_PACKED_DISABLE))
  1032. #define IS_DSI_DE_POLARITY(DataEnable) (((DataEnable) == DSI_DATA_ENABLE_ACTIVE_HIGH) || ((DataEnable) == DSI_DATA_ENABLE_ACTIVE_LOW))
  1033. #define IS_DSI_VSYNC_POLARITY(VSYNC) (((VSYNC) == DSI_VSYNC_ACTIVE_HIGH) || ((VSYNC) == DSI_VSYNC_ACTIVE_LOW))
  1034. #define IS_DSI_HSYNC_POLARITY(HSYNC) (((HSYNC) == DSI_HSYNC_ACTIVE_HIGH) || ((HSYNC) == DSI_HSYNC_ACTIVE_LOW))
  1035. #define IS_DSI_VIDEO_MODE_TYPE(VideoModeType) (((VideoModeType) == DSI_VID_MODE_NB_PULSES) || \
  1036. ((VideoModeType) == DSI_VID_MODE_NB_EVENTS) || \
  1037. ((VideoModeType) == DSI_VID_MODE_BURST))
  1038. #define IS_DSI_COLOR_MODE(ColorMode) (((ColorMode) == DSI_COLOR_MODE_FULL) || ((ColorMode) == DSI_COLOR_MODE_EIGHT))
  1039. #define IS_DSI_SHUT_DOWN(ShutDown) (((ShutDown) == DSI_DISPLAY_ON) || ((ShutDown) == DSI_DISPLAY_OFF))
  1040. #define IS_DSI_LP_COMMAND(LPCommand) (((LPCommand) == DSI_LP_COMMAND_DISABLE) || ((LPCommand) == DSI_LP_COMMAND_ENABLE))
  1041. #define IS_DSI_LP_HFP(LPHFP) (((LPHFP) == DSI_LP_HFP_DISABLE) || ((LPHFP) == DSI_LP_HFP_ENABLE))
  1042. #define IS_DSI_LP_HBP(LPHBP) (((LPHBP) == DSI_LP_HBP_DISABLE) || ((LPHBP) == DSI_LP_HBP_ENABLE))
  1043. #define IS_DSI_LP_VACTIVE(LPVActive) (((LPVActive) == DSI_LP_VACT_DISABLE) || ((LPVActive) == DSI_LP_VACT_ENABLE))
  1044. #define IS_DSI_LP_VFP(LPVFP) (((LPVFP) == DSI_LP_VFP_DISABLE) || ((LPVFP) == DSI_LP_VFP_ENABLE))
  1045. #define IS_DSI_LP_VBP(LPVBP) (((LPVBP) == DSI_LP_VBP_DISABLE) || ((LPVBP) == DSI_LP_VBP_ENABLE))
  1046. #define IS_DSI_LP_VSYNC(LPVSYNC) (((LPVSYNC) == DSI_LP_VSYNC_DISABLE) || ((LPVSYNC) == DSI_LP_VSYNC_ENABLE))
  1047. #define IS_DSI_FBTAA(FrameBTAAcknowledge) (((FrameBTAAcknowledge) == DSI_FBTAA_DISABLE) || ((FrameBTAAcknowledge) == DSI_FBTAA_ENABLE))
  1048. #define IS_DSI_TE_SOURCE(TESource) (((TESource) == DSI_TE_DSILINK) || ((TESource) == DSI_TE_EXTERNAL))
  1049. #define IS_DSI_TE_POLARITY(TEPolarity) (((TEPolarity) == DSI_TE_RISING_EDGE) || ((TEPolarity) == DSI_TE_FALLING_EDGE))
  1050. #define IS_DSI_AUTOMATIC_REFRESH(AutomaticRefresh) (((AutomaticRefresh) == DSI_AR_DISABLE) || ((AutomaticRefresh) == DSI_AR_ENABLE))
  1051. #define IS_DSI_VS_POLARITY(VSPolarity) (((VSPolarity) == DSI_VSYNC_FALLING) || ((VSPolarity) == DSI_VSYNC_RISING))
  1052. #define IS_DSI_TE_ACK_REQUEST(TEAcknowledgeRequest) (((TEAcknowledgeRequest) == DSI_TE_ACKNOWLEDGE_DISABLE) || ((TEAcknowledgeRequest) == DSI_TE_ACKNOWLEDGE_ENABLE))
  1053. #define IS_DSI_ACK_REQUEST(AcknowledgeRequest) (((AcknowledgeRequest) == DSI_ACKNOWLEDGE_DISABLE) || ((AcknowledgeRequest) == DSI_ACKNOWLEDGE_ENABLE))
  1054. #define IS_DSI_LP_GSW0P(LP_GSW0P) (((LP_GSW0P) == DSI_LP_GSW0P_DISABLE) || ((LP_GSW0P) == DSI_LP_GSW0P_ENABLE))
  1055. #define IS_DSI_LP_GSW1P(LP_GSW1P) (((LP_GSW1P) == DSI_LP_GSW1P_DISABLE) || ((LP_GSW1P) == DSI_LP_GSW1P_ENABLE))
  1056. #define IS_DSI_LP_GSW2P(LP_GSW2P) (((LP_GSW2P) == DSI_LP_GSW2P_DISABLE) || ((LP_GSW2P) == DSI_LP_GSW2P_ENABLE))
  1057. #define IS_DSI_LP_GSR0P(LP_GSR0P) (((LP_GSR0P) == DSI_LP_GSR0P_DISABLE) || ((LP_GSR0P) == DSI_LP_GSR0P_ENABLE))
  1058. #define IS_DSI_LP_GSR1P(LP_GSR1P) (((LP_GSR1P) == DSI_LP_GSR1P_DISABLE) || ((LP_GSR1P) == DSI_LP_GSR1P_ENABLE))
  1059. #define IS_DSI_LP_GSR2P(LP_GSR2P) (((LP_GSR2P) == DSI_LP_GSR2P_DISABLE) || ((LP_GSR2P) == DSI_LP_GSR2P_ENABLE))
  1060. #define IS_DSI_LP_GLW(LP_GLW) (((LP_GLW) == DSI_LP_GLW_DISABLE) || ((LP_GLW) == DSI_LP_GLW_ENABLE))
  1061. #define IS_DSI_LP_DSW0P(LP_DSW0P) (((LP_DSW0P) == DSI_LP_DSW0P_DISABLE) || ((LP_DSW0P) == DSI_LP_DSW0P_ENABLE))
  1062. #define IS_DSI_LP_DSW1P(LP_DSW1P) (((LP_DSW1P) == DSI_LP_DSW1P_DISABLE) || ((LP_DSW1P) == DSI_LP_DSW1P_ENABLE))
  1063. #define IS_DSI_LP_DSR0P(LP_DSR0P) (((LP_DSR0P) == DSI_LP_DSR0P_DISABLE) || ((LP_DSR0P) == DSI_LP_DSR0P_ENABLE))
  1064. #define IS_DSI_LP_DLW(LP_DLW) (((LP_DLW) == DSI_LP_DLW_DISABLE) || ((LP_DLW) == DSI_LP_DLW_ENABLE))
  1065. #define IS_DSI_LP_MRDP(LP_MRDP) (((LP_MRDP) == DSI_LP_MRDP_DISABLE) || ((LP_MRDP) == DSI_LP_MRDP_ENABLE))
  1066. #define IS_DSI_SHORT_WRITE_PACKET_TYPE(MODE) (((MODE) == DSI_DCS_SHORT_PKT_WRITE_P0) || \
  1067. ((MODE) == DSI_DCS_SHORT_PKT_WRITE_P1) || \
  1068. ((MODE) == DSI_GEN_SHORT_PKT_WRITE_P0) || \
  1069. ((MODE) == DSI_GEN_SHORT_PKT_WRITE_P1) || \
  1070. ((MODE) == DSI_GEN_SHORT_PKT_WRITE_P2))
  1071. #define IS_DSI_LONG_WRITE_PACKET_TYPE(MODE) (((MODE) == DSI_DCS_LONG_PKT_WRITE) || \
  1072. ((MODE) == DSI_GEN_LONG_PKT_WRITE))
  1073. #define IS_DSI_READ_PACKET_TYPE(MODE) (((MODE) == DSI_DCS_SHORT_PKT_READ) || \
  1074. ((MODE) == DSI_GEN_SHORT_PKT_READ_P0) || \
  1075. ((MODE) == DSI_GEN_SHORT_PKT_READ_P1) || \
  1076. ((MODE) == DSI_GEN_SHORT_PKT_READ_P2))
  1077. #define IS_DSI_COMMUNICATION_DELAY(CommDelay) (((CommDelay) == DSI_SLEW_RATE_HSTX) || ((CommDelay) == DSI_SLEW_RATE_LPTX) || ((CommDelay) == DSI_HS_DELAY))
  1078. #define IS_DSI_LANE_GROUP(Lane) (((Lane) == DSI_CLOCK_LANE) || ((Lane) == DSI_DATA_LANES))
  1079. #define IS_DSI_CUSTOM_LANE(CustomLane) (((CustomLane) == DSI_SWAP_LANE_PINS) || ((CustomLane) == DSI_INVERT_HS_SIGNAL))
  1080. #define IS_DSI_LANE(Lane) (((Lane) == DSI_CLOCK_LANE) || ((Lane) == DSI_DATA_LANE0) || ((Lane) == DSI_DATA_LANE1))
  1081. #define IS_DSI_PHY_TIMING(Timing) (((Timing) == DSI_TCLK_POST ) || \
  1082. ((Timing) == DSI_TLPX_CLK ) || \
  1083. ((Timing) == DSI_THS_EXIT ) || \
  1084. ((Timing) == DSI_TLPX_DATA ) || \
  1085. ((Timing) == DSI_THS_ZERO ) || \
  1086. ((Timing) == DSI_THS_TRAIL ) || \
  1087. ((Timing) == DSI_THS_PREPARE ) || \
  1088. ((Timing) == DSI_TCLK_ZERO ) || \
  1089. ((Timing) == DSI_TCLK_PREPARE))
  1090. /**
  1091. * @}
  1092. */
  1093. /* Private functions prototypes ----------------------------------------------*/
  1094. /** @defgroup DSI_Private_Functions_Prototypes DSI Private Functions Prototypes
  1095. * @{
  1096. */
  1097. /**
  1098. * @}
  1099. */
  1100. /* Private functions ---------------------------------------------------------*/
  1101. /** @defgroup DSI_Private_Functions DSI Private Functions
  1102. * @{
  1103. */
  1104. /**
  1105. * @}
  1106. */
  1107. /**
  1108. * @}
  1109. */
  1110. /**
  1111. * @}
  1112. */
  1113. #endif /* DSI */
  1114. #ifdef __cplusplus
  1115. }
  1116. #endif
  1117. #endif /* __STM32L4xx_HAL_DSI_H */
  1118. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/