lib_lcd.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. ******************************************************************************
  3. * @file lib_lcd.h
  4. * @author Application Team
  5. * @version V1.1.0
  6. * @date 2019-10-28
  7. * @brief LCD library.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. ******************************************************************************
  12. */
  13. #ifndef __LIB_LCD_H
  14. #define __LIB_LCD_H
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "target.h"
  19. /* LCD COMx IO typedef */
  20. typedef struct
  21. {
  22. __IO uint32_t *GPIO;
  23. uint16_t Pin;
  24. }LCD_COMIO;
  25. typedef struct
  26. {
  27. uint32_t Type;
  28. uint32_t Drv;
  29. uint32_t FRQ;
  30. uint32_t SWPR;
  31. uint32_t FBMODE;
  32. uint32_t BKFILL;
  33. } LCD_InitType;
  34. typedef struct
  35. {
  36. uint32_t SegCtrl0;
  37. uint32_t SegCtrl1;
  38. uint16_t SegCtrl2;
  39. uint32_t COMMode;
  40. } LCD_IOInitType;
  41. /************** Bits definition for ANA_REG6 register ******************/
  42. #define ANA_REG6_VLCD_0 (0x0U << ANA_REG6_VLCD_Pos)
  43. #define ANA_REG6_VLCD_1 (0x1U << ANA_REG6_VLCD_Pos)
  44. #define ANA_REG6_VLCD_2 (0x2U << ANA_REG6_VLCD_Pos)
  45. #define ANA_REG6_VLCD_3 (0x3U << ANA_REG6_VLCD_Pos)
  46. #define ANA_REG6_VLCD_4 (0x4U << ANA_REG6_VLCD_Pos)
  47. #define ANA_REG6_VLCD_5 (0x5U << ANA_REG6_VLCD_Pos)
  48. #define ANA_REG6_VLCD_6 (0x6U << ANA_REG6_VLCD_Pos)
  49. #define ANA_REG6_VLCD_7 (0x7U << ANA_REG6_VLCD_Pos)
  50. #define ANA_REG6_VLCD_8 (0x8U << ANA_REG6_VLCD_Pos)
  51. #define ANA_REG6_VLCD_9 (0x9U << ANA_REG6_VLCD_Pos)
  52. #define ANA_REG6_VLCD_A (0xAU << ANA_REG6_VLCD_Pos)
  53. #define ANA_REG6_VLCD_B (0xBU << ANA_REG6_VLCD_Pos)
  54. #define ANA_REG6_VLCD_C (0xCU << ANA_REG6_VLCD_Pos)
  55. #define ANA_REG6_VLCD_D (0xDU << ANA_REG6_VLCD_Pos)
  56. #define ANA_REG6_VLCD_E (0xEU << ANA_REG6_VLCD_Pos)
  57. #define ANA_REG6_VLCD_F (0xFU << ANA_REG6_VLCD_Pos)
  58. /************** Bits definition for LCD_CTRL register ******************/
  59. /************** Bits definition for LCD_CTRL2 register ******************/
  60. //Type
  61. #define LCD_TYPE_4COM (0x0U << LCD_CTRL_TYPE_Pos) /*!< 0x00000000 */
  62. #define LCD_TYPE_6COM (0x1U << LCD_CTRL_TYPE_Pos) /*!< 0x00000010 */
  63. #define LCD_TYPE_8COM (0x2U << LCD_CTRL_TYPE_Pos) /*!< 0x00000020 */
  64. #define IS_LCD_TYPE(__TYPE__) (((__TYPE__) == LCD_TYPE_4COM) ||\
  65. ((__TYPE__) == LCD_TYPE_6COM) ||\
  66. ((__TYPE__) == LCD_TYPE_8COM))
  67. //DrivingRes
  68. #define LCD_DRV_300 (0x0U << LCD_CTRL_DRV_Pos) /*!< 0x00000000 */
  69. #define LCD_DRV_600 (0x1U << LCD_CTRL_DRV_Pos) /*!< 0x00000004 */
  70. #define LCD_DRV_150 (0x2U << LCD_CTRL_DRV_Pos) /*!< 0x00000008 */
  71. #define LCD_DRV_200 (0x3U << LCD_CTRL_DRV_Pos) /*!< 0x0000000C */
  72. #define IS_LCD_DRV(__DRV__) (((__DRV__) == LCD_DRV_300) ||\
  73. ((__DRV__) == LCD_DRV_600) ||\
  74. ((__DRV__) == LCD_DRV_150) ||\
  75. ((__DRV__) == LCD_DRV_200))
  76. //ScanFRQ
  77. #define LCD_FRQ_64H (0x0U << LCD_CTRL_FRQ_Pos) /*!< 0x00000000 */
  78. #define LCD_FRQ_128H (0x1U << LCD_CTRL_FRQ_Pos) /*!< 0x00000001 */
  79. #define LCD_FRQ_256H (0x2U << LCD_CTRL_FRQ_Pos) /*!< 0x00000002 */
  80. #define LCD_FRQ_512H (0x3U << LCD_CTRL_FRQ_Pos) /*!< 0x00000003 */
  81. #define IS_LCD_FRQ(__FRQ__) (((__FRQ__) == LCD_FRQ_64H) ||\
  82. ((__FRQ__) == LCD_FRQ_128H) ||\
  83. ((__FRQ__) == LCD_FRQ_256H) ||\
  84. ((__FRQ__) == LCD_FRQ_512H))
  85. #define IS_LCD_SWPR(__SWPR__) ((__SWPR__) <= 0xFFUL)
  86. //SwitchMode
  87. #define LCD_FBMODE_BUFA (0x0U << LCD_CTRL2_FBMODE_Pos) /*!< 0x00000000 */
  88. #define LCD_FBMODE_BUFAB (0x1U << LCD_CTRL2_FBMODE_Pos) /*!< 0x00000040 */
  89. #define LCD_FBMODE_BUFABLANK (0x2U << LCD_CTRL2_FBMODE_Pos) /*!< 0x00000080 */
  90. #define IS_LCD_FBMODE(__FBMODE__) (((__FBMODE__) == LCD_FBMODE_BUFA) ||\
  91. ((__FBMODE__) == LCD_FBMODE_BUFAB) ||\
  92. ((__FBMODE__) == LCD_FBMODE_BUFABLANK))
  93. //BlankFill
  94. #define LCD_BKFILL_1 LCD_CTRL2_BKFILL
  95. #define LCD_BKFILL_0 0
  96. #define IS_LCD_BKFILL(__BKFILL__) (((__BKFILL__) == LCD_BKFILL_1) || ((__BKFILL__) == LCD_BKFILL_0))
  97. //ComMode
  98. #define LCD_COMMOD_4COM 1
  99. #define LCD_COMMOD_6COM 3
  100. #define LCD_COMMOD_8COM 7
  101. #define IS_LCD_COMMOD(__COMMOD__) (((__COMMOD__) == LCD_COMMOD_4COM) ||\
  102. ((__COMMOD__) == LCD_COMMOD_6COM) ||\
  103. ((__COMMOD__) == LCD_COMMOD_8COM))
  104. //BiasSelection
  105. #define LCD_BMODE_DIV3 0
  106. #define LCD_BMODE_DIV4 ANA_REG6_LCDBMODE
  107. #define IS_LCD_BMODE(__BMODE__) (((__BMODE__) == LCD_BMODE_DIV3) ||\
  108. ((__BMODE__) == LCD_BMODE_DIV4))
  109. /****************************** LCD Instances *********************************/
  110. #define IS_LCD_ALL_INSTANCE(INSTANCE) ((INSTANCE) == LCD)
  111. /* Exported Functions ------------------------------------------------------- */
  112. /* LCD Exported Functions Group1:
  113. (De)Initialization -------------------------*/
  114. void LCD_DeInit(void);
  115. void LCD_StructInit(LCD_InitType *LCD_InitStruct);
  116. void LCD_Init(LCD_InitType *InitStruct);
  117. /* LCD Exported Functions Group1:
  118. MISC Configuration -------------------------*/
  119. void LCD_Cmd(LCD_IOInitType *IOInitType, uint32_t NewState);
  120. void LCD_BiasModeConfig(uint32_t BiasSelection);
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124. #endif /* __LIB_LCD_H */
  125. /*********************************** END OF FILE ******************************/