source: azure_iot_hub_f767zi/trunk/asp_baseplatform/gdic/stlcd_st7789h2/stlcd_st7789h2.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 11.5 KB
Line 
1/*
2 * TOPPERS BASE PLATFORM MIDDLEWARE
3 *
4 * Copyright (C) 2017-2018 by TOPPERS PROJECT
5 * Educational Working Group.
6 *
7 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
8 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
9 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
10 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
11 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
12 * スコード中に含まれていること.
13 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
14 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
15 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
16 * の無保証規定を掲載すること.
17 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
18 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
19 * と.
20 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
21 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
22 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
23 * 報告すること.
24 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
25 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
26 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
27 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
28 * 免責すること.
29 *
30 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
31 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
32 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
33 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
34 * の責任を負わない.
35 *
36 * @(#) $Id$
37 */
38/**
39 ******************************************************************************
40 * @attention
41 *
42 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
43 *
44 * Redistribution and use in source and binary forms, with or without modification,
45 * are permitted provided that the following conditions are met:
46 * 1. Redistributions of source code must retain the above copyright notice,
47 * this list of conditions and the following disclaimer.
48 * 2. Redistributions in binary form must reproduce the above copyright notice,
49 * this list of conditions and the following disclaimer in the documentation
50 * and/or other materials provided with the distribution.
51 * 3. Neither the name of STMicroelectronics nor the names of its contributors
52 * may be used to endorse or promote products derived from this software
53 * without specific prior written permission.
54 *
55 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
56 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
58 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
61 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
62 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
63 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
64 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
65 *
66 ******************************************************************************
67 */
68
69#ifndef _STLCD_ST7789H2_H_
70#define _STLCD_ST7789H2_H_
71
72#ifdef __cplusplus
73 extern "C" {
74#endif
75
76#include <kernel.h>
77#include <t_syslog.h>
78#include <t_stdlib.h>
79#include <target_syssvc.h>
80#include "device.h"
81#include "ltdc.h"
82
83
84/**
85 * @brief ST7789H2 ID
86 */
87#define ST7789H2_ID 0x85
88
89/**
90 * @brief ST7789H2 Size
91 */
92#define ST7789H2_LCD_PIXEL_WIDTH ((uint16_t)240)
93#define ST7789H2_LCD_PIXEL_HEIGHT ((uint16_t)240)
94
95/**
96 * @brief LCD_OrientationTypeDef
97 * Possible values of Display Orientation
98 */
99#define ST7789H2_ORIENTATION_PORTRAIT ((uint32_t)0x00) /* Portrait orientation choice of LCD screen */
100#define ST7789H2_ORIENTATION_LANDSCAPE ((uint32_t)0x01) /* Landscape orientation choice of LCD screen */
101#define ST7789H2_ORIENTATION_LANDSCAPE_ROT180 ((uint32_t)0x02) /* Landscape rotated 180ー orientation choice of LCD screen */
102
103/**
104 * @brief ST7789H2 Registers
105 */
106#define ST7789H2_LCD_ID 0x04
107#define ST7789H2_SLEEP_IN 0x10
108#define ST7789H2_SLEEP_OUT 0x11
109#define ST7789H2_PARTIAL_DISPLAY 0x12
110#define ST7789H2_DISPLAY_INVERSION 0x21
111#define ST7789H2_DISPLAY_ON 0x29
112#define ST7789H2_WRITE_RAM 0x2C
113#define ST7789H2_READ_RAM 0x2E
114#define ST7789H2_CASET 0x2A
115#define ST7789H2_RASET 0x2B
116#define ST7789H2_VSCRDEF 0x33 /* Vertical Scroll Definition */
117#define ST7789H2_VSCSAD 0x37 /* Vertical Scroll Start Address of RAM */
118#define ST7789H2_TEARING_EFFECT 0x35
119#define ST7789H2_NORMAL_DISPLAY 0x36
120#define ST7789H2_IDLE_MODE_OFF 0x38
121#define ST7789H2_IDLE_MODE_ON 0x39
122#define ST7789H2_COLOR_MODE 0x3A
123#define ST7789H2_PORCH_CTRL 0xB2
124#define ST7789H2_GATE_CTRL 0xB7
125#define ST7789H2_VCOM_SET 0xBB
126#define ST7789H2_DISPLAY_OFF 0xBD
127#define ST7789H2_LCM_CTRL 0xC0
128#define ST7789H2_VDV_VRH_EN 0xC2
129#define ST7789H2_VDV_SET 0xC4
130#define ST7789H2_VCOMH_OFFSET_SET 0xC5
131#define ST7789H2_FR_CTRL 0xC6
132#define ST7789H2_POWER_CTRL 0xD0
133#define ST7789H2_PV_GAMMA_CTRL 0xE0
134#define ST7789H2_NV_GAMMA_CTRL 0xE1
135
136
137/*
138 * ポリゴンポイント定義
139 */
140typedef struct
141{
142 int16_t X;
143 int16_t Y;
144}Point, *pPoint;
145
146
147#define LCD_ORIENTATION_PORTRAIT ((uint8_t)0x00) /*!< Portrait orientation choice of LCD screen */
148#define LCD_ORIENTATION_LANDSCAPE ((uint8_t)0x01) /*!< Landscape orientation choice of LCD screen */
149#define LCD_ORIENTATION_LANDSCAPE_ROT180 ((uint32_t)0x02) /*!< Landscape rotated 180ー orientation choice of LCD screen */
150
151
152/**
153 * @brief LCD color
154 */
155#define LCD_COLOR_BLUE ((uint16_t)0x001F)
156#define LCD_COLOR_GREEN ((uint16_t)0x07E0)
157#define LCD_COLOR_RED ((uint16_t)0xF800)
158#define LCD_COLOR_CYAN ((uint16_t)0x07FF)
159#define LCD_COLOR_MAGENTA ((uint16_t)0xF81F)
160#define LCD_COLOR_YELLOW ((uint16_t)0xFFE0)
161#define LCD_COLOR_LIGHTBLUE ((uint16_t)0x841F)
162#define LCD_COLOR_LIGHTGREEN ((uint16_t)0x87F0)
163#define LCD_COLOR_LIGHTRED ((uint16_t)0xFC10)
164#define LCD_COLOR_LIGHTMAGENTA ((uint16_t)0xFC1F)
165#define LCD_COLOR_LIGHTYELLOW ((uint16_t)0xFFF0)
166#define LCD_COLOR_DARKBLUE ((uint16_t)0x0010)
167#define LCD_COLOR_DARKGREEN ((uint16_t)0x0400)
168#define LCD_COLOR_DARKRED ((uint16_t)0x8000)
169#define LCD_COLOR_DARKCYAN ((uint16_t)0x0410)
170#define LCD_COLOR_DARKMAGENTA ((uint16_t)0x8010)
171#define LCD_COLOR_DARKYELLOW ((uint16_t)0x8400)
172#define LCD_COLOR_WHITE ((uint16_t)0xFFFF)
173#define LCD_COLOR_LIGHTGRAY ((uint16_t)0xD69A)
174#define LCD_COLOR_GRAY ((uint16_t)0x8410)
175#define LCD_COLOR_DARKGRAY ((uint16_t)0x4208)
176#define LCD_COLOR_BLACK ((uint16_t)0x0000)
177#define LCD_COLOR_BROWN ((uint16_t)0xA145)
178#define LCD_COLOR_ORANGE ((uint16_t)0xFD20)
179
180
181/*
182 * LCDハンドラ構造体定義
183 */
184typedef struct
185{
186 uint32_t fmc_base; /* FMCベースアドレス */
187 uint16_t _width; /* 幅ピクセル数 */
188 uint16_t _height; /* 高さピクセル数 */
189 uint16_t winXstart; /* Windows X start */
190 uint16_t winYstart; /* Windows Y start */
191 uint16_t winXend; /* Windows X end */
192 uint16_t winYend; /* Windows Y end */
193
194 uint32_t rst_clk; /* RESET CLOCK BIT */
195 uint32_t te_clk; /* LCD tearing effect CLOCK BIT */
196 uint32_t bl_clk; /* LCD Backlight control CLOCK BIT */
197 uint32_t rst_base; /* RESET PORT */
198 uint32_t te_base; /* LCD tearing effect PORT */
199 uint32_t bl_base; /* LCD Backlight control PORT */
200 uint32_t gpio_speed; /* GPIO SPEED */
201 uint32_t rst_pull; /* RESET PULL TYPE */
202 uint32_t bl_pull; /* LCD Backlight control PULL TYPE */
203 uint8_t rst_pin; /* RESET PIN */
204 uint8_t te_pin; /* LCD tearing effect PIN */
205 uint8_t bl_pin; /* LCD Backlight control PIN */
206 uint8_t bl_active;
207}LCD_Handler_t;
208
209/**
210 * @}
211 */
212typedef struct
213{
214 LCD_Handler_t *hlcd;
215 uint32_t TextColor;
216 uint32_t BackColor;
217 void *pFont;
218}LCD_DrawProp_t;
219
220
221extern ER lcd_init(LCD_Handler_t *hlcd, uint32_t orientation);
222extern ER lcd_deinit(LCD_Handler_t *hlcd);
223
224extern ER lcd_layerdefaultinit(LCD_Handler_t *hlcd, LCD_DrawProp_t *pDrawProp, uint16_t LayerIndex, uint32_t FB_Address);
225extern void lcd_setAddrWindow(LCD_Handler_t *hlcd, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
226extern void lcd_clear(LCD_Handler_t *hlcd, uint16_t Color);
227extern uint16_t lcd_readPixel(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos);
228extern void lcd_drawPixel(LCD_Handler_t *hlcd, int16_t x, int16_t y, uint16_t color);
229extern void lcd_drawFastHLine(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint32_t color);
230extern void lcd_drawFastVLine(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint32_t color);
231extern void lcd_drawBitmap(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
232extern void lcd_drawRGBImage(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata);
233extern void lcd_displayOn(LCD_Handler_t *hlcd);
234extern void lcd_displayOff(LCD_Handler_t *hlcd);
235extern void lcd_fillRect(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height, uint32_t color);
236
237extern void lcd_drawLine(LCD_DrawProp_t *pDrawProp, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
238extern void lcd_drawRect(LCD_DrawProp_t *pDrawProp, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
239extern void lcd_DrawCircle(LCD_DrawProp_t *pDrawProp, uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
240extern void lcd_drawPolygon(LCD_DrawProp_t *pDrawProp, pPoint Points, uint16_t PointCount);
241extern void lcd_DrawEllipse(LCD_DrawProp_t *pDrawProp, int Xpos, int Ypos, int XRadius, int YRadius);
242extern void lcd_fillCircle(LCD_DrawProp_t *pDrawProp, uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
243extern void lcd_fillEllipse(LCD_DrawProp_t *pDrawProp, int Xpos, int Ypos, int XRadius, int YRadius);
244extern void lcd_fillPolygon(LCD_DrawProp_t *pDrawProp, pPoint Points, uint16_t PointCount);
245
246
247#ifdef __cplusplus
248}
249#endif
250
251#endif /* _STLCD_ST7789H2_H_ */
252
Note: See TracBrowser for help on using the repository browser.