[453] | 1 | /*
|
---|
| 2 | * TOPPERS/ASP Kernel
|
---|
| 3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
| 4 | * Advanced Standard Profile Kernel
|
---|
| 5 | *
|
---|
| 6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
| 7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
| 8 | * Copyright (C) 2004-2010 by Embedded and Real-Time Systems Laboratory
|
---|
| 9 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
| 10 | * Copyright (C) 2015-2019 by TOPPERS PROJECT Educational Working Group.
|
---|
| 11 | *
|
---|
| 12 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
| 13 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
| 14 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
| 15 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
| 16 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
| 17 | * スコード中に含まれていること.
|
---|
| 18 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
| 19 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
| 20 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
| 21 | * の無保証規定を掲載すること.
|
---|
| 22 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
| 23 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
| 24 | * と.
|
---|
| 25 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
| 26 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
| 27 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
| 28 | * 報告すること.
|
---|
| 29 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
| 30 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
| 31 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
| 32 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
| 33 | * 免責すること.
|
---|
| 34 | *
|
---|
| 35 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
| 36 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
| 37 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
| 38 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
| 39 | * の責任を負わない.
|
---|
| 40 | *
|
---|
| 41 | * $Id$
|
---|
| 42 | */
|
---|
| 43 | /*
|
---|
| 44 | * SIPEED ST7789 2.4"LCD制御プログラムのヘッダファイル
|
---|
| 45 | */
|
---|
| 46 |
|
---|
| 47 | #ifndef _SIPEED_ST7789_H_
|
---|
| 48 | #define _SIPEED_ST7789_H_
|
---|
| 49 |
|
---|
| 50 | #ifdef __cplusplus
|
---|
| 51 | extern "C" {
|
---|
| 52 | #endif
|
---|
| 53 |
|
---|
| 54 | #include "device.h"
|
---|
| 55 | #include "spi.h"
|
---|
| 56 |
|
---|
| 57 | /*
|
---|
| 58 | * LCDカラーモード定義
|
---|
| 59 | */
|
---|
| 60 | #define CM_ARGB8888 0x00000000 /* ARGB8888 color mode */
|
---|
| 61 | #define CM_RGB888 0x00000001 /* RGB888 color mode */
|
---|
| 62 | #define CM_RGB565 0x00000002 /* RGB565 color mode */
|
---|
| 63 |
|
---|
| 64 | #define ST7789_TFTWIDTH 240
|
---|
| 65 | #define ST7789_TFTHEIGHT 320
|
---|
| 66 |
|
---|
| 67 |
|
---|
| 68 | #define NO_OPERATION 0x00
|
---|
| 69 | #define SOFTWARE_RESET 0x01
|
---|
| 70 | #define READ_ID 0x04
|
---|
| 71 | #define READ_STATUS 0x09
|
---|
| 72 | #define READ_POWER_MODE 0x0A
|
---|
| 73 | #define READ_MADCTL 0x0B
|
---|
| 74 | #define READ_PIXEL_FORMAT 0x0C
|
---|
| 75 | #define READ_IMAGE_FORMAT 0x0D
|
---|
| 76 | #define READ_SIGNAL_MODE 0x0E
|
---|
| 77 | #define READ_SELT_DIAG_RESULT 0x0F
|
---|
| 78 | #define SLEEP_ON 0x10
|
---|
| 79 | #define SLEEP_OFF 0x11
|
---|
| 80 | #define PARTIAL_DISPALY_ON 0x12
|
---|
| 81 | #define NORMAL_DISPALY_ON 0x13
|
---|
| 82 | #define INVERSION_DISPALY_OFF 0x20
|
---|
| 83 | #define INVERSION_DISPALY_ON 0x21
|
---|
| 84 | #define GAMMA_SET 0x26
|
---|
| 85 | #define DISPALY_OFF 0x28
|
---|
| 86 | #define DISPALY_ON 0x29
|
---|
| 87 | #define HORIZONTAL_ADDRESS_SET 0x2A
|
---|
| 88 | #define VERTICAL_ADDRESS_SET 0x2B
|
---|
| 89 | #define MEMORY_WRITE 0x2C
|
---|
| 90 | #define COLOR_SET 0x2D
|
---|
| 91 | #define MEMORY_READ 0x2E
|
---|
| 92 | #define PARTIAL_AREA 0x30
|
---|
| 93 | #define VERTICAL_SCROL_DEFINE 0x33
|
---|
| 94 | #define TEAR_EFFECT_LINE_OFF 0x34
|
---|
| 95 | #define TEAR_EFFECT_LINE_ON 0x35
|
---|
| 96 | #define MEMORY_ACCESS_CTL 0x36
|
---|
| 97 | #define VERTICAL_SCROL_S_ADD 0x37
|
---|
| 98 | #define IDLE_MODE_OFF 0x38
|
---|
| 99 | #define IDLE_MODE_ON 0x39
|
---|
| 100 | #define PIXEL_FORMAT_SET 0x3A
|
---|
| 101 | #define WRITE_MEMORY_CONTINUE 0x3C
|
---|
| 102 | #define READ_MEMORY_CONTINUE 0x3E
|
---|
| 103 | #define SET_TEAR_SCANLINE 0x44
|
---|
| 104 | #define GET_SCANLINE 0x45
|
---|
| 105 | #define WRITE_BRIGHTNESS 0x51
|
---|
| 106 | #define READ_BRIGHTNESS 0x52
|
---|
| 107 | #define WRITE_CTRL_DISPALY 0x53
|
---|
| 108 | #define READ_CTRL_DISPALY 0x54
|
---|
| 109 | #define WRITE_BRIGHTNESS_CTL 0x55
|
---|
| 110 | #define READ_BRIGHTNESS_CTL 0x56
|
---|
| 111 | #define WRITE_MIN_BRIGHTNESS 0x5E
|
---|
| 112 | #define READ_MIN_BRIGHTNESS 0x5F
|
---|
| 113 | #define READ_ID1 0xDA
|
---|
| 114 | #define READ_ID2 0xDB
|
---|
| 115 | #define READ_ID3 0xDC
|
---|
| 116 | #define RGB_IF_SIGNAL_CTL 0xB0
|
---|
| 117 | #define NORMAL_FRAME_CTL 0xB1
|
---|
| 118 | #define IDLE_FRAME_CTL 0xB2
|
---|
| 119 | #define PARTIAL_FRAME_CTL 0xB3
|
---|
| 120 | #define INVERSION_CTL 0xB4
|
---|
| 121 | #define BLANK_PORCH_CTL 0xB5
|
---|
| 122 | #define DISPALY_FUNCTION_CTL 0xB6
|
---|
| 123 | #define ENTRY_MODE_SET 0xB7
|
---|
| 124 | #define BACKLIGHT_CTL1 0xB8
|
---|
| 125 | #define BACKLIGHT_CTL2 0xB9
|
---|
| 126 | #define BACKLIGHT_CTL3 0xBA
|
---|
| 127 | #define BACKLIGHT_CTL4 0xBB
|
---|
| 128 | #define BACKLIGHT_CTL5 0xBC
|
---|
| 129 | #define BACKLIGHT_CTL7 0xBE
|
---|
| 130 | #define BACKLIGHT_CTL8 0xBF
|
---|
| 131 | #define POWER_CTL1 0xC0
|
---|
| 132 | #define POWER_CTL2 0xC1
|
---|
| 133 | #define VCOM_CTL1 0xC5
|
---|
| 134 | #define VCOM_CTL2 0xC7
|
---|
| 135 | #define NV_MEMORY_WRITE 0xD0
|
---|
| 136 | #define NV_MEMORY_PROTECT_KEY 0xD1
|
---|
| 137 | #define NV_MEMORY_STATUS_READ 0xD2
|
---|
| 138 | #define READ_ID4 0xD3
|
---|
| 139 | #define POSITIVE_GAMMA_CORRECT 0xE0
|
---|
| 140 | #define NEGATIVE_GAMMA_CORRECT 0xE1
|
---|
| 141 | #define DIGITAL_GAMMA_CTL1 0xE2
|
---|
| 142 | #define DIGITAL_GAMMA_CTL2 0xE3
|
---|
| 143 | #define INTERFACE_CTL 0xF6
|
---|
| 144 |
|
---|
| 145 | /*
|
---|
| 146 | * カラー定義
|
---|
| 147 | */
|
---|
| 148 | #define ST7789_BLACK 0x0000
|
---|
| 149 | #define ST7789_NAVY 0x000F
|
---|
| 150 | #define ST7789_DARKGREEN 0x03E0
|
---|
| 151 | #define ST7789_DARKCYAN 0x03EF
|
---|
| 152 | #define ST7789_MAROON 0x7800
|
---|
| 153 | #define ST7789_PURPLE 0x780F
|
---|
| 154 | #define ST7789_OLIVE 0x7BE0
|
---|
| 155 | #define ST7789_LIGHTGREY 0xC618
|
---|
| 156 | #define ST7789_DARKGREY 0x7BEF
|
---|
| 157 | #define ST7789_BLUE 0x001F
|
---|
| 158 | #define ST7789_GREEN 0x07E0
|
---|
| 159 | #define ST7789_CYAN 0x07FF
|
---|
| 160 | #define ST7789_RED 0xF800
|
---|
| 161 | #define ST7789_MAGENTA 0xF81F
|
---|
| 162 | #define ST7789_YELLOW 0xFFE0
|
---|
| 163 | #define ST7789_WHITE 0xFFFF
|
---|
| 164 | #define ST7789_ORANGE 0xFD20
|
---|
| 165 | #define ST7789_GREENYELLOW 0xAFE5
|
---|
| 166 | #define ST7789_PINK 0xF81F
|
---|
| 167 |
|
---|
| 168 | /*
|
---|
| 169 | * LCD DIRECTION
|
---|
| 170 | */
|
---|
| 171 | #define DIR_XY_RLUD 0x00
|
---|
| 172 | #define DIR_YX_RLUD 0x20
|
---|
| 173 | #define DIR_XY_LRUD 0x40
|
---|
| 174 | #define DIR_YX_LRUD 0x60
|
---|
| 175 | #define DIR_XY_RLDU 0x80
|
---|
| 176 | #define DIR_YX_RLDU 0xA0
|
---|
| 177 | #define DIR_XY_LRDU 0xC0
|
---|
| 178 | #define DIR_YX_LRDU 0xE0
|
---|
| 179 | #define DIR_XY_MASK 0x20
|
---|
| 180 | #define DIR_RL_MASK 0x40
|
---|
| 181 | #define DIR_UD_MASK 0x80
|
---|
| 182 |
|
---|
| 183 | #define TRS_COLOR_T uint32_t
|
---|
| 184 |
|
---|
| 185 | #ifndef TOPPERS_MACRO_ONLY
|
---|
| 186 |
|
---|
| 187 |
|
---|
| 188 | /*
|
---|
| 189 | * カラーの属性を定義
|
---|
| 190 | */
|
---|
| 191 | typedef uint16_t color_t;
|
---|
| 192 |
|
---|
| 193 | typedef struct
|
---|
| 194 | {
|
---|
| 195 | SPI_Handle_t *hspi;
|
---|
| 196 | uint16_t _width;
|
---|
| 197 | uint16_t _height;
|
---|
| 198 | uint16_t colstart;
|
---|
| 199 | uint16_t rowstart;
|
---|
| 200 | ID spi_lock;
|
---|
| 201 | uint8_t mode;
|
---|
| 202 | uint8_t dir;
|
---|
| 203 |
|
---|
| 204 | int8_t dcx_pin;
|
---|
| 205 | int8_t rst_pin;
|
---|
| 206 | int8_t cs_sel;
|
---|
| 207 | uint8_t dcx_no;
|
---|
| 208 | uint8_t rst_no;
|
---|
| 209 | } LCD_Handler_t;
|
---|
| 210 |
|
---|
| 211 |
|
---|
| 212 | /*
|
---|
| 213 | * 描画構造体
|
---|
| 214 | */
|
---|
| 215 | typedef struct
|
---|
| 216 | {
|
---|
| 217 | LCD_Handler_t *hlcd;
|
---|
| 218 | color_t TextColor;
|
---|
| 219 | color_t BackColor;
|
---|
| 220 | void *pFont;
|
---|
| 221 | }LCD_DrawProp_t;
|
---|
| 222 |
|
---|
| 223 | typedef struct
|
---|
| 224 | {
|
---|
| 225 | int16_t X;
|
---|
| 226 | int16_t Y;
|
---|
| 227 | }Point, * pPoint;
|
---|
| 228 |
|
---|
| 229 | /*
|
---|
| 230 | * 関数のプロトタイプ宣言
|
---|
| 231 | */
|
---|
| 232 | extern ER lcd_writecommand(LCD_Handler_t *hlcd, uint8_t c);
|
---|
| 233 | extern ER lcd_writebyte(LCD_Handler_t *hlcd, uint8_t *buf, uint8_t len);
|
---|
| 234 | extern ER lcd_writehalf(LCD_Handler_t *hlcd, uint32_t *buf, int cnt);
|
---|
| 235 | extern ER lcd_filldata(LCD_Handler_t *hlcd, uint32_t *data_buf, uint32_t len);
|
---|
| 236 |
|
---|
| 237 | extern void lcd_init(LCD_Handler_t *hlcd);
|
---|
| 238 | extern void lcd_setAddrWindow(LCD_Handler_t *hlcd, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
|
---|
| 239 | extern void lcd_fillRect(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t w, int16_t h, color_t color);
|
---|
| 240 | extern void lcd_pushColor(LCD_Handler_t *hlcd, color_t color);
|
---|
| 241 | extern void lcd_drawPixel(LCD_Handler_t *hlcd, int16_t x, int16_t y, color_t color);
|
---|
| 242 | extern void lcd_drawFastVLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t h, color_t color);
|
---|
| 243 | extern void lcd_drawFastHLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t w, color_t color);
|
---|
| 244 | extern void lcd_drawImageHLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, uint16_t w, TRS_COLOR_T *pcolor);
|
---|
| 245 | extern void lcd_drawBitmap(LCD_Handler_t *hlcd, uint16_t x0, uint16_t y0, uint8_t *pbmp);
|
---|
| 246 | extern void lcd_drawPicture(LCD_Handler_t *hlcd, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t *pbmp);
|
---|
| 247 | extern void lcd_invertDisplay(LCD_Handler_t *hlcd, bool_t i);
|
---|
| 248 |
|
---|
| 249 | extern void lcd_fillScreen(LCD_DrawProp_t *pDrawProp);
|
---|
| 250 | extern void lcd_drawRect(LCD_DrawProp_t *pDrawProp, int16_t x, int16_t y, int16_t w, int16_t h);
|
---|
| 251 | extern void lcd_DrawCircle(LCD_DrawProp_t *pDrawProp, uint16_t x0, uint16_t y0, uint16_t Radius);
|
---|
| 252 | extern void lcd_drawLine(LCD_DrawProp_t *pDrawProp, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
---|
| 253 | extern void lcd_drawPolygon(LCD_DrawProp_t *pDrawProp, pPoint Points, uint16_t PointCount);
|
---|
| 254 |
|
---|
| 255 | #endif /* TOPPERS_MACRO_ONLY */
|
---|
| 256 |
|
---|
| 257 | #ifdef __cplusplus
|
---|
| 258 | }
|
---|
| 259 | #endif
|
---|
| 260 |
|
---|
| 261 | #endif /* _SIPEED_ST7789_H_ */
|
---|
| 262 |
|
---|