air105_lcdi.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (c) 2022 OpenLuat & AirM2M
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. * this software and associated documentation files (the "Software"), to deal in
  6. * the Software without restriction, including without limitation the rights to
  7. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  8. * the Software, and to permit persons to whom the Software is furnished to do so,
  9. * subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in all
  12. * copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  16. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  17. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  18. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. */
  21. #ifndef __AIR105_LCDI_H
  22. #define __AIR105_LCDI_H
  23. #ifdef __cplusplus
  24. extern "C"
  25. {
  26. #endif
  27. #include "air105.h"
  28. #define LCDI_CMD (0)
  29. #define LCDI_DAT (1)
  30. #define LCDI_MODE_6800 (0)
  31. #define LCDI_MODE_8080 (1)
  32. #define LCD_CMD_BUFF_SIZE (64)
  33. #define LCD_READ_BUFF_SIZE (512)
  34. #define LCD_WRITE_BUFF_SIZE (512)
  35. //LCD module
  36. #define LCDI_FIFO_OV_IE (1 << 12)
  37. #define LCDI_FIFO_RST (1 << 11)
  38. #define LCDI_WR_DMA_EN (1 << 10)
  39. #define LCDI_WR_FIFO_EN (1 << 9)
  40. #define LCDI_CTRL_AUTO_READ (1 << 8)
  41. #define LCDI_CTRL_TYPE_8080 (1 << 7)
  42. #define LCDI_CTRL_EN_RD (1 << 6)
  43. #define LCDI_CTRL_RW_WR (1 << 5)
  44. #define LCDI_CTRL_CD (1 << 4)
  45. #define LCDI_CTRL_WIDTH_4BIT (1 << 3)
  46. #define LCDI_CTRL_AUTO (1 << 2)
  47. #define LCDI_CTRL_RD_IE (1 << 1)
  48. #define LCDI_CTRL_WR_IE (1 << 0)
  49. #define LCDI_STATUS_READY (1 << 2)
  50. #define LCDI_STATUS_RD_IS (1 << 1)
  51. #define LCDI_STATUS_WR_IS (1 << 0)
  52. #define RNG_BUF_IS_FULL(pBuf) ((pBuf)->u32Tail == (pBuf)->u32Head)
  53. #define RNG_BUF_NEXT_HEAD(pBuf) (((pBuf)->u32Head + 1) % ((pBuf)->u32BuffSize))
  54. #define RNG_BUF_NEXT_TAIL(pBuf) (((pBuf)->u32Tail + 1) % ((pBuf)->u32BuffSize))
  55. #define RNG_BUF_LEN(pBuf) (((pBuf)->u32Tail + (pBuf)->u32BuffSize - 1 - (pBuf)->u32Head) % (pBuf)->u32BuffSize)
  56. #define RNG_BUF_PERI_TAIL(pBuf) (((pBuf)->u32Tail + (pBuf)->u32BuffSize - 1) % ((pBuf)->u32BuffSize))
  57. typedef struct
  58. {
  59. uint32_t volatile u32Head;
  60. uint32_t volatile u32Tail;
  61. uint32_t volatile u32BuffSize;
  62. uint32_t volatile u32Stat;
  63. uint8_t volatile *pu8Buff;
  64. } RNG_BUF8, *RNG_BUF8_ID;
  65. typedef struct
  66. {
  67. uint32_t volatile u32Head;
  68. uint32_t volatile u32Tail;
  69. uint32_t volatile u32BuffSize;
  70. uint32_t volatile u32Stat;
  71. uint32_t volatile *pu32Buff;
  72. } RNG_BUF32, *RNG_BUF32_ID;
  73. typedef struct
  74. {
  75. uint8_t lcd_ReadBuff[LCD_READ_BUFF_SIZE];
  76. uint8_t lcd_WriteBuff[LCD_WRITE_BUFF_SIZE];
  77. uint32_t lcd_CmdBuff[LCD_CMD_BUFF_SIZE];
  78. RNG_BUF8 rbRead;
  79. RNG_BUF8 rbWrite;
  80. RNG_BUF32 rbCmd;
  81. RNG_BUF32_ID prbCmd;
  82. RNG_BUF8_ID prbRead;
  83. RNG_BUF8_ID prbWrite;
  84. volatile uint32_t u32OpCount;
  85. } RING_BUF;
  86. typedef struct
  87. {
  88. uint8_t LCD_BusMode; //Bus mode(8080/6800)
  89. uint8_t LCD_IntRead; //Read interrupt Enable
  90. uint8_t LCD_IntWrite; //Read interrupt Enable
  91. uint8_t fifo_level;
  92. uint32_t LCD_MaxQTR; //Max qaurter cylce of read/write.
  93. uint32_t fifo_ov_ie_enable;
  94. uint32_t fifo_rst_enable;
  95. uint32_t wr_dma_enable;
  96. uint32_t wr_fifo_enable;
  97. uint32_t opt;
  98. RING_BUF ring_buf;
  99. } LCD_InitTypeDef;
  100. //Operate the bus signal
  101. void LCD_BusRead(LCD_TypeDef *LCDx,uint8_t u8CD);
  102. void LCD_BusWrite(LCD_TypeDef *LCDx,uint8_t u8CD, uint8_t value);
  103. void LCD_Read(LCD_TypeDef *LCDx,uint8_t u8CD, uint8_t *dat);
  104. void LCD_Write(LCD_TypeDef *LCDx,uint8_t u8CD, uint8_t u8Value);
  105. //Buffer mode only can used in interrupt mode.
  106. int32_t LCD_ReadBuff(LCD_TypeDef *LCDx, LCD_InitTypeDef *pLcdInit, uint8_t *pu8Buff, uint32_t u32BuffLen);
  107. int32_t LCD_WriteBuff(LCD_TypeDef *LCDx, LCD_InitTypeDef *pLcdInit, uint8_t *pu8Buff, uint32_t u32BuffLen);
  108. void LCD_Init(LCD_TypeDef *LCDx, LCD_InitTypeDef *pLcdInit);
  109. void LCD_FIFODMAconfig(LCD_TypeDef *LCDx, LCD_InitTypeDef *LCD_InitType);
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif
  114. /************************** (C) COPYRIGHT Megahunt *****END OF FILE****/