| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 32 | kaklik | /***************************************************************************** |
| 2 | * Module for Microchip Graphics Library |
||
| 3 | * Himax HX8238 TCON driver |
||
| 4 | ***************************************************************************** |
||
| 5 | * FileName: TCON_HX8238.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 | *****************************************************************************/ |
||
| 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 | |||
| 128 | GPIO_TCON(0x0001, 0x6300); //Driver Output Control |
||
| 129 | GPIO_TCON(0x0002, 0x0200); //LCD-Driving-Waveform Control:N-line inversion,N=0 |
||
| 130 | GPIO_TCON(0x0003, 0x7184); //Power control 1:Set the step-up cycle of the step-up circuit for 262k-color mode |
||
| 131 | DelayMs(100); |
||
| 132 | GPIO_TCON(0x0004, 0x0447); //Input Data and Color Filter Control |
||
| 133 | GPIO_TCON(0x0005, 0xb854); //Function Control |
||
| 134 | GPIO_TCON(0X000a, 0x4008); //Contrast/Brightness Control |
||
| 135 | |||
| 136 | // GPIO_TCON(0X000a,0xff18);//Contrast/Brightness Control |
||
| 137 | DelayMs(40); |
||
| 138 | GPIO_TCON(0x000b, 0xd400); //Frame Cycle Control |
||
| 139 | GPIO_TCON(0x000d, 0x123a); //Power Control 2 |
||
| 140 | DelayMs(200); |
||
| 141 | GPIO_TCON(0x000e, 0x3000); //Power Control 3 |
||
| 142 | DelayMs(200); |
||
| 143 | GPIO_TCON(0x000f, 0x0000); //Gate Scan Position |
||
| 144 | GPIO_TCON(0x0016, 0x9f80); //Horizontal Porch |
||
| 145 | GPIO_TCON(0x0017, 0x2212); //Vertical Porch |
||
| 146 | DelayMs(200); |
||
| 147 | GPIO_TCON(0x001e, 0x00ef); //Set the VCOMH voltage |
||
| 148 | DelayMs(200); |
||
| 149 | |||
| 150 | GPIO_TCON(0x0030, 0x0507); //Gamma Control |
||
| 151 | GPIO_TCON(0x0031, 0x0004); //Gamma Control |
||
| 152 | GPIO_TCON(0x0032, 0x0707); //Gamma Control |
||
| 153 | GPIO_TCON(0x0033, 0x0000); //Gamma Control |
||
| 154 | GPIO_TCON(0x0034, 0x0000); //Gamma Control |
||
| 155 | GPIO_TCON(0x0035, 0x0307); //Gamma Control |
||
| 156 | GPIO_TCON(0x0036, 0x0700); //Gamma Control |
||
| 157 | GPIO_TCON(0x0037, 0x0000); //Gamma Control |
||
| 158 | GPIO_TCON(0x003a, 0x140b); //Gamma Control |
||
| 159 | GPIO_TCON(0x003b, 0x140b); //Gamma Control |
||
| 160 | } |
Powered by WebSVN v2.8.3