-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathSSD1963.h
More file actions
403 lines (357 loc) · 18.4 KB
/
SSD1963.h
File metadata and controls
403 lines (357 loc) · 18.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
/*
* @cond
* The following section will be excluded from the documentation.
*/
/* *********************************************************************************************************************
* PicoMite MMBasic - SSD1963.h
*
* SSD1963 parallel LCD display controller definitions
*
* <COPYRIGHT HOLDERS> Geoff Graham, Peter Mather
* Copyright (c) 2021, <COPYRIGHT HOLDERS> All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.
* 3. The name MMBasic be used when referring to the interpreter in any documentation and promotional material and the
* original copyright message be displayed on the console at startup (additional copyright messages may be added).
* 4. All advertising materials mentioning features or use of this software must display the following acknowledgement:
* This product includes software developed by the <copyright holder>.
* 5. Neither the name of the <copyright holder> nor the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDERS> AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL <COPYRIGHT HOLDERS> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/
#ifndef _SSD1963_H
#define _SSD1963_H
/* ==============================================================================================================
* GENERAL DEFINITIONS
* ============================================================================================================== */
#define nop asm("NOP")
/* ==============================================================================================================
* GPIO DEFINITIONS
* ============================================================================================================== */
#define GPIO3 3
#define GPIO2 2
#define GPIO1 1
#define GPIO0 0
#define LCD_RESET (1 << GPIO0) // LCD Reset signal (for display panel, NOT ssd1963)
#define LCD_SPENA 0
#define LCD_SPCLK 0
#define LCD_SPDAT 0
/* ==============================================================================================================
* DISPLAY ORIENTATION MODES
* ============================================================================================================== */
#define SSD1963_LANDSCAPE 0b00
#define SSD1963_PORTRAIT ((1 << 7) | (1 << 5))
#define SSD1963_RLANDSCAPE (SSD1963_LANDSCAPE | 0b11)
#define SSD1963_RPORTRAIT (SSD1963_PORTRAIT | 0b11)
/* ==============================================================================================================
* SSD1963 COMMAND SET
* ============================================================================================================== */
// Basic Commands
#define CMD_NOP 0x00 // No operation
#define CMD_SOFT_RESET 0x01 // Software reset
#define CMD_GET_PWR_MODE 0x0A // Get the current power mode
#define CMD_GET_ADDR_MODE 0x0B // Get frame memory to display panel read order
#define CMD_GET_PIXEL_FORMAT 0x0C // Get the current pixel format
#define CMD_GET_DISPLAY_MODE 0x0D // Returns the display mode
#define CMD_GET_SIGNAL_MODE 0x0E
#define CMD_GET_DIAGNOSTIC 0x0F
// Power and Sleep Commands
#define CMD_ENT_SLEEP 0x10
#define CMD_EXIT_SLEEP 0x11
#define CMD_ENT_PARTIAL_MODE 0x12
#define CMD_ENT_NORMAL_MODE 0x13
#define CMD_EXIT_INVERT_MODE 0x20
#define CMD_ENT_INVERT_MODE 0x21
// Display Commands
#define CMD_SET_GAMMA 0x26
#define CMD_BLANK_DISPLAY 0x28
#define CMD_ON_DISPLAY 0x29
// Memory Access Commands
#define CMD_SET_COLUMN 0x2A
#define CMD_SET_PAGE 0x2B
#define CMD_WR_MEMSTART 0x2C
#define CMD_RD_MEMSTART 0x2E
#define CMD_WR_MEM_AUTO 0x3C
#define CMD_RD_MEM_AUTO 0x3E
// Area and Scrolling Commands
#define CMD_SET_PARTIAL_AREA 0x30
#define CMD_SET_SCROLL_AREA 0x33
#define CMD_SET_SCROLL_START 0x37
// Tearing Effect Commands
#define CMD_SET_TEAR_OFF 0x34 // Sync information is not sent from display
#define CMD_SET_TEAR_ON 0x35 // Sync information is sent from display
#define CMD_SET_TEAR_SCANLINE 0x44
#define CMD_GET_SCANLINE 0x45
// Configuration Commands
#define CMD_SET_ADDR_MODE 0x36 // Set frame buffer read order to display panel
#define CMD_SET_PIXEL_FORMAT 0x3A // Defines how many bits per pixel is used
// Idle Mode Commands
#define CMD_EXIT_IDLE_MODE 0x38
#define CMD_ENT_IDLE_MODE 0x39
// Read Display Data Commands
#define CMD_RD_DDB_START 0xA1
#define CMD_RD_DDB_AUTO 0xA8
// Panel Mode Commands
#define CMD_SET_PANEL_MODE 0xB0
#define CMD_GET_PANEL_MODE 0xB1
// Timing Configuration Commands
#define CMD_SET_HOR_PERIOD 0xB4
#define CMD_GET_HOR_PERIOD 0xB5
#define CMD_SET_VER_PERIOD 0xB6
#define CMD_GET_VER_PERIOD 0xB7
// GPIO Configuration Commands
#define CMD_SET_GPIO_CONF 0xB8
#define CMD_GET_GPIO_CONF 0xB9
#define CMD_SET_GPIO_VAL 0xBA
#define CMD_GET_GPIO_STATUS 0xBB
// Post Processing Commands
#define CMD_SET_POST_PROC 0xBC
#define CMD_GET_POST_PROC 0xBD
// PWM Configuration Commands
#define CMD_SET_PWM_CONF 0xBE
#define CMD_GET_PWM_CONF 0xBF
// LCD Signal Generator Commands
#define CMD_SET_LCD_GEN0 0xC0
#define CMD_GET_LCD_GEN0 0xC1
#define CMD_SET_LCD_GEN1 0xC2
#define CMD_GET_LCD_GEN1 0xC3
#define CMD_SET_LCD_GEN2 0xC4
#define CMD_GET_LCD_GEN2 0xC5
#define CMD_SET_LCD_GEN3 0xC6
#define CMD_GET_LCD_GEN3 0xC7
// GPIO ROP (Raster Operation) Commands
#define CMD_SET_GPIO0_ROP 0xC8
#define CMD_GET_GPIO0_ROP 0xC9
#define CMD_SET_GPIO1_ROP 0xCA
#define CMD_GET_GPIO1_ROP 0xCB
#define CMD_SET_GPIO2_ROP 0xCC
#define CMD_GET_GPIO2_ROP 0xCD
#define CMD_SET_GPIO3_ROP 0xCE
#define CMD_GET_GPIO3_ROP 0xCF
// Adaptive Brightness Control (ABC/DBC) Commands
#define CMD_SET_ABC_DBC_CONF 0xD0
#define CMD_GET_ABC_DBC_CONF 0xD1
#define CMD_SET_DBC_HISTO_PTR 0xD2
#define CMD_GET_DBC_HISTO_PTR 0xD3
#define CMD_SET_DBC_THRES 0xD4
#define CMD_GET_DBC_THRES 0xD5
#define CMD_SET_ABM_TMR 0xD6
#define CMD_GET_ABM_TMR 0xD7
// Ambient Light Level Commands
#define CMD_SET_AMB_LVL0 0xD8
#define CMD_GET_AMB_LVL0 0xD9
#define CMD_SET_AMB_LVL1 0xDA
#define CMD_GET_AMB_LVL1 0xDB
#define CMD_SET_AMB_LVL2 0xDC
#define CMD_GET_AMB_LVL2 0xDD
#define CMD_SET_AMB_LVL3 0xDE
#define CMD_GET_AMB_LVL3 0xDF
// PLL Commands
#define CMD_PLL_START 0xE0 // Start the PLL
#define CMD_PLL_STOP 0xE1 // Disable the PLL
#define CMD_SET_PLL_MN 0xE2
#define CMD_GET_PLL_MN 0xE3
#define CMD_GET_PLL_STATUS 0xE4 // Get the current PLL status
#define CMD_ENT_DEEP_SLEEP 0xE5
// Pixel Clock Commands
#define CMD_SET_PCLK 0xE6 // Set pixel clock (LSHIFT signal) frequency
#define CMD_GET_PCLK 0xE7 // Get pixel clock (LSHIFT signal) freq. settings
// Data Interface Commands
#define CMD_SET_DATA_INTERFACE 0xF0
#define CMD_GET_DATA_INTERFACE 0xF1
/* ==============================================================================================================
* ILI9341 COMMAND SET (for compatibility)
* ============================================================================================================== */
#define ILI9341_SLPIN 0x10
#define ILI9341_SLPOUT 0x11
#define ILI9341_PTLON 0x12
#define ILI9341_NORON 0x13
#define ILI9341_INVOFF 0x20
#define ILI9341_INVON 0x21
#define ILI9341_GAMMASET 0x26
#define ILI9341_DISPOFF 0x28
#define ILI9341_DISPON 0x29
#define ILI9341_PTLAR 0x30
#define ILI9341_VSCRDEF 0x33
#define ILI9341_MADCTL 0x36
#define ILI9341_VSCRSADD 0x37
#define ILI9341_PIXFMT 0x3A
#define ILI9341_FRMCTR1 0xB1
#define ILI9341_FRMCTR2 0xB2
#define ILI9341_FRMCTR3 0xB3
#define ILI9341_INVCTR 0xB4
#define ILI9341_DFUNCTR 0xB6
#define ILI9341_PWCTR1 0xC0
#define ILI9341_PWCTR2 0xC1
#define ILI9341_PWCTR3 0xC2
#define ILI9341_PWCTR4 0xC3
#define ILI9341_PWCTR5 0xC4
#define ILI9341_VMCTR1 0xC5
#define ILI9341_VMCTR2 0xC7
#define ILI9341_GMCTRP1 0xE0
#define ILI9341_GMCTRN1 0xE1
/* ==============================================================================================================
* PIN MAPPING MACROS - SSD1963 Control Pins
* ============================================================================================================== */
#define SSD1963_DC_PIN PINMAP[Option.SSD_DC]
#define SSD1963_WR_PIN PINMAP[Option.SSD_WR]
#define SSD1963_RD_PIN PINMAP[Option.SSD_RD]
#define SSD1963_RESET_PIN PINMAP[Option.SSD_RESET]
#define SSD1963_DC_GPPIN Option.SSD_DC
#define SSD1963_WR_GPPIN Option.SSD_WR
#define SSD1963_RD_GPPIN Option.SSD_RD
#define SSD1963_RESET_GPPIN Option.SSD_RESET
/* ==============================================================================================================
* PIN MAPPING MACROS - SSD1963 Data Pins (8-bit and 16-bit modes)
* ============================================================================================================== */
#define SSD1963_DAT1 Option.SSD_DATA
#define SSD1963_DAT2 PINMAP[PinDef[Option.SSD_DATA].GPno + 1]
#define SSD1963_DAT3 PINMAP[PinDef[Option.SSD_DATA].GPno + 2]
#define SSD1963_DAT4 PINMAP[PinDef[Option.SSD_DATA].GPno + 3]
#define SSD1963_DAT5 PINMAP[PinDef[Option.SSD_DATA].GPno + 4]
#define SSD1963_DAT6 PINMAP[PinDef[Option.SSD_DATA].GPno + 5]
#define SSD1963_DAT7 PINMAP[PinDef[Option.SSD_DATA].GPno + 6]
#define SSD1963_DAT8 PINMAP[PinDef[Option.SSD_DATA].GPno + 7]
#define SSD1963_DAT9 PINMAP[PinDef[Option.SSD_DATA].GPno + 8]
#define SSD1963_DAT10 PINMAP[PinDef[Option.SSD_DATA].GPno + 9]
#define SSD1963_DAT11 PINMAP[PinDef[Option.SSD_DATA].GPno + 10]
#define SSD1963_DAT12 PINMAP[PinDef[Option.SSD_DATA].GPno + 11]
#define SSD1963_DAT13 PINMAP[PinDef[Option.SSD_DATA].GPno + 12]
#define SSD1963_DAT14 PINMAP[PinDef[Option.SSD_DATA].GPno + 13]
#define SSD1963_DAT15 PINMAP[PinDef[Option.SSD_DATA].GPno + 14]
#define SSD1963_DAT16 PINMAP[PinDef[Option.SSD_DATA].GPno + 15]
#define SSD1963_GPDAT1 PinDef[Option.SSD_DATA].GPno
#define SSD1963_GPDAT2 SSD1963_GPDAT1 + 1
#define SSD1963_GPDAT3 SSD1963_GPDAT1 + 2
#define SSD1963_GPDAT4 SSD1963_GPDAT1 + 3
#define SSD1963_GPDAT5 SSD1963_GPDAT1 + 4
#define SSD1963_GPDAT6 SSD1963_GPDAT1 + 5
#define SSD1963_GPDAT7 SSD1963_GPDAT1 + 6
#define SSD1963_GPDAT8 SSD1963_GPDAT1 + 7
#define SSD1963_GPDAT9 SSD1963_GPDAT1 + 8
#define SSD1963_GPDAT10 SSD1963_GPDAT1 + 9
#define SSD1963_GPDAT11 SSD1963_GPDAT1 + 10
#define SSD1963_GPDAT12 SSD1963_GPDAT1 + 11
#define SSD1963_GPDAT13 SSD1963_GPDAT1 + 12
#define SSD1963_GPDAT14 SSD1963_GPDAT1 + 13
#define SSD1963_GPDAT15 SSD1963_GPDAT1 + 14
#define SSD1963_GPDAT16 SSD1963_GPDAT1 + 15
/* ==============================================================================================================
* GLOBAL VARIABLES - Display Panel Parameters
* Refer to the glass data sheet for specific values
* ============================================================================================================== */
extern int SSD1963HorizPulseWidth;
extern int SSD1963HorizBackPorch;
extern int SSD1963HorizFrontPorch;
extern int SSD1963VertPulseWidth;
extern int SSD1963VertBackPorch;
extern int SSD1963VertFrontPorch;
extern int SSD1963PClock1;
extern int SSD1963PClock2;
extern int SSD1963PClock3;
extern int SSD1963Mode1;
extern int SSD1963Mode2;
extern volatile int ScrollStart;
extern int display_backlight;
extern int SSD1963data;
/* ==============================================================================================================
* GLOBAL VARIABLES - Cursor and Touch Timing
* ============================================================================================================== */
extern volatile int CursorTimer; // Used to time the flashing cursor
extern volatile int ClickTimer; // Used to time the click when touch occurs
extern volatile int TouchTimer; // Used to time the response to touch
/* ==============================================================================================================
* GLOBAL VARIABLES - Pin Mapping
* ============================================================================================================== */
#ifdef rp2350
extern const uint8_t PINMAP[48];
#else
extern const uint8_t PINMAP[30];
#endif
/* ==============================================================================================================
* FUNCTION POINTERS
* ============================================================================================================== */
extern void (*WriteColor)(unsigned int c);
/* ==============================================================================================================
* FUNCTION PROTOTYPES - Initialization
* ============================================================================================================== */
extern void InitSSD1963(void);
extern void InitILI9341(void);
extern void InitILI9341_8(void);
extern void InitDisplaySSD(void);
extern void ConfigDisplaySSD(unsigned char *p);
/* ==============================================================================================================
* FUNCTION PROTOTYPES - Display Control
* ============================================================================================================== */
extern void SetBacklightSSD1963(int intensity);
extern void SetTearingCfg(int state, int mode);
extern void ShowCursor(int show);
extern void ScrollSSD1963(int lines);
/* ==============================================================================================================
* FUNCTION PROTOTYPES - Text Output
* ============================================================================================================== */
extern void DisplayPutC(char c);
extern void DisplayPutS(char *s);
/* ==============================================================================================================
* FUNCTION PROTOTYPES - Low-Level Commands
* ============================================================================================================== */
extern void WriteComand(int cmd);
extern void WriteData(int data);
extern void WriteData16bit(int data);
extern void Write16bitCommand(int cmd);
#if PICOMITERP2350
// Optional RAM-resident specs for flash-sensitive paths
extern void __not_in_flash_func(WriteComand)(int cmd);
extern void __not_in_flash_func(WriteData)(int data);
#endif
/* ==============================================================================================================
* FUNCTION PROTOTYPES - Area Definition
* ============================================================================================================== */
extern void SetAreaSSD1963(int x1, int y1, int x2, int y2);
extern void SetAreaILI9341(int xstart, int ystart, int xend, int yend, int rw);
extern void SetAreaIPS_4_16(int xstart, int ystart, int xend, int yend, int rw);
#if PICOMITERP2350
extern void __not_in_flash_func(SetAreaSSD1963)(int x1, int y1, int x2, int y2);
#endif
/* ==============================================================================================================
* FUNCTION PROTOTYPES - Drawing Operations (SSD1963)
* ============================================================================================================== */
extern void DrawBitmapSSD1963(int x1, int y1, int width, int height, int scale, int fg, int bg, unsigned char *bitmap);
extern void DrawBufferSSD1963(int x1, int y1, int x2, int y2, unsigned char *p);
extern void DrawBLITBufferSSD1963(int x1, int y1, int x2, int y2, unsigned char *p);
extern void DrawRectangleSSD1963(int x1, int y1, int x2, int y2, int c);
/* ==============================================================================================================
* FUNCTION PROTOTYPES - Reading Operations (SSD1963)
* ============================================================================================================== */
extern void ReadBufferSSD1963(int x1, int y1, int x2, int y2, unsigned char *p);
extern void ReadBLITBufferSSD1963(int x1, int y1, int x2, int y2, unsigned char *p);
/* ==============================================================================================================
* FUNCTION PROTOTYPES - Drawing Operations (320x240 Displays)
* ============================================================================================================== */
extern void DrawBitmap320(int x1, int y1, int width, int height, int scale, int fg, int bg, unsigned char *bitmap);
extern void DrawBuffer320(int x1, int y1, int x2, int y2, unsigned char *p);
extern void DrawBLITBuffer320(int x1, int y1, int x2, int y2, unsigned char *p);
extern void DrawRectangle320(int x1, int y1, int x2, int y2, int c);
/* ==============================================================================================================
* FUNCTION PROTOTYPES - Reading Operations (320x240 Displays)
* ============================================================================================================== */
extern void ReadBuffer320(int x1, int y1, int x2, int y2, unsigned char *p);
extern void ReadBLITBuffer320(int x1, int y1, int x2, int y2, unsigned char *p);
/* ==============================================================================================================
* FUNCTION PROTOTYPES - IPS Display Commands
* ============================================================================================================== */
extern void WriteCmdDataIPS_4_16(int cmd, int n, int data);
#endif // _SSD1963_H
/* @endcond */