You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

1338 regels
54 KiB

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