GLCD Library
A C Library for Embedded Applications
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
LPC111x.c
Go to the documentation of this file.
1 
7 /*
8  Copyright (c) 2012, Andy Gock
9 
10  All rights reserved.
11 
12  Redistribution and use in source and binary forms, with or without
13  modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright
15  notice, this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright
17  notice, this list of conditions and the following disclaimer in the
18  documentation and/or other materials provided with the distribution.
19  * Neither the name of Andy Gock nor the
20  names of its contributors may be used to endorse or promote products
21  derived from this software without specific prior written permission.
22 
23  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  DISCLAIMED. IN NO EVENT SHALL ANDY GOCK BE LIABLE FOR ANY
27  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34 
35 #include "../glcd.h"
36 #include "LPC111x.h"
37 
38 #if defined(GLCD_DEVICE_LPC111X)
39 
40 void glcd_init(void)
41 {
42 
43 #if defined(GLCD_CONTROLLER_PCD8544)
44  /*
45  * Set up SPI (SSP)
46  * Note: Max allowed SPI clock is 4 MHz from datasheet.
47  */
48 
49  /* Select SSP/SPI port */
50  SSP_IOConfig( CONTROLLER_SPI_PORT_NUMBER );
51 
52  /* Initialise SSP/SPI port */
53  SSP_Init( CONTROLLER_SPI_PORT_NUMBER );
54 
55  /* Above functions take care of SPI pins */
56 
57  /* Set SS, DC and RST pins to output */
58  CONTROLLER_SS_PORT->DIR |= (1 << CONTROLLER_SS_PIN);
59  CONTROLLER_DC_PORT->DIR |= (1 << CONTROLLER_DC_PIN);
60  CONTROLLER_RST_PORT->DIR |= (1 << CONTROLLER_RST_PIN);
61 
62  /* Deselect LCD */
63  //GLCD_DESELECT();
64 
65  /* Reset the display */
66  glcd_reset();
67 
68  /* Get into the EXTENDED mode! */
70 
71  /* LCD bias select (4 is optimal?) */
73 
74  /* Set VOP */
75  glcd_command(PCD8544_SET_VOP | 50); // Experimentally determined
76 
77  /* Back to standard instructions */
79 
80  /* Normal mode */
82 
84 
85  glcd_clear();
86 
87 #else /* GLCD_CONTROLLER_PCD8544 */
88  #error "Controller not supported by LPC111x"
89 #endif
90 
91 }
92 
93 void glcd_spi_write(uint8_t c)
94 {
95  GLCD_SELECT();
96  SSP_Send(CONTROLLER_SPI_PORT_NUMBER,&c,1);
97  GLCD_DESELECT();
98 }
99 
100 void glcd_reset(void)
101 {
102  /* Toggle RST low to reset. Minimum pulse 100ns on datasheet. */
103  GLCD_SELECT();
104  GLCD_RESET_LOW();
105  delay_ms(GLCD_RESET_TIME);
106  GLCD_RESET_HIGH();
107  GLCD_DESELECT();
108 }
109 
110 #endif /* GLCD_DEVICE_LPC111x */
#define PCD8544_FUNCTION_SET
Definition: PCD8544.h:43
void glcd_spi_write(uint8_t c)
Write a byte to the connected SPI slave.
#define PCD8544_SET_VOP
Definition: PCD8544.h:75
void glcd_select_screen(uint8_t *buffer, glcd_BoundingBox_t *bbox)
Select screen buffer and bounding box structure.
Definition: glcd.c:133
void glcd_reset(void)
Reset the LCD.
#define PCD8544_EXTENDED_INSTRUCTION
Definition: PCD8544.h:47
#define PCD8544_DISPLAY_NORMAL
Definition: PCD8544.h:56
glcd_BoundingBox_t glcd_bbox
Keeps track of bounding box of area on LCD which need to be updated next reresh cycle.
Definition: glcd.c:55
#define PCD8544_DISPLAY_CONTROL
Definition: PCD8544.h:54
Pinouts and driver config for NXP LPC111x ARM Cortex-M0 MCUs.
#define PCD8544_SET_BIAS
Definition: PCD8544.h:74
void glcd_command(uint8_t c)
Send command byte to LCD.
void glcd_clear(void)
Clear the display.
Definition: glcd.c:122
uint8_t glcd_buffer[GLCD_LCD_WIDTH *GLCD_LCD_HEIGHT/8]
Screen buffer.
Definition: glcd.c:49
#define GLCD_RESET_TIME
Reset duration by glcd_reset(), in milliseconds.
Definition: glcd.h:156
void glcd_init(void)
Initialise the LCD.