stm32f4xx_hal_dsi.h 49 KB

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