Landtiger LPC1768 C BigLib 1
A self made, custom C library for the LandTiger board.
 
Loading...
Searching...
No Matches
glcd_lowlevel.h File Reference
#include "types.h"

Go to the source code of this file.

Functions

void __LCD_LL_Init (u16 orientation)
 
u16 __LCD_LL_GetPointColor (u16 x, u16 y)
 
void __LCD_LL_SetPointColor (u16 rgb565, u16 x, u16 y)
 
void __LCD_LL_FillScreen (u16 color)
 

Function Documentation

◆ __LCD_LL_FillScreen()

void __LCD_LL_FillScreen ( u16  color)

Definition at line 374 of file glcd_lowlevel.c.

375{
376 // Sets the GRAM cursor to the top-left corner of the display
378 {
379 write_to(0x02, 0x00);
380 write_to(0x03, 0x00);
381 write_to(0x04, 0x00);
382 write_to(0x05, 0xEF);
383 write_to(0x06, 0x00);
384 write_to(0x07, 0x00);
385 write_to(0x08, 0x01);
386 write_to(0x09, 0x3F);
387 }
388 else
389 set_gram_cursor(0, 0);
390
391 init_rw_operation_at(0x0022); // Write GRAM
392 for (u32 index = 0; index < LCDMaxX * LCDMaxY; index++)
393 do_write(color & 0xFFFF);
394}
_DECL_EXTERNALLY u16 LCDMaxY
_PRIVATE void set_gram_cursor(u16 x, u16 y)
Sets the GRAM cursor to the specified coordinates, for writing data into the appropriate pixel in the...
_PRIVATE void write_to(u16 reg, u16 data)
Writes a 16-bit value to the LCD controller, at the specified register.
_PRIVATE u8 s_model_code
The model code of the LCD controller.
_PRIVATE void init_rw_operation_at(u16 index)
Tells the LCD controller to initiate a R/W operation with the register at the index specified.
@ HX8347A
@ HX8347D
_DECL_EXTERNALLY u16 LCDMaxX
The maximum X and Y coordinates of the screen.
_PRIVATE void do_write(u16 data)
Writes an half-word (16 bits) into the LCD's DB port, destined to the register at the index selected ...
uint32_t u32
Definition types.h:6

◆ __LCD_LL_GetPointColor()

u16 __LCD_LL_GetPointColor ( u16  x,
u16  y 
)

Definition at line 334 of file glcd_lowlevel.c.

335{
336 u16 dummy;
337
338 set_gram_cursor(x, y);
339 init_rw_operation_at(0x0022); // Write GRAM
340
341 switch (s_model_code)
342 {
343 case ST7781:
344 case LGDP4531:
345 case LGDP4535:
346 case SSD1289:
347 case SSD1298:
348 dummy = do_read(); /* Empty read */
349 dummy = do_read();
350 return dummy;
351 case HX8347A:
352 case HX8347D: {
353 dummy = do_read(); /* Empty read */
354
355 const u8 red = do_read() >> 3;
356 const u8 green = do_read() >> 2;
357 const u8 blue = do_read() >> 3;
358 dummy = (u16)((red << 11) | (green << 5) | blue);
359 return dummy;
360 }
361 default: /* 0x9320 0x9325 0x9328 0x9331 0x5408 0x1505 0x0505 0x9919 */
362 dummy = do_read(); /* Empty read */
363 dummy = do_read();
364 return dummy;
365 }
366}
@ SSD1298
@ ST7781
@ LGDP4535
@ SSD1289
@ LGDP4531
_PRIVATE u16 do_read(void)
Reads an half-word (16 bits) from the LCD's DB port, from the register at the index selected with the...
uint8_t u8
Definition types.h:8
uint16_t u16
Definition types.h:7

◆ __LCD_LL_Init()

void __LCD_LL_Init ( u16  orientation)

Definition at line 228 of file glcd_lowlevel.c.

