source: azure_iot_hub_f767zi/trunk/asp_baseplatform/gdic/stlcd_otm8009a/stlcd_otm8009a.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: 17.2 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_OTM8009A_H_
70#define _STLCD_OTM8009A_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 <sil.h>
80#include <target_syssvc.h>
81#include <string.h>
82
83#include "device.h"
84#include "i2c.h"
85#include "ltdc.h"
86#include "dsi.h"
87#include "dfsdm.h"
88
89
90/** @defgroup RCCEx_PLLSAI_DIVR RCCEx PLLSAI DIVR
91 * @{
92 */
93#define RCC_PLLSAIDIVR_2 ((uint32_t)0x00000000U)
94#define RCC_PLLSAIDIVR_4 RCC_DCKCFGR1_PLLSAIDIVR_0
95#define RCC_PLLSAIDIVR_8 RCC_DCKCFGR1_PLLSAIDIVR_1
96#define RCC_PLLSAIDIVR_16 RCC_DCKCFGR1_PLLSAIDIVR
97
98
99
100/**
101 * @brief LCD_OrientationTypeDef
102 * Possible values of Display Orientation
103 */
104#define OTM8009A_ORIENTATION_PORTRAIT ((uint32_t)0x00) /* Portrait orientation choice of LCD screen */
105#define OTM8009A_ORIENTATION_LANDSCAPE ((uint32_t)0x01) /* Landscape orientation choice of LCD screen */
106
107/**
108 * @brief Possible values of
109 * pixel data format (ie color coding) transmitted on DSI Data lane in DSI packets
110 */
111#define OTM8009A_FORMAT_RGB888 ((uint32_t)0x00) /* Pixel format chosen is RGB888 : 24 bpp */
112#define OTM8009A_FORMAT_RBG565 ((uint32_t)0x02) /* Pixel format chosen is RGB565 : 16 bpp */
113
114/**
115 * @brief otm8009a_480x800 Size
116 */
117
118/* Width and Height in Portrait mode */
119#define OTM8009A_480X800_WIDTH ((uint16_t)480) /* LCD PIXEL WIDTH */
120#define OTM8009A_480X800_HEIGHT ((uint16_t)800) /* LCD PIXEL HEIGHT */
121
122/* Width and Height in Landscape mode */
123#define OTM8009A_800X480_WIDTH ((uint16_t)800) /* LCD PIXEL WIDTH */
124#define OTM8009A_800X480_HEIGHT ((uint16_t)480) /* LCD PIXEL HEIGHT */
125
126/**
127 * @brief OTM8009A_480X800 Timing parameters for Portrait orientation mode
128 */
129#define OTM8009A_480X800_HSYNC ((uint16_t)63) /* Horizontal synchronization: This value is set to limit value mentionned
130 in otm8009a spec to fit with USB functional clock configuration constraints */
131#define OTM8009A_480X800_HBP ((uint16_t)120) /* Horizontal back porch */
132#define OTM8009A_480X800_HFP ((uint16_t)120) /* Horizontal front porch */
133#define OTM8009A_480X800_VSYNC ((uint16_t)12) /* Vertical synchronization */
134#define OTM8009A_480X800_VBP ((uint16_t)12) /* Vertical back porch */
135#define OTM8009A_480X800_VFP ((uint16_t)12) /* Vertical front porch */
136
137/**
138 * @brief OTM8009A_800X480 Timing parameters for Landscape orientation mode
139 * Same values as for Portrait mode in fact.
140 */
141#define OTM8009A_800X480_HSYNC OTM8009A_480X800_HSYNC /* Horizontal synchronization */
142#define OTM8009A_800X480_HBP OTM8009A_480X800_HBP /* Horizontal back porch */
143#define OTM8009A_800X480_HFP OTM8009A_480X800_HFP /* Horizontal front porch */
144#define OTM8009A_800X480_VSYNC OTM8009A_480X800_VSYNC /* Vertical synchronization */
145#define OTM8009A_800X480_VBP OTM8009A_480X800_VBP /* Vertical back porch */
146#define OTM8009A_800X480_VFP OTM8009A_480X800_VFP /* Vertical front porch */
147
148
149/* List of OTM8009A used commands */
150/* Detailed in OTM8009A Data Sheet 'DATA_SHEET_OTM8009A_V0 92.pdf' */
151/* Version of 14 June 2012 */
152#define OTM8009A_CMD_NOP 0x00 /* NOP command */
153#define OTM8009A_CMD_SWRESET 0x01 /* Sw reset command */
154#define OTM8009A_CMD_RDDMADCTL 0x0B /* Read Display MADCTR command : read memory display access ctrl */
155#define OTM8009A_CMD_RDDCOLMOD 0x0C /* Read Display pixel format */
156#define OTM8009A_CMD_SLPIN 0x10 /* Sleep In command */
157#define OTM8009A_CMD_SLPOUT 0x11 /* Sleep Out command */
158#define OTM8009A_CMD_PTLON 0x12 /* Partial mode On command */
159
160#define OTM8009A_CMD_DISPOFF 0x28 /* Display Off command */
161#define OTM8009A_CMD_DISPON 0x29 /* Display On command */
162
163#define OTM8009A_CMD_CASET 0x2A /* Column address set command */
164#define OTM8009A_CMD_PASET 0x2B /* Page address set command */
165
166#define OTM8009A_CMD_RAMWR 0x2C /* Memory (GRAM) write command */
167#define OTM8009A_CMD_RAMRD 0x2E /* Memory (GRAM) read command */
168
169#define OTM8009A_CMD_PLTAR 0x30 /* Partial area command (4 parameters) */
170
171#define OTM8009A_CMD_TEOFF 0x34 /* Tearing Effect Line Off command : command with no parameter */
172
173#define OTM8009A_CMD_TEEON 0x35 /* Tearing Effect Line On command : command with 1 parameter 'TELOM' */
174
175/* Parameter TELOM : Tearing Effect Line Output Mode : possible values */
176#define OTM8009A_TEEON_TELOM_VBLANKING_INFO_ONLY 0x00
177#define OTM8009A_TEEON_TELOM_VBLANKING_AND_HBLANKING_INFO 0x01
178
179#define OTM8009A_CMD_MADCTR 0x36 /* Memory Access write control command */
180
181/* Possible used values of MADCTR */
182#define OTM8009A_MADCTR_MODE_PORTRAIT 0x00
183#define OTM8009A_MADCTR_MODE_LANDSCAPE 0x60 /* MY = 0, MX = 1, MV = 1, ML = 0, RGB = 0 */
184
185#define OTM8009A_CMD_IDMOFF 0x38 /* Idle mode Off command */
186#define OTM8009A_CMD_IDMON 0x39 /* Idle mode On command */
187
188#define OTM8009A_CMD_COLMOD 0x3A /* Interface Pixel format command */
189
190/* Possible values of COLMOD parameter corresponding to used pixel formats */
191#define OTM8009A_COLMOD_RGB565 0x55
192#define OTM8009A_COLMOD_RGB888 0x77
193
194#define OTM8009A_CMD_RAMWRC 0x3C /* Memory write continue command */
195#define OTM8009A_CMD_RAMRDC 0x3E /* Memory read continue command */
196
197#define OTM8009A_CMD_WRTESCN 0x44 /* Write Tearing Effect Scan line command */
198#define OTM8009A_CMD_RDSCNL 0x45 /* Read Tearing Effect Scan line command */
199
200/* CABC Management : ie : Content Adaptive Back light Control in IC OTM8009a */
201#define OTM8009A_CMD_WRDISBV 0x51 /* Write Display Brightness command */
202#define OTM8009A_CMD_WRCTRLD 0x53 /* Write CTRL Display command */
203#define OTM8009A_CMD_WRCABC 0x55 /* Write Content Adaptive Brightness command */
204#define OTM8009A_CMD_WRCABCMB 0x5E /* Write CABC Minimum Brightness command */
205
206/**
207 * @brief OTM8009A_480X800 frequency divider
208 */
209#define OTM8009A_480X800_FREQUENCY_DIVIDER 2 /* LCD Frequency divider */
210
211/**
212 * @brief LCD FB_StartAddress
213 */
214#define LCD_FB_START_ADDRESS ((uint32_t)0xC0000000)
215
216/** @brief Maximum number of LTDC layers
217 */
218#define LTDC_MAX_LAYER_NUMBER ((uint32_t) 2)
219
220/** @brief LTDC Background layer index
221 */
222#define LTDC_ACTIVE_LAYER_BACKGROUND ((uint32_t) 0)
223
224/** @brief LTDC Foreground layer index
225 */
226#define LTDC_ACTIVE_LAYER_FOREGROUND ((uint32_t) 1)
227
228/** @brief Number of LTDC layers
229 */
230#define LTDC_NB_OF_LAYERS ((uint32_t) 2)
231
232/** @brief LTDC Default used layer index
233 */
234#define LTDC_DEFAULT_ACTIVE_LAYER LTDC_ACTIVE_LAYER_FOREGROUND
235
236/**
237 * @brief LCD Display OTM8009A DSI Virtual Channel ID
238 */
239#define LCD_OTM8009A_ID ((uint32_t) 0)
240
241
242/**
243 * @brief LCD color
244 */
245#define LCD_COLOR_BLUE ((uint32_t)0xFF0000FF)
246#define LCD_COLOR_GREEN ((uint32_t)0xFF00FF00)
247#define LCD_COLOR_RED ((uint32_t)0xFFFF0000)
248#define LCD_COLOR_CYAN ((uint32_t)0xFF00FFFF)
249#define LCD_COLOR_MAGENTA ((uint32_t)0xFFFF00FF)
250#define LCD_COLOR_YELLOW ((uint32_t)0xFFFFFF00)
251#define LCD_COLOR_LIGHTBLUE ((uint32_t)0xFF8080FF)
252#define LCD_COLOR_LIGHTGREEN ((uint32_t)0xFF80FF80)
253#define LCD_COLOR_LIGHTRED ((uint32_t)0xFFFF8080)
254#define LCD_COLOR_LIGHTCYAN ((uint32_t)0xFF80FFFF)
255#define LCD_COLOR_LIGHTMAGENTA ((uint32_t)0xFFFF80FF)
256#define LCD_COLOR_LIGHTYELLOW ((uint32_t)0xFFFFFF80)
257#define LCD_COLOR_DARKBLUE ((uint32_t)0xFF000080)
258#define LCD_COLOR_DARKGREEN ((uint32_t)0xFF008000)
259#define LCD_COLOR_DARKRED ((uint32_t)0xFF800000)
260#define LCD_COLOR_DARKCYAN ((uint32_t)0xFF008080)
261#define LCD_COLOR_DARKMAGENTA ((uint32_t)0xFF800080)
262#define LCD_COLOR_DARKYELLOW ((uint32_t)0xFF808000)
263#define LCD_COLOR_WHITE ((uint32_t)0xFFFFFFFF)
264#define LCD_COLOR_LIGHTGRAY ((uint32_t)0xFFD3D3D3)
265#define LCD_COLOR_GRAY ((uint32_t)0xFF808080)
266#define LCD_COLOR_DARKGRAY ((uint32_t)0xFF404040)
267#define LCD_COLOR_BLACK ((uint32_t)0xFF000000)
268#define LCD_COLOR_BROWN ((uint32_t)0xFFA52A2A)
269#define LCD_COLOR_ORANGE ((uint32_t)0xFFFFA500)
270#define LCD_COLOR_TRANSPARENT ((uint32_t)0xFF000000)
271
272/**
273 * @brief Possible values of
274 * pixel data format (ie color coding) transmitted on DSI Data lane in DSI packets
275 */
276
277#define LCD_DSI_PIXEL_DATA_FMT_RBG888 DSI_RGB888 /*!< DSI packet pixel format chosen is RGB888 : 24 bpp */
278#define LCD_DSI_PIXEL_DATA_FMT_RBG565 DSI_RGB565 /*!< DSI packet pixel format chosen is RGB565 : 16 bpp */
279
280/*
281 * LCDハンドラ構造体定義
282 */
283typedef struct
284{
285 LTDC_Handle_t *hltdc; /* LTDCハンドラ */
286 DSI_Handle_t *hdsi; /* DSIハンドラ */
287 DSI_VideoConfig_t dsivc; /* DSI video configハンドラ */
288 uint32_t layer;
289 uint16_t _width; /* 幅ピクセル数 */
290 uint16_t _height; /* 高さピクセル数 */
291} LCD_Handler_t;
292
293/**
294* @brief LCD Drawing main properties
295*/
296typedef struct
297{
298 LCD_Handler_t *hlcd;
299 uint32_t TextColor; /* Specifies the color of text */
300 uint32_t BackColor; /* Specifies the background color below the text */
301 void *pFont; /* Specifies the font used for the text */
302
303} LCD_DrawProp_t;
304
305/**
306 * @brief LCD Drawing point (pixel) geometric definition
307 */
308typedef struct
309{
310 int16_t X; /*!< geometric X position of drawing */
311 int16_t Y; /*!< geometric Y position of drawing */
312
313} Point;
314
315/**
316 * @brief Pointer on LCD Drawing point (pixel) geometric definition
317 */
318typedef Point * pPoint;
319
320/**
321 * @brief LCD_OrientationTypeDef
322 * Possible values of Display Orientation
323 */
324typedef enum
325{
326 LCD_ORIENTATION_PORTRAIT = 0x00, /*!< Portrait orientation choice of LCD screen */
327 LCD_ORIENTATION_LANDSCAPE = 0x01, /*!< Landscape orientation choice of LCD screen */
328 LCD_ORIENTATION_INVALID = 0x02 /*!< Invalid orientation choice of LCD screen */
329} LCD_OrientationTypeDef;
330
331
332extern ER lcd_init(LCD_Handler_t *hlcd, LCD_OrientationTypeDef orientation);
333extern ER lcd_reset(LCD_Handler_t *hlcd);
334
335extern ER lcd_layerdefaultinit(LCD_Handler_t *hlcd, LCD_DrawProp_t *pDrawProp, uint16_t LayerIndex, uint32_t FB_Address);
336extern void lcd_setlayervisible(LCD_Handler_t *hlcd, uint32_t LayerIndex, uint8_t State);
337extern void lcd_settransparency(LCD_Handler_t *hlcd, uint32_t LayerIndex, uint8_t Transparency);
338extern void lcd_setlayeraddress(LCD_Handler_t *hlcd, uint32_t LayerIndex, uint32_t Address);
339extern void lcd_setcolorkeying(LCD_Handler_t *hlcd, uint32_t LayerIndex, uint32_t RGBValue);
340extern void lcd_resetcolorkeying(LCD_Handler_t *hlcd, uint32_t LayerIndex);
341
342extern void lcd_setAddrWindow(LCD_Handler_t *hlcd, uint16_t LayerIndex, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
343extern void lcd_clear(LCD_Handler_t *hlcd, uint32_t Color);
344extern uint32_t lcd_readPixel(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos);
345extern void lcd_drawPixel(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos, uint32_t RGB_Code);
346extern void lcd_drawFastHLine(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint32_t color);
347extern void lcd_drawFastVLine(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos, uint16_t Length, uint32_t color);
348extern void lcd_drawBitmap(LCD_Handler_t *hlcd, uint32_t Xpos, uint32_t Ypos, uint8_t *pbmp);
349extern void lcd_displayOn(LCD_Handler_t *hlcd);
350extern void lcd_displayOff(LCD_Handler_t *hlcd);
351extern void lcd_setbrightness(LCD_Handler_t *hlcd, uint8_t BrightnessValue);
352extern void lcd_fillRect(LCD_Handler_t *hlcd, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height, uint32_t color);
353
354extern void lcd_drawLine(LCD_DrawProp_t *pDrawProp, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
355extern void lcd_drawRect(LCD_DrawProp_t *pDrawProp, uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
356extern void lcd_DrawCircle(LCD_DrawProp_t *pDrawProp, uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
357extern void lcd_DrawEllipse(LCD_DrawProp_t *pDrawProp, int Xpos, int Ypos, int XRadius, int YRadius);
358extern void lcd_drawPolygon(LCD_DrawProp_t *pDrawProp, pPoint Points, uint16_t PointCount);
359extern void lcd_fillCircle(LCD_DrawProp_t *pDrawProp, uint16_t Xpos, uint16_t Ypos, uint16_t Radius);
360extern void lcd_fillEllipse(LCD_DrawProp_t *pDrawProp, int Xpos, int Ypos, int XRadius, int YRadius);
361extern void lcd_fillPolygon(LCD_DrawProp_t *pDrawProp, pPoint Points, uint16_t PointCount);
362
363
364#ifdef __cplusplus
365}
366#endif
367
368#endif /* _STLCD_OTM8009A_H_ */
369
Note: See TracBrowser for help on using the repository browser.