WILLY BAYOT / stm32_adafruit

Dependents:   TDEMNucleo

Committer:
willybayot
Date:
Sun Jan 04 13:25:59 2015 +0000
Revision:
0:4db361f2e6d5
ADAFRUIT revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
willybayot 0:4db361f2e6d5 1 /**
willybayot 0:4db361f2e6d5 2 ******************************************************************************
willybayot 0:4db361f2e6d5 3 * @file st7735.h
willybayot 0:4db361f2e6d5 4 * @author MCD Application Team
willybayot 0:4db361f2e6d5 5 * @version V1.0.0
willybayot 0:4db361f2e6d5 6 * @date 22-April-2014
willybayot 0:4db361f2e6d5 7 * @brief This file contains all the functions prototypes for the st7735.c
willybayot 0:4db361f2e6d5 8 * driver.
willybayot 0:4db361f2e6d5 9 ******************************************************************************
willybayot 0:4db361f2e6d5 10 * @attention
willybayot 0:4db361f2e6d5 11 *
willybayot 0:4db361f2e6d5 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
willybayot 0:4db361f2e6d5 13 *
willybayot 0:4db361f2e6d5 14 * Redistribution and use in source and binary forms, with or without modification,
willybayot 0:4db361f2e6d5 15 * are permitted provided that the following conditions are met:
willybayot 0:4db361f2e6d5 16 * 1. Redistributions of source code must retain the above copyright notice,
willybayot 0:4db361f2e6d5 17 * this list of conditions and the following disclaimer.
willybayot 0:4db361f2e6d5 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
willybayot 0:4db361f2e6d5 19 * this list of conditions and the following disclaimer in the documentation
willybayot 0:4db361f2e6d5 20 * and/or other materials provided with the distribution.
willybayot 0:4db361f2e6d5 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
willybayot 0:4db361f2e6d5 22 * may be used to endorse or promote products derived from this software
willybayot 0:4db361f2e6d5 23 * without specific prior written permission.
willybayot 0:4db361f2e6d5 24 *
willybayot 0:4db361f2e6d5 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
willybayot 0:4db361f2e6d5 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
willybayot 0:4db361f2e6d5 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
willybayot 0:4db361f2e6d5 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
willybayot 0:4db361f2e6d5 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
willybayot 0:4db361f2e6d5 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
willybayot 0:4db361f2e6d5 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
willybayot 0:4db361f2e6d5 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
willybayot 0:4db361f2e6d5 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
willybayot 0:4db361f2e6d5 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
willybayot 0:4db361f2e6d5 35 *
willybayot 0:4db361f2e6d5 36 ******************************************************************************
willybayot 0:4db361f2e6d5 37 */
willybayot 0:4db361f2e6d5 38
willybayot 0:4db361f2e6d5 39 /* Define to prevent recursive inclusion -------------------------------------*/
willybayot 0:4db361f2e6d5 40 #ifndef __ST7735_H
willybayot 0:4db361f2e6d5 41 #define __ST7735_H
willybayot 0:4db361f2e6d5 42
willybayot 0:4db361f2e6d5 43 #ifdef __cplusplus
willybayot 0:4db361f2e6d5 44 extern "C" {
willybayot 0:4db361f2e6d5 45 #endif
willybayot 0:4db361f2e6d5 46
willybayot 0:4db361f2e6d5 47 /* Includes ------------------------------------------------------------------*/
willybayot 0:4db361f2e6d5 48 #include "lcd.h"
willybayot 0:4db361f2e6d5 49
willybayot 0:4db361f2e6d5 50 /** @addtogroup BSP
willybayot 0:4db361f2e6d5 51 * @{
willybayot 0:4db361f2e6d5 52 */
willybayot 0:4db361f2e6d5 53
willybayot 0:4db361f2e6d5 54 /** @addtogroup Components
willybayot 0:4db361f2e6d5 55 * @{
willybayot 0:4db361f2e6d5 56 */
willybayot 0:4db361f2e6d5 57
willybayot 0:4db361f2e6d5 58 /** @addtogroup ST7735
willybayot 0:4db361f2e6d5 59 * @{
willybayot 0:4db361f2e6d5 60 */
willybayot 0:4db361f2e6d5 61
willybayot 0:4db361f2e6d5 62 /** @defgroup ST7735_Exported_Types
willybayot 0:4db361f2e6d5 63 * @{
willybayot 0:4db361f2e6d5 64 */
willybayot 0:4db361f2e6d5 65
willybayot 0:4db361f2e6d5 66 /**
willybayot 0:4db361f2e6d5 67 * @}
willybayot 0:4db361f2e6d5 68 */
willybayot 0:4db361f2e6d5 69
willybayot 0:4db361f2e6d5 70 /** @defgroup ST7735_Exported_Constants
willybayot 0:4db361f2e6d5 71 * @{
willybayot 0:4db361f2e6d5 72 */
willybayot 0:4db361f2e6d5 73
willybayot 0:4db361f2e6d5 74 /**
willybayot 0:4db361f2e6d5 75 * @brief ST7735 Size
willybayot 0:4db361f2e6d5 76 */
willybayot 0:4db361f2e6d5 77 #define ST7735_LCD_PIXEL_WIDTH ((uint16_t)128)
willybayot 0:4db361f2e6d5 78 #define ST7735_LCD_PIXEL_HEIGHT ((uint16_t)160)
willybayot 0:4db361f2e6d5 79
willybayot 0:4db361f2e6d5 80 /**
willybayot 0:4db361f2e6d5 81 * @brief ST7735 Registers
willybayot 0:4db361f2e6d5 82 */
willybayot 0:4db361f2e6d5 83 #define LCD_REG_0 0x00 /* No Operation: NOP */
willybayot 0:4db361f2e6d5 84 #define LCD_REG_1 0x01 /* Software reset: SWRESET */
willybayot 0:4db361f2e6d5 85 #define LCD_REG_4 0x04 /* Read Display ID: RDDID */
willybayot 0:4db361f2e6d5 86 #define LCD_REG_9 0x09 /* Read Display Statu: RDDST */
willybayot 0:4db361f2e6d5 87 #define LCD_REG_10 0x0A /* Read Display Power: RDDPM */
willybayot 0:4db361f2e6d5 88 #define LCD_REG_11 0x0B /* Read Display: RDDMADCTL */
willybayot 0:4db361f2e6d5 89 #define LCD_REG_12 0x0C /* Read Display Pixel: RDDCOLMOD */
willybayot 0:4db361f2e6d5 90 #define LCD_REG_13 0x0D /* Read Display Image: RDDIM */
willybayot 0:4db361f2e6d5 91 #define LCD_REG_14 0x0E /* Read Display Signal: RDDSM */
willybayot 0:4db361f2e6d5 92 #define LCD_REG_16 0x10 /* Sleep in & booster off: SLPIN */
willybayot 0:4db361f2e6d5 93 #define LCD_REG_17 0x11 /* Sleep out & booster on: SLPOUT */
willybayot 0:4db361f2e6d5 94 #define LCD_REG_18 0x12 /* Partial mode on: PTLON */
willybayot 0:4db361f2e6d5 95 #define LCD_REG_19 0x13 /* Partial off (Normal): NORON */
willybayot 0:4db361f2e6d5 96 #define LCD_REG_32 0x20 /* Display inversion off: INVOFF */
willybayot 0:4db361f2e6d5 97 #define LCD_REG_33 0x21 /* Display inversion on: INVON */
willybayot 0:4db361f2e6d5 98 #define LCD_REG_38 0x26 /* Gamma curve select: GAMSET */
willybayot 0:4db361f2e6d5 99 #define LCD_REG_40 0x28 /* Display off: DISPOFF */
willybayot 0:4db361f2e6d5 100 #define LCD_REG_41 0x29 /* Display on: DISPON */
willybayot 0:4db361f2e6d5 101 #define LCD_REG_42 0x2A /* Column address set: CASET */
willybayot 0:4db361f2e6d5 102 #define LCD_REG_43 0x2B /* Row address set: RASET */
willybayot 0:4db361f2e6d5 103 #define LCD_REG_44 0x2C /* Memory write: RAMWR */
willybayot 0:4db361f2e6d5 104 #define LCD_REG_45 0x2D /* LUT for 4k,65k,262k color: RGBSET */
willybayot 0:4db361f2e6d5 105 #define LCD_REG_46 0x2E /* Memory read: RAMRD*/
willybayot 0:4db361f2e6d5 106 #define LCD_REG_48 0x30 /* Partial start/end address set: PTLAR */
willybayot 0:4db361f2e6d5 107 #define LCD_REG_52 0x34 /* Tearing effect line off: TEOFF */
willybayot 0:4db361f2e6d5 108 #define LCD_REG_53 0x35 /* Tearing effect mode set & on: TEON */
willybayot 0:4db361f2e6d5 109 #define LCD_REG_54 0x36 /* Memory data access control: MADCTL */
willybayot 0:4db361f2e6d5 110 #define LCD_REG_56 0x38 /* Idle mode off: IDMOFF */
willybayot 0:4db361f2e6d5 111 #define LCD_REG_57 0x39 /* Idle mode on: IDMON */
willybayot 0:4db361f2e6d5 112 #define LCD_REG_58 0x3A /* Interface pixel format: COLMOD */
willybayot 0:4db361f2e6d5 113 #define LCD_REG_177 0xB1 /* In normal mode (Full colors): FRMCTR1 */
willybayot 0:4db361f2e6d5 114 #define LCD_REG_178 0xB2 /* In Idle mode (8-colors): FRMCTR2 */
willybayot 0:4db361f2e6d5 115 #define LCD_REG_179 0xB3 /* In partial mode + Full colors: FRMCTR3 */
willybayot 0:4db361f2e6d5 116 #define LCD_REG_180 0xB4 /* Display inversion control: INVCTR */
willybayot 0:4db361f2e6d5 117 #define LCD_REG_192 0xC0 /* Power control setting: PWCTR1 */
willybayot 0:4db361f2e6d5 118 #define LCD_REG_193 0xC1 /* Power control setting: PWCTR2 */
willybayot 0:4db361f2e6d5 119 #define LCD_REG_194 0xC2 /* In normal mode (Full colors): PWCTR3 */
willybayot 0:4db361f2e6d5 120 #define LCD_REG_195 0xC3 /* In Idle mode (8-colors): PWCTR4 */
willybayot 0:4db361f2e6d5 121 #define LCD_REG_196 0xC4 /* In partial mode + Full colors: PWCTR5 */
willybayot 0:4db361f2e6d5 122 #define LCD_REG_197 0xC5 /* VCOM control 1: VMCTR1 */
willybayot 0:4db361f2e6d5 123 #define LCD_REG_199 0xC7 /* Set VCOM offset control: VMOFCTR */
willybayot 0:4db361f2e6d5 124 #define LCD_REG_209 0xD1 /* Set LCM version code: WRID2 */
willybayot 0:4db361f2e6d5 125 #define LCD_REG_210 0xD2 /* Customer Project code: WRID3 */
willybayot 0:4db361f2e6d5 126 #define LCD_REG_217 0xD9 /* NVM control status: NVCTR1 */
willybayot 0:4db361f2e6d5 127 #define LCD_REG_218 0xDA /* Read ID1: RDID1 */
willybayot 0:4db361f2e6d5 128 #define LCD_REG_219 0xDB /* Read ID2: RDID2 */
willybayot 0:4db361f2e6d5 129 #define LCD_REG_220 0xDC /* Read ID3: RDID3 */
willybayot 0:4db361f2e6d5 130 #define LCD_REG_222 0xDE /* NVM Read Command: NVCTR2 */
willybayot 0:4db361f2e6d5 131 #define LCD_REG_223 0xDF /* NVM Write Command: NVCTR3 */
willybayot 0:4db361f2e6d5 132 #define LCD_REG_224 0xE0 /* Set Gamma adjustment (+ polarity): GAMCTRP1 */
willybayot 0:4db361f2e6d5 133 #define LCD_REG_225 0xE1 /* Set Gamma adjustment (- polarity): GAMCTRN1 */
willybayot 0:4db361f2e6d5 134
willybayot 0:4db361f2e6d5 135 /**
willybayot 0:4db361f2e6d5 136 * @brief LCD Lines depending on the chosen fonts.
willybayot 0:4db361f2e6d5 137 */
willybayot 0:4db361f2e6d5 138 #define LCD_LINE_0 LINE(0)
willybayot 0:4db361f2e6d5 139 #define LCD_LINE_1 LINE(1)
willybayot 0:4db361f2e6d5 140 #define LCD_LINE_2 LINE(2)
willybayot 0:4db361f2e6d5 141 #define LCD_LINE_3 LINE(3)
willybayot 0:4db361f2e6d5 142 #define LCD_LINE_4 LINE(4)
willybayot 0:4db361f2e6d5 143 #define LCD_LINE_5 LINE(5)
willybayot 0:4db361f2e6d5 144 #define LCD_LINE_6 LINE(6)
willybayot 0:4db361f2e6d5 145 #define LCD_LINE_7 LINE(7)
willybayot 0:4db361f2e6d5 146 #define LCD_LINE_8 LINE(8)
willybayot 0:4db361f2e6d5 147 #define LCD_LINE_9 LINE(9)
willybayot 0:4db361f2e6d5 148 #define LCD_LINE_10 LINE(10)
willybayot 0:4db361f2e6d5 149 #define LCD_LINE_11 LINE(11)
willybayot 0:4db361f2e6d5 150 #define LCD_LINE_12 LINE(12)
willybayot 0:4db361f2e6d5 151 #define LCD_LINE_13 LINE(13)
willybayot 0:4db361f2e6d5 152 #define LCD_LINE_14 LINE(14)
willybayot 0:4db361f2e6d5 153 #define LCD_LINE_15 LINE(15)
willybayot 0:4db361f2e6d5 154 #define LCD_LINE_16 LINE(16)
willybayot 0:4db361f2e6d5 155 #define LCD_LINE_17 LINE(17)
willybayot 0:4db361f2e6d5 156 #define LCD_LINE_18 LINE(18)
willybayot 0:4db361f2e6d5 157 #define LCD_LINE_19 LINE(19)
willybayot 0:4db361f2e6d5 158
willybayot 0:4db361f2e6d5 159 /**
willybayot 0:4db361f2e6d5 160 * @}
willybayot 0:4db361f2e6d5 161 */
willybayot 0:4db361f2e6d5 162
willybayot 0:4db361f2e6d5 163 /** @defgroup ADAFRUIT_SPI_LCD_Exported_Functions
willybayot 0:4db361f2e6d5 164 * @{
willybayot 0:4db361f2e6d5 165 */
willybayot 0:4db361f2e6d5 166 void st7735_Init(void);
willybayot 0:4db361f2e6d5 167 uint16_t st7735_ReadID(void);
willybayot 0:4db361f2e6d5 168
willybayot 0:4db361f2e6d5 169 void st7735_DisplayOn(void);
willybayot 0:4db361f2e6d5 170 void st7735_DisplayOff(void);
willybayot 0:4db361f2e6d5 171 void st7735_SetCursor(uint16_t Xpos, uint16_t Ypos);
willybayot 0:4db361f2e6d5 172 void st7735_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code);
willybayot 0:4db361f2e6d5 173 void st7735_WriteReg(uint8_t LCDReg, uint8_t LCDRegValue);
willybayot 0:4db361f2e6d5 174 uint8_t st7735_ReadReg(uint8_t LCDReg);
willybayot 0:4db361f2e6d5 175
willybayot 0:4db361f2e6d5 176 void st7735_DrawHLine(uint16_t RGB_Code, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
willybayot 0:4db361f2e6d5 177 void st7735_DrawVLine(uint16_t RGB_Code, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
willybayot 0:4db361f2e6d5 178
willybayot 0:4db361f2e6d5 179 uint16_t st7735_GetLcdPixelWidth(void);
willybayot 0:4db361f2e6d5 180 uint16_t st7735_GetLcdPixelHeight(void);
willybayot 0:4db361f2e6d5 181
willybayot 0:4db361f2e6d5 182 /* LCD driver structure */
willybayot 0:4db361f2e6d5 183 extern LCD_DrvTypeDef st7735_drv;
willybayot 0:4db361f2e6d5 184
willybayot 0:4db361f2e6d5 185 /* LCD IO functions */
willybayot 0:4db361f2e6d5 186 void LCD_IO_Init(void);
willybayot 0:4db361f2e6d5 187 void LCD_IO_WriteData(uint8_t Data);
willybayot 0:4db361f2e6d5 188 void LCD_IO_WriteReg(uint8_t Reg);
willybayot 0:4db361f2e6d5 189 void LCD_Delay(uint32_t delay);
willybayot 0:4db361f2e6d5 190 /**
willybayot 0:4db361f2e6d5 191 * @}
willybayot 0:4db361f2e6d5 192 */
willybayot 0:4db361f2e6d5 193
willybayot 0:4db361f2e6d5 194 #ifdef __cplusplus
willybayot 0:4db361f2e6d5 195 }
willybayot 0:4db361f2e6d5 196 #endif
willybayot 0:4db361f2e6d5 197
willybayot 0:4db361f2e6d5 198 #endif /* __ST7735_H */
willybayot 0:4db361f2e6d5 199
willybayot 0:4db361f2e6d5 200 /**
willybayot 0:4db361f2e6d5 201 * @}
willybayot 0:4db361f2e6d5 202 */
willybayot 0:4db361f2e6d5 203
willybayot 0:4db361f2e6d5 204 /**
willybayot 0:4db361f2e6d5 205 * @}
willybayot 0:4db361f2e6d5 206 */
willybayot 0:4db361f2e6d5 207
willybayot 0:4db361f2e6d5 208 /**
willybayot 0:4db361f2e6d5 209 * @}
willybayot 0:4db361f2e6d5 210 */
willybayot 0:4db361f2e6d5 211
willybayot 0:4db361f2e6d5 212 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/