?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 * Himax. HX8257 TCON driver
4 *****************************************************************************
5 * FileName: TCON_HX8257.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 01/12/09
39 *****************************************************************************/
40 #include "Graphics\Graphics.h"
41  
42 #define CS 0x01
43 #define SCL 0x02
44 #define SDO 0x04
45  
46 BYTE value;
47  
48 /* */
49  
50 void TCON_Delay(void)
51 {
52 WORD timeOut;
53 timeOut = 200;
54 while(timeOut--);
55 }
56  
57 /* */
58 void TCON_CTRL(BYTE mask, BYTE level)
59 {
60 if(level == 0)
61 {
62 value &= ~mask;
63 }
64 else
65 {
66 value |= mask;
67 }
68  
69 SetReg(0xAC, value);
70 }
71  
72 /* */
73 void TCONWriteByte(BYTE value)
74 {
75 BYTE mask;
76  
77 mask = 0x80;
78 while(mask)
79 {
80 TCON_CTRL(SCL, 0);
81 TCON_Delay();
82 if(mask & value)
83 {
84 TCON_CTRL(SDO, 1);
85 }
86 else
87 {
88 TCON_CTRL(SDO, 0);
89 }
90  
91 TCON_CTRL(SCL, 1);
92 mask >>= 1;
93 }
94 }
95  
96 /* */
97 void GPIO_TCON(WORD index, WORD value)
98 {
99 TCON_CTRL(CS, 0);
100  
101 // Index
102 TCONWriteByte(0x70);
103 TCONWriteByte(((WORD_VAL) index).v[1]);
104 TCONWriteByte(((WORD_VAL) index).v[0]);
105  
106 TCON_CTRL(CS, 1);
107 TCON_Delay();
108 TCON_CTRL(CS, 0);
109  
110 // Data
111 TCONWriteByte(0x72);
112 TCONWriteByte(((WORD_VAL) value).v[1]);
113 TCONWriteByte(((WORD_VAL) value).v[0]);
114 TCON_CTRL(CS, 1);
115 TCON_Delay();
116 }
117  
118 /* */
119 void TCON_Init(void)
120 {
121 SetReg(0xA8, CS | SDO | SCL);
122 TCON_CTRL(CS, 1);
123 TCON_CTRL(SDO, 1);
124 TCON_CTRL(SCL, 1);
125  
126 DelayMs(20);
127 GPIO_TCON(0x0006, 0x2020);
128 DelayMs(20);
129 }
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3