?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /*****************************************************************************
2 * Module for Microchip Graphics Library
3 * Solomon Systech. SSD1289 TCON driver
4 *****************************************************************************
5 * FileName: TCON_SSD1289.c
6 * Dependencies: Graphics.h
7 * Processor: PIC24, PIC32
8 * Compiler: MPLAB C30, MPLAB C32
9 * Linker: MPLAB LINK30, MPLAB LINK32
10 * Company: Microchip Technology Incorporated
11 *
12 * Software License Agreement
13 *
14 * Copyright © 2008 Microchip Technology Inc. All rights reserved.
15 * Microchip licenses to you the right to use, modify, copy and distribute
16 * Software only when embedded on a Microchip microcontroller or digital
17 * signal controller, which is integrated into your product or third party
18 * product (pursuant to the sublicense terms in the accompanying license
19 * agreement).
20 *
21 * You should refer to the license agreement accompanying this Software
22 * for additional information regarding your rights and obligations.
23 *
24 * SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY
25 * KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY
26 * OF MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR
27 * PURPOSE. IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR
28 * OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION,
29 * BREACH OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT
30 * DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL,
31 * INDIRECT, PUNITIVE OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
32 * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY
33 * CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
34 * OR OTHER SIMILAR COSTS.
35 *
36 * Author Date Comment
37 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38 * Anton Alkhimenok 11/17/08
39 * PAT 04/05/10 Modified initialization to reduce flicker.
40 *****************************************************************************/
41 #include "Graphics\Graphics.h"
42  
43 #define CS 0x01
44 #define SCL 0x02
45 #define SDO 0x04
46 #define DC 0x08
47 #define BL 0x10
48  
49 BYTE value;
50  
51 /* */
52  
53 void TCON_Delay(void)
54 {
55 WORD timeOut;
56 timeOut = 200;
57 while(timeOut--);
58 }
59  
60 /* */
61 void TCON_CTRL(BYTE mask, BYTE level)
62 {
63 #if (DISPLAY_CONTROLLER == MCHP_DA210)
64  
65 switch(mask)
66 {
67 case CS: CS_PORT = level;
68 break;
69  
70 case SCL: SCL_PORT = level;
71 break;
72  
73 case SDO: SDO_PORT = level;
74 break;
75  
76 case DC: DC_PORT = level;
77 break;
78 }
79  
80 Nop();
81  
82 #else
83  
84 if(level == 0)
85 {
86 value &= ~mask;
87 }
88 else
89 {
90 value |= mask;
91 }
92  
93 SetReg(0xAC, value);
94  
95 #endif
96 }
97  
98 /* */
99 void TCONWriteByte(BYTE value)
100 {
101 BYTE mask;
102  
103 mask = 0x80;
104 while(mask)
105 {
106 TCON_CTRL(SCL, 0);
107 TCON_Delay();
108 if(mask & value)
109 {
110 TCON_CTRL(SDO, 1);
111 }
112 else
113 {
114 TCON_CTRL(SDO, 0);
115 }
116  
117 TCON_CTRL(SCL, 1);
118 mask >>= 1;
119 }
120 }
121  
122 /* */
123 void GPIO_TCON(WORD index, WORD value)
124 {
125 TCON_CTRL(CS, 0);
126  
127 // Index
128 TCON_CTRL(DC, 0);
129 TCONWriteByte(((WORD_VAL) index).v[1]);
130 TCONWriteByte(((WORD_VAL) index).v[0]);
131  
132 TCON_CTRL(CS, 1);
133 TCON_Delay();
134 TCON_CTRL(CS, 0);
135  
136 // Data
137 TCON_CTRL(DC, 1);
138 TCONWriteByte(((WORD_VAL) value).v[1]);
139 TCONWriteByte(((WORD_VAL) value).v[0]);
140 TCON_CTRL(CS, 1);
141 TCON_Delay();
142 }
143  
144 /* */
145 void TCON_Init(void)
146 {
147 #if (DISPLAY_CONTROLLER == MCHP_DA210)
148  
149 WORD CS_TRIS_temp = CS_TRIS;
150 WORD SCL_TRIS_temp = SCL_TRIS;
151 WORD SDO_TRIS_temp = SDO_TRIS;
152 WORD DC_TRIS_temp = DC_TRIS;
153  
154 CS_DIG();
155 CS_PORT = 1;
156 CS_TRIS = 0;
157  
158 SCL_DIG();
159 SCL_PORT = 1;
160 SCL_TRIS = 0;
161  
162 SDO_DIG();
163 SDO_PORT = 1;
164 SDO_TRIS = 0;
165  
166 DC_DIG();
167 DC_PORT = 1;
168 DC_TRIS = 0;
169  
170 #else
171  
172 SetReg(0xA8, BL| DC | CS | SDO | SCL);
173 TCON_CTRL(DC, 1);
174 TCON_CTRL(CS, 1);
175 TCON_CTRL(SDO, 1);
176 TCON_CTRL(SCL, 1);
177 TCON_CTRL(BL, 1);
178  
179 #endif
180  
181 GPIO_TCON(0x0028, 0x0006);
182 GPIO_TCON(0x0000, 0x0001);
183 DelayMs(15);
184  
185 GPIO_TCON(0x002B, 0x9532);
186 GPIO_TCON(0x0003, 0xAAAC);
187 GPIO_TCON(0x000C, 0x0002);
188 GPIO_TCON(0x000D, 0x000A);
189 GPIO_TCON(0x000E, 0x2C00);
190 GPIO_TCON(0x001E, 0x00AA);
191 GPIO_TCON(0x0025, 0x8000);
192 DelayMs(15);
193  
194 GPIO_TCON(0x0001, 0x2B3F);
195 GPIO_TCON(0x0002, 0x0600);
196 GPIO_TCON(0x0010, 0x0000);
197 DelayMs(20);
198  
199 GPIO_TCON(0x0005, 0x0000);
200 GPIO_TCON(0x0006, 0x0000);
201  
202  
203 GPIO_TCON(0x0016, 0xEF1C);
204 GPIO_TCON(0x0017, 0x0003);
205 GPIO_TCON(0x0007, 0x0233);
206 GPIO_TCON(0x000B, 0x5312);
207 GPIO_TCON(0x000F, 0x0000);
208 DelayMs(20);
209  
210 GPIO_TCON(0x0041, 0x0000);
211 GPIO_TCON(0x0042, 0x0000);
212 GPIO_TCON(0x0048, 0x0000);
213 GPIO_TCON(0x0049, 0x013F);
214 GPIO_TCON(0x0044, 0xEF00);
215 GPIO_TCON(0x0045, 0x0000);
216 GPIO_TCON(0x0046, 0x013F);
217 GPIO_TCON(0x004A, 0x0000);
218 GPIO_TCON(0x004B, 0x0000);
219 DelayMs(20);
220  
221 GPIO_TCON(0x0030, 0x0707);
222 GPIO_TCON(0x0031, 0x0704);
223 GPIO_TCON(0x0032, 0x0204);
224 GPIO_TCON(0x0033, 0x0201);
225 GPIO_TCON(0x0034, 0x0203);
226 GPIO_TCON(0x0035, 0x0204);
227 GPIO_TCON(0x0036, 0x0204);
228 GPIO_TCON(0x0037, 0x0502);
229 GPIO_TCON(0x003A, 0x0302);
230 GPIO_TCON(0x003B, 0x0500);
231 DelayMs(20);
232  
233 #if (DISPLAY_CONTROLLER == MCHP_DA210)
234 CS_TRIS = CS_TRIS_temp;
235 SCL_TRIS = SCL_TRIS_temp;
236 SDO_TRIS = SDO_TRIS_temp;
237 DC_TRIS = DC_TRIS_temp;
238 #endif
239  
240 }
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3