st7735_reg.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /**
  2. ******************************************************************************
  3. * @file st7735_reg.h
  4. * @author MCD Application Team
  5. * @brief This file contains all the functions prototypes for the st7735_regs.c
  6. * driver.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef ST7735_REG_H
  22. #define ST7735_REG_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include <stdint.h>
  28. /** @addtogroup BSP
  29. * @{
  30. */
  31. /** @addtogroup Components
  32. * @{
  33. */
  34. /** @defgroup ST7735_REG ST7735 Registers
  35. * @{
  36. */
  37. /** @defgroup ST7735_REG_Exported_Constants Exported Constants
  38. * @{
  39. */
  40. /**
  41. * @brief ST7735 Registers
  42. */
  43. #define ST7735_NOP 0x00U /* No Operation: NOP */
  44. #define ST7735_SW_RESET 0x01U /* Software reset: SWRESET */
  45. #define ST7735_READ_ID 0x04U /* Read Display ID: RDDID */
  46. #define ST7735_READ_STATUS 0x09U /* Read Display Statu: RDDST */
  47. #define ST7735_READ_POWER_MODE 0x0AU /* Read Display Power: RDDPM */
  48. #define ST7735_READ_MADCTL 0x0BU /* Read Display: RDDMADCTL */
  49. #define ST7735_READ_PIXEL_FORMAT 0x0CU /* Read Display Pixel: RDDCOLMOD */
  50. #define ST7735_READ_IMAGE_MODE 0x0DU /* Read Display Image: RDDIM */
  51. #define ST7735_READ_SIGNAL_MODE 0x0EU /* Read Display Signal: RDDSM */
  52. #define ST7735_SLEEP_IN 0x10U /* Sleep in & booster off: SLPIN */
  53. #define ST7735_SLEEP_OUT 0x11U /* Sleep out & booster on: SLPOUT */
  54. #define ST7735_PARTIAL_DISPLAY_ON 0x12U /* Partial mode on: PTLON */
  55. #define ST7735_NORMAL_DISPLAY_OFF 0x13U /* Partial off (Normal): NORON */
  56. #define ST7735_DISPLAY_INVERSION_OFF 0x20U /* Display inversion off: INVOFF */
  57. #define ST7735_DISPLAY_INVERSION_ON 0x21U /* Display inversion on: INVON */
  58. #define ST7735_GAMMA_SET 0x26U /* Gamma curve select: GAMSET */
  59. #define ST7735_DISPLAY_OFF 0x28U /* Display off: DISPOFF */
  60. #define ST7735_DISPLAY_ON 0x29U /* Display on: DISPON */
  61. #define ST7735_CASET 0x2AU /* Column address set: CASET */
  62. #define ST7735_RASET 0x2BU /* Row address set: RASET */
  63. #define ST7735_WRITE_RAM 0x2CU /* Memory write: RAMWR */
  64. #define ST7735_RGBSET 0x2DU /* LUT for 4k,65k,262k color: RGBSET */
  65. #define ST7735_READ_RAM 0x2EU /* Memory read: RAMRD */
  66. #define ST7735_PTLAR 0x30U /* Partial start/end address set: PTLAR */
  67. #define ST7735_TE_LINE_OFF 0x34U /* Tearing effect line off: TEOFF */
  68. #define ST7735_TE_LINE_ON 0x35U /* Tearing effect mode set & on: TEON */
  69. #define ST7735_MADCTL 0x36U /* Memory data access control: MADCTL */
  70. #define ST7735_IDLE_MODE_OFF 0x38U /* Idle mode off: IDMOFF */
  71. #define ST7735_IDLE_MODE_ON 0x39U /* Idle mode on: IDMON */
  72. #define ST7735_COLOR_MODE 0x3AU /* Interface pixel format: COLMOD */
  73. #define ST7735_FRAME_RATE_CTRL1 0xB1U /* In normal mode (Full colors): FRMCTR1 */
  74. #define ST7735_FRAME_RATE_CTRL2 0xB2U /* In Idle mode (8-colors): FRMCTR2 */
  75. #define ST7735_FRAME_RATE_CTRL3 0xB3U /* In partial mode + Full colors: FRMCTR3 */
  76. #define ST7735_FRAME_INVERSION_CTRL 0xB4U /* Display inversion control: INVCTR */
  77. #define ST7735_DISPLAY_SETTING 0xB6U /* Display function setting */
  78. #define ST7735_PWR_CTRL1 0xC0U /* Power control setting: PWCTR1 */
  79. #define ST7735_PWR_CTRL2 0xC1U /* Power control setting: PWCTR2 */
  80. #define ST7735_PWR_CTRL3 0xC2U /* In normal mode (Full colors): PWCTR3 */
  81. #define ST7735_PWR_CTRL4 0xC3U /* In Idle mode (8-colors): PWCTR4 */
  82. #define ST7735_PWR_CTRL5 0xC4U /* In partial mode + Full colors: PWCTR5 */
  83. #define ST7735_VCOMH_VCOML_CTRL1 0xC5U /* VCOM control 1: VMCTR1 */
  84. #define ST7735_VMOF_CTRL 0xC7U /* Set VCOM offset control: VMOFCTR */
  85. #define ST7735_WRID2 0xD1U /* Set LCM version code: WRID2 */
  86. #define ST7735_WRID3 0xD2U /* Customer Project code: WRID3 */
  87. #define ST7735_NV_CTRL1 0xD9U /* NVM control status: NVCTR1 */
  88. #define ST7735_READ_ID1 0xDAU /* Read ID1: RDID1 */
  89. #define ST7735_READ_ID2 0xDBU /* Read ID2: RDID2 */
  90. #define ST7735_READ_ID3 0xDCU /* Read ID3: RDID3 */
  91. #define ST7735_NV_CTRL2 0xDEU /* NVM Read Command: NVCTR2 */
  92. #define ST7735_NV_CTRL3 0xDFU /* NVM Write Command: NVCTR3 */
  93. #define ST7735_PV_GAMMA_CTRL 0xE0U /* Set Gamma adjustment (+ polarity): GAMCTRP1 */
  94. #define ST7735_NV_GAMMA_CTRL 0xE1U /* Set Gamma adjustment (- polarity): GAMCTRN1 */
  95. #define ST7735_EXT_CTRL 0xF0U /* Extension command control */
  96. #define ST7735_PWR_CTRL6 0xFCU /* In partial mode + Idle mode: PWCTR6 */
  97. #define ST7735_VCOM4_LEVEL 0xFFU /* VCOM 4 level control */
  98. /**
  99. * @}
  100. */
  101. /** @defgroup ST7735_REG_Exported_Types Exported Types
  102. * @{
  103. */
  104. typedef int32_t (*ST7735_Write_Func)(void *, uint8_t, uint8_t*, uint32_t);
  105. typedef int32_t (*ST7735_Read_Func) (void *, uint8_t, uint8_t*);
  106. typedef int32_t (*ST7735_Send_Func) (void *, uint8_t*, uint32_t);
  107. typedef int32_t (*ST7735_Recv_Func) (void *, uint8_t*, uint32_t);
  108. typedef struct
  109. {
  110. ST7735_Write_Func WriteReg;
  111. ST7735_Read_Func ReadReg;
  112. ST7735_Send_Func SendData;
  113. ST7735_Recv_Func RecvData;
  114. void *handle;
  115. } st7735_ctx_t;
  116. /**
  117. * @}
  118. */
  119. /** @defgroup ST7735_REG_Exported_Functions Exported Functions
  120. * @{
  121. */
  122. int32_t st7735_write_reg(st7735_ctx_t *ctx, uint8_t reg, uint8_t *pdata, uint32_t length);
  123. int32_t st7735_read_reg(st7735_ctx_t *ctx, uint8_t reg, uint8_t *pdata);
  124. int32_t st7735_send_data(st7735_ctx_t *ctx, uint8_t *pdata, uint32_t length);
  125. int32_t st7735_recv_data(st7735_ctx_t *ctx, uint8_t *pdata, uint32_t length);
  126. /**
  127. * @}
  128. */
  129. #ifdef __cplusplus
  130. }
  131. #endif
  132. #endif /* ST7735_REG_H */
  133. /**
  134. * @}
  135. */
  136. /**
  137. * @}
  138. */
  139. /**
  140. * @}
  141. */
  142. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/