229{
230 // Setting PINS as 00 (GPIO) in PINSEL0 (bit 6 to 25) for P0.19 to P0.25
231 // 0000 0011 1111 1111 1111 1111 1100 0000
232 LPC_PINCON->PINSEL1 &= ~(0x03FFFFC0);
233
234 // Setting 00 in PINSEL4 (bit 0 to 15) for P2.0 to P2.7
235 // 0000 0000 0000 0000 1111 1111 1111 1111
236 LPC_PINCON->PINSEL4 &= ~(0x0000FFFF);
237
238 /* EN = P0.19 , LE = P0.20 , DIR = P0.21 , CS = P0.22 , RS = P0.23 , RS = P0.23 */
239 /* RS = P0.23 , WR = P0.24 , RD = P0.25 , DB[0.7] = P2.0...P2.7 , DB[8.15]= P2.0...P2.7 */
240 LPC_GPIO0->FIODIR |= 0x03f80000;
241 LPC_GPIO0->FIOSET = 0x03f80000;
242
243 s_orientation = orientation;
244 if (orientation == LCD_ORIENT_VER || orientation == LCD_ORIENT_VER_INV)
245 {
246 LCDMaxX = 240;
247 LCDMaxY = 320;
248 }
249 else
250 {
251 LCDMaxX = 320;
252 LCDMaxY = 240;
253 }
254
255 DELAY_MS(100);
256 const u16 code = read_from(0x0000);
257 if (code == 0x9325 || code == 0x9328)
258 {
260 write_to(0x00e7, 0x0010); // Test Register
261 write_to(0x0000, 0x0001); // Starts internal OSC
262 write_to(0x0001, 0x0100); // Output driver control
263
264 write_to(0x0002, 0x0700); // LCD Driver Waveform Control
265 write_to(0x0003, (1 << 12) | (1 << 5) | (1 << 4) | (0 << 3)); // Entry mode
266 write_to(0x0004, 0x0000); // Resizing Function
267 write_to(0x0008, 0x0207); // Back and Front porch periods
268 write_to(0x0009, 0x0000); // Non-Display Area refresh cycle
269 write_to(0x000a, 0x0000); // Frame cycle
270 write_to(0x000c, 0x0001);
271 write_to(0x000d, 0x0000);
272 write_to(0x000f, 0x0000);
273
274 // Power Control
275 write_to(0x0010, 0x0000);
276 write_to(0x0011, 0x0007);
277 write_to(0x0012, 0x0000);
278 write_to(0x0013, 0x0000);
279 DELAY_MS(50);
280 write_to(0x0010, 0x1590);
281 write_to(0x0011, 0x0227);
282 DELAY_MS(50);
283 write_to(0x0012, 0x009c);
284 DELAY_MS(50);
285 write_to(0x0013, 0x1900);
286 write_to(0x0029, 0x0023);
287
288 write_to(0x002b, 0x000e); // Frate rate & Color control
289 DELAY_MS(50);
290 write_to(0x0020, 0x0000); // GRAM horizontal Address
291 write_to(0x0021, 0x0000); // GRAM Vertical Address
292
293 DELAY_MS(50);
294 write_to(0x0030, 0x0007);
295 write_to(0x0031, 0x0707);
296 write_to(0x0032, 0x0006);
297 write_to(0x0035, 0x0704);
298 write_to(0x0036, 0x1f04);
299 write_to(0x0037, 0x0004);
300 write_to(0x0038, 0x0000);
301 write_to(0x0039, 0x0706);
302 write_to(0x003c, 0x0701);
303 write_to(0x003d, 0x000f);
304 DELAY_MS(50);
305 write_to(0x0050, 0x0000);
306 write_to(0x0051, 0x00ef);
307 write_to(0x0052, 0x0000);
308 write_to(0x0053, 0x013f);
309 write_to(0x0060, 0xa700);
310 write_to(0x0061, 0x0001);
311 write_to(0x006a, 0x0000);
312 write_to(0x0080, 0x0000);
313 write_to(0x0081, 0x0000);
314 write_to(0x0082, 0x0000);
315 write_to(0x0083, 0x0000);
316 write_to(0x0084, 0x0000);
317 write_to(0x0085, 0x0000);
318 write_to(0x0090, 0x0010);
319 write_to(0x0092, 0x0000);
320 write_to(0x0093, 0x0003);
321 write_to(0x0095, 0x0110);
322 write_to(0x0097, 0x0000);
323 write_to(0x0098, 0x0000);
324
325 // Display On Sequence
326 write_to(0x0007, 0x0133);
327 write_to(0x0020, 0x0000);
328 write_to(0x0021, 0x0000);
329 }
330
331 DELAY_MS(50);
332}
_PRIVATE u16 s_orientation
The current orientation of the screen.
#define DELAY_MS(ms)
_PRIVATE u16 read_from(u16 reg)
Reads an HW from the LCD controller, at the specified register.
@ ILI9325
@ LCD_ORIENT_VER_INV
Definition glcd_types.h:15
@ LCD_ORIENT_VER
Definition glcd_types.h:13

◆ __LCD_LL_SetPointColor()

void __LCD_LL_SetPointColor ( u16  rgb565,
u16  x,
u16  y 
)

Definition at line 368 of file glcd_lowlevel.c.

369{
370 set_gram_cursor(x, y);
371 write_to(0x0022, rgb565 & 0xFFFF);
372}