GLCD Library
A C Library for Embedded Applications
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
LPC11Uxx.h
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 #ifndef DEVICE_LPC11UXX_H
36 #define DEVICE_LPC11UXX_H
37 
43 #if defined(GLCD_DEVICE_LPC11UXX)
44 
45 #define swap(a, b) { uint8_t t = a; a = b; b = t; }
46 
47 #if !defined(GLCD_USE_PARALLEL)
48  /* SPI interface */
49 
50  /* Define port and pins used to connecto LCD */
51  #define CONTROLLER_SPI_PORT_NUMBER 1
52  #define CONTROLLER_MOSI_PORT LPC_GPIO2
53  #define CONTROLLER_MOSI_PIN 3
54  #define CONTROLLER_MISO_PORT LPC_GPIO2
55  #define CONTROLLER_MISO_PIN 2
56  #define CONTROLLER_SCK_PORT LPC_GPIO2
57  #define CONTROLLER_SCK_PIN 1
58  #define CONTROLLER_SS_PORT LPC_GPIO2
59  #define CONTROLLER_SS_PIN 0
60  #define CONTROLLER_DC_PORT LPC_GPIO2
61  #define CONTROLLER_DC_PIN 4
62  #define CONTROLLER_RST_PORT LPC_GPIO2
63  #define CONTROLLER_RST_PIN 5
64 
65  /* Preprocessor macros */
66  #define GLCD_SELECT() CONTROLLER_SS_PORT->DATA &= ~(1 << CONTROLLER_SS_PIN)
67  #define GLCD_DESELECT() CONTROLLER_SS_PORT->DATA |= (1 << CONTROLLER_SS_PIN)
68  #define GLCD_DC_LOW() CONTROLLER_DC_PORT->DATA &= ~(1 << CONTROLLER_DC_PIN)
69  #define GLCD_DC_HIGH() CONTROLLER_DC_PORT->DATA |= (1 << CONTROLLER_DC_PIN)
70  #define GLCD_RESET_LOW() CONTROLLER_RST_PORT->DATA &= ~(1 << CONTROLLER_RST_PIN)
71  #define GLCD_RESET_HIGH() CONTROLLER_RST_PORT->DATA |= (1 << CONTROLLER_RST_PIN)
72 
73 #else
74  /* Parallel interface */
75 
76  #define CONTROLLER_LCD_EN_PORT 0
77  #define CONTROLLER_LCD_EN_PIN 12
78  #define CONTROLLER_LCD_RW_PORT 0
79  #define CONTROLLER_LCD_RW_PIN 13
80  #define CONTROLLER_LCD_RS_PORT 0
81  #define CONTROLLER_LCD_RS_PIN 14
82  #define CONTROLLER_LCD_CS_PORT 1
83  #define CONTROLLER_LCD_CS_PIN 13
85  #define CONTROLLER_LCD_D0_PORT 1
86  #define CONTROLLER_LCD_D1_PORT 1
87  #define CONTROLLER_LCD_D2_PORT 1
88  #define CONTROLLER_LCD_D3_PORT 1
89  #define CONTROLLER_LCD_D4_PORT 1
90  #define CONTROLLER_LCD_D5_PORT 1
91  #define CONTROLLER_LCD_D6_PORT 1
92  #define CONTROLLER_LCD_D7_PORT 1
93 
94  #define CONTROLLER_LCD_D0_PIN 19
95  #define CONTROLLER_LCD_D1_PIN 20
96  #define CONTROLLER_LCD_D2_PIN 21
97  #define CONTROLLER_LCD_D3_PIN 22
98  #define CONTROLLER_LCD_D4_PIN 26
99  #define CONTROLLER_LCD_D5_PIN 27
100  #define CONTROLLER_LCD_D6_PIN 28
101  #define CONTROLLER_LCD_D7_PIN 31
102 
103 #if (CONTROLLER_LCD_D1_PORT == CONTROLLER_LCD_D0_PORT) && \
104  (CONTROLLER_LCD_D2_PORT == CONTROLLER_LCD_D0_PORT) && \
105  (CONTROLLER_LCD_D3_PORT == CONTROLLER_LCD_D0_PORT) && \
106  (CONTROLLER_LCD_D4_PORT == CONTROLLER_LCD_D0_PORT) && \
107  (CONTROLLER_LCD_D5_PORT == CONTROLLER_LCD_D0_PORT) && \
108  (CONTROLLER_LCD_D6_PORT == CONTROLLER_LCD_D0_PORT) && \
109  (CONTROLLER_LCD_D7_PORT == CONTROLLER_LCD_D0_PORT)
110  /* All data pins are on the same port */
111  #define CONTROLLER_LCD_DATA_PORT 1
112 
113  #define GLCD_PARALLEL_MASK ( \
114  (1U<<CONTROLLER_LCD_D0_PIN)| \
115  (1U<<CONTROLLER_LCD_D1_PIN)| \
116  (1U<<CONTROLLER_LCD_D2_PIN)| \
117  (1U<<CONTROLLER_LCD_D3_PIN)| \
118  (1U<<CONTROLLER_LCD_D4_PIN)| \
119  (1U<<CONTROLLER_LCD_D5_PIN)| \
120  (1U<<CONTROLLER_LCD_D6_PIN)| \
121  (1U<<CONTROLLER_LCD_D7_PIN) \
122  )
123 
124  #define GLCD_EN_LOW() LPC_GPIO->CLR[CONTROLLER_LCD_EN_PORT] |= (1U<<CONTROLLER_LCD_EN_PIN);
125  #define GLCD_EN_HIGH() LPC_GPIO->SET[CONTROLLER_LCD_EN_PORT] |= (1U<<CONTROLLER_LCD_EN_PIN);
126  #define GLCD_RW_LOW() LPC_GPIO->CLR[CONTROLLER_LCD_RW_PORT] |= (1U<<CONTROLLER_LCD_RW_PIN);
127  #define GLCD_RW_HIGH() LPC_GPIO->SET[CONTROLLER_LCD_RW_PORT] |= (1U<<CONTROLLER_LCD_RW_PIN);
128  #define GLCD_RS_LOW() LPC_GPIO->CLR[CONTROLLER_LCD_RS_PORT] |= (1U<<CONTROLLER_LCD_RS_PIN);
129  #define GLCD_RS_HIGH() LPC_GPIO->SET[CONTROLLER_LCD_RS_PORT] |= (1U<<CONTROLLER_LCD_RS_PIN);
130  #define GLCD_CS_LOW() LPC_GPIO->CLR[CONTROLLER_LCD_CS_PORT] |= (1U<<CONTROLLER_LCD_CS_PIN);
131  #define GLCD_CS_HIGH() LPC_GPIO->SET[CONTROLLER_LCD_CS_PORT] |= (1U<<CONTROLLER_LCD_CS_PIN);
132 
133 #else /* All parallel data pins on same port */
134  #undef CONTROLLER_LCD_DATA_PORT
135 #endif
136 
137 #endif /* not use GLCD_USE_SPI */
138 
139 #endif /* GLCD_DEVICE_LPC11UXX */
140 
141 #endif /* DEVICE_LPC11UXX_H */