lib_lcd.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /**
  2. ******************************************************************************
  3. * @file lib_lcd.h
  4. * @author Application Team
  5. * @version V4.5.0
  6. * @date 2019-05-14
  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 SEGx IO typedef */
  20. typedef struct
  21. {
  22. __IO uint32_t *GPIO;
  23. uint16_t Pin;
  24. }LCD_SEGIO;
  25. /* LCD COMx IO typedef */
  26. typedef struct
  27. {
  28. __IO uint32_t *GPIO;
  29. uint16_t Pin;
  30. }LCD_COMIO;
  31. typedef struct
  32. {
  33. uint32_t Type;
  34. uint32_t Drv;
  35. uint32_t FRQ;
  36. uint32_t SWPR;
  37. uint32_t FBMODE;
  38. uint32_t BKFILL;
  39. } LCD_InitType;
  40. //Type
  41. #define LCD_TYPE_4COM LCD_CTRL_TYPE_4COM
  42. #define LCD_TYPE_6COM LCD_CTRL_TYPE_6COM
  43. #define LCD_TYPE_8COM LCD_CTRL_TYPE_8COM
  44. //DrivingRes
  45. #define LCD_DRV_300 LCD_CTRL_DRV_300KOHM
  46. #define LCD_DRV_600 LCD_CTRL_DRV_600KOHM
  47. #define LCD_DRV_150 LCD_CTRL_DRV_150KOHM
  48. #define LCD_DRV_200 LCD_CTRL_DRV_200KOHM
  49. //ScanFRQ
  50. #define LCD_FRQ_64H LCD_CTRL_FRQ_64HZ
  51. #define LCD_FRQ_128H LCD_CTRL_FRQ_128HZ
  52. #define LCD_FRQ_256H LCD_CTRL_FRQ_256HZ
  53. #define LCD_FRQ_512H LCD_CTRL_FRQ_512HZ
  54. //SwitchMode
  55. #define LCD_FBMODE_BUFA LCD_CTRL2_FBMODE_BUFA
  56. #define LCD_FBMODE_BUFAB LCD_CTRL2_FBMODE_BUFAANDBUFB
  57. #define LCD_FBMODE_BUFABLANK LCD_CTRL2_FBMODE_BUFAANDBLANK
  58. //BlankFill
  59. #define LCD_BKFILL_1 LCD_CTRL2_BKFILL
  60. #define LCD_BKFILL_0 0
  61. //ComMode
  62. #define LCD_COMMOD_4COM 1
  63. #define LCD_COMMOD_6COM 3
  64. #define LCD_COMMOD_8COM 7
  65. //BiasSelection
  66. #define LCD_BMODE_DIV3 0
  67. #define LCD_BMODE_DIV4 ANA_REG6_LCD_BMODE
  68. //VLCDSelection
  69. #define LCD_VLCD_0 0
  70. #define LCD_VLCD_INC60MV 1
  71. #define LCD_VLCD_INC120MV 2
  72. #define LCD_VLCD_INC180MV 3
  73. #define LCD_VLCD_INC240MV 4
  74. #define LCD_VLCD_INC300MV 5
  75. #define LCD_VLCD_DEC60MV 6
  76. #define LCD_VLCD_DEC120MV 7
  77. #define LCD_VLCD_DEC180MV 8
  78. #define LCD_VLCD_DEC240MV 9
  79. #define LCD_VLCD_DEC300MV 10
  80. #define LCD_VLCD_DEC360MV 11
  81. #define LCD_VLCD_DEC420MV 12
  82. #define LCD_VLCD_DEC480MV 13
  83. #define LCD_VLCD_DEC540MV 14
  84. #define LCD_VLCD_DEC600MV 15
  85. /* Private macros ------------------------------------------------------------*/
  86. #define IS_LCD_TYPE(__TYPE__) (((__TYPE__) == LCD_TYPE_4COM) ||\
  87. ((__TYPE__) == LCD_TYPE_6COM) ||\
  88. ((__TYPE__) == LCD_TYPE_8COM))
  89. #define IS_LCD_DRV(__DRV__) (((__DRV__) == LCD_DRV_300) ||\
  90. ((__DRV__) == LCD_DRV_600) ||\
  91. ((__DRV__) == LCD_DRV_150) ||\
  92. ((__DRV__) == LCD_DRV_200))
  93. #define IS_LCD_FRQ(__FRQ__) (((__FRQ__) == LCD_FRQ_64H) ||\
  94. ((__FRQ__) == LCD_FRQ_128H) ||\
  95. ((__FRQ__) == LCD_FRQ_256H) ||\
  96. ((__FRQ__) == LCD_FRQ_512H))
  97. #define IS_LCD_SWPR(__SWPR__) ((__SWPR__) <= 0xFFUL)
  98. #define IS_LCD_FBMODE(__FBMODE__) (((__FBMODE__) == LCD_FBMODE_BUFA) ||\
  99. ((__FBMODE__) == LCD_FBMODE_BUFAB) ||\
  100. ((__FBMODE__) == LCD_FBMODE_BUFABLANK))
  101. #define IS_LCD_BKFILL(__BKFILL__) (((__BKFILL__) == LCD_BKFILL_1) || ((__BKFILL__) == LCD_BKFILL_0))
  102. #define IS_LCD_BMODE(__BMODE__) (((__BMODE__) == LCD_BMODE_DIV3) ||\
  103. ((__BMODE__) == LCD_BMODE_DIV4))
  104. #define IS_LCD_COMMOD(__COMMOD__) (((__COMMOD__) == LCD_COMMOD_4COM) ||\
  105. ((__COMMOD__) == LCD_COMMOD_6COM) ||\
  106. ((__COMMOD__) == LCD_COMMOD_8COM))
  107. #define IS_LCD_VLCD(__VLCD__) (((__VLCD__) == LCD_VLCD_0) ||\
  108. ((__VLCD__) == LCD_VLCD_INC60MV) ||\
  109. ((__VLCD__) == LCD_VLCD_INC120MV) ||\
  110. ((__VLCD__) == LCD_VLCD_INC180MV) ||\
  111. ((__VLCD__) == LCD_VLCD_INC240MV) ||\
  112. ((__VLCD__) == LCD_VLCD_INC300MV) ||\
  113. ((__VLCD__) == LCD_VLCD_DEC60MV) ||\
  114. ((__VLCD__) == LCD_VLCD_DEC120MV) ||\
  115. ((__VLCD__) == LCD_VLCD_DEC180MV) ||\
  116. ((__VLCD__) == LCD_VLCD_DEC240MV) ||\
  117. ((__VLCD__) == LCD_VLCD_DEC300MV) ||\
  118. ((__VLCD__) == LCD_VLCD_DEC360MV) ||\
  119. ((__VLCD__) == LCD_VLCD_DEC420MV) ||\
  120. ((__VLCD__) == LCD_VLCD_DEC480MV) ||\
  121. ((__VLCD__) == LCD_VLCD_DEC540MV) ||\
  122. ((__VLCD__) == LCD_VLCD_DEC600MV))
  123. /* Exported Functions ------------------------------------------------------- */
  124. /* LCD Exported Functions Group1:
  125. (De)Initialization -------------------------*/
  126. void LCD_DeInit(void);
  127. void LCD_StructInit(LCD_InitType *LCD_InitStruct);
  128. void LCD_Init(LCD_InitType *InitStruct);
  129. /* LCD Exported Functions Group1:
  130. MISC Configuration -------------------------*/
  131. void LCD_Cmd(uint32_t NewState);
  132. void LCD_IOConfig(uint32_t ComMode, uint32_t SEGVal0, uint32_t SEGVal1, uint16_t SEGVal2, uint32_t NewState);
  133. void LCD_SetSEG(uint32_t SegCtrl0, uint32_t SegCtrl1, uint16_t SegCtrl2);
  134. void LCD_BiasModeConfig(uint32_t BiasSelection);
  135. uint32_t LCD_VoltageConfig(uint32_t VLCDSelection);
  136. #ifdef __cplusplus
  137. }
  138. #endif
  139. #endif /* __LIB_LCD_H */
  140. /*********************************** END OF FILE ******************************/