Y:/FINAL CODE/LCD_methods.h

Go to the documentation of this file.
00001 /******************************************************************************                      
00002  *
00003  *       Copyright (C) 2006 J Team, Inc.
00004  *       All Rights Reserved
00005  *
00006  * File Name      : LCD_methods.h
00007  * Project Name   : RFIDXpress.mcp
00008  * Description    : This file contains the methods for interfacing with the LCD.
00009  *                  
00010  * Authors: Jared Suttles
00011  *          Jennifer Tietz
00012  *          Jonathan Chen
00013  *          Joshua Chapman
00014  *
00015  * Version : 2.0
00016  * Date    : 05/1/06
00017  *
00018  *****************************************************************************/
00019 
00020 
00021 #define lcdEnable PTG_PTG5
00022 #define lcdRS     PTG_PTG4
00023 #define lcdReset  PTG_PTG6
00024 #define LCD_BUS_0 PTG_PTG0
00025 #define LCD_BUS_1 PTG_PTG1
00026 #define LCD_BUS_2 PTG_PTG2
00027 #define LCD_BUS_3 PTG_PTG3
00028 #define LCD_BUS_4 PTH_PTH2
00029 #define LCD_BUS_5 PTH_PTH1
00030 #define LCD_BUS_6 PTH_PTH0
00031 #define LCD_BUS_7 PTJ_PTJ0
00032 #define NULL      0
00033 
00034 void LCD_strobe() {
00035   lcdEnable = 1;
00036   lcdEnable = 0; 
00037 }
00038 
00039 void LCD_reset() {
00040   lcdReset=0;
00041   lcdReset=1;
00042 }
00043 
00044 void LCD_set_reg(int func, int val) {
00045   lcdRS=1;
00046   LCD_BUS_0 = (func & 0x01); // set register
00047   LCD_BUS_1 = (func & 0x02) >> 1; // set register
00048   LCD_BUS_2 = (func & 0x04) >> 2; // set register
00049   LCD_BUS_3 = (func & 0x08) >> 3; // set register
00050   LCD_BUS_4 = (func & 0x10) >> 4; // set register
00051   LCD_BUS_5 = (func & 0x20) >> 5; // set register
00052   LCD_BUS_6 = (func & 0x40) >> 6; // set register
00053   LCD_BUS_7 = (func & 0x80) >> 7; // set register
00054   LCD_strobe();
00055   
00056   lcdRS=0;
00057   LCD_BUS_0 = (val & 0x01); // set register
00058   LCD_BUS_1 = (val & 0x02) >> 1; // set register
00059   LCD_BUS_2 = (val & 0x04) >> 2; // set register
00060   LCD_BUS_3 = (val & 0x08) >> 3; // set register
00061   LCD_BUS_4 = (val & 0x10) >> 4; // set register
00062   LCD_BUS_5 = (val & 0x20) >> 5; // set register
00063   LCD_BUS_6 = (val & 0x40) >> 6; // set register
00064   LCD_BUS_7 = (val & 0x80) >> 7; // set register
00065   LCD_strobe();
00066 }
00067 
00068 void LCD_set_mode(int mode) {LCD_set_reg(0,mode);}        // 0x32 for Graphic mode Master Display on
00069 void LCD_char_pitch(int cpitch) {LCD_set_reg(1,cpitch);}        // please use 0x07. set char pitch register
00070 void LCD_set_nchar(int nchar) {LCD_set_reg(2,nchar);}    // use 29 for g mode, set no. of char/bytes in row
00071 void LCD_set_time_div(int Nx) {LCD_set_reg(3,Nx);}     // plase use 0x7F
00072 void LCD_set_cursor(int Np) {LCD_set_reg(4,Np);}   // Np = number of pixels the cursor is from top of char
00073 void LCD_set_daddl(int daddl) {LCD_set_reg(8,daddl);} // set lower display address.Always set lower first!
00074 void LCD_set_daddu(int daddu) {LCD_set_reg(9,daddu);} // set upper dispaly address.Always set lower first!
00075 void LCD_set_caddl(int caddl) {LCD_set_reg(10,caddl);} // set lower cursor address.Always set lower first!
00076 void LCD_set_caddu(int caddu) {LCD_set_reg(11,caddu);} // set upper cursor address.Always set lower first!
00077 void LCD_write_data(int data) {LCD_set_reg(12,data);}  // Writes data
00078 
00079 void LCD_set_char_add(int row, int col) { // for char mode only
00080   int abs, lower, upper;
00081   abs=row*40+col;
00082   lower=abs%256;
00083   upper=abs-lower;
00084   upper=upper >> 8;
00085   LCD_set_caddl(lower);
00086   LCD_set_caddu(upper);  
00087 }
00088 
00089 void LCD_print_string(char *str) {
00090   while (*str != NULL) {
00091     LCD_write_data(*str);
00092     str++; 
00093   }
00094 }
00095 
00096 void LCD_putchar(char toput) {
00097   LCD_write_data(toput);
00098 }
00099 
00100 void LCD_graphic_ini() {
00101   int counter;
00102   LCD_set_time_div(127);     
00103   LCD_set_mode(50);   
00104   LCD_char_pitch(7);
00105   LCD_set_nchar(29);
00106   LCD_set_daddl(0);
00107   LCD_set_daddu(0);
00108   LCD_set_caddl(0);
00109   LCD_set_caddu(0);
00110   for (counter = 0; counter < 4096; counter++) {
00111     LCD_write_data(0x00);
00112   }
00113   LCD_set_caddl(0x00);
00114   LCD_set_caddu(0x00);
00115 }
00116 
00117 void LCD_char_ini() {
00118   int counter;
00119   LCD_set_time_div(127);
00120   LCD_set_cursor(167);
00121   LCD_char_pitch(165);
00122   LCD_set_nchar(38);
00123   LCD_set_mode(48);
00124   LCD_set_daddl(0);
00125   LCD_set_daddu(0);
00126   LCD_set_caddl(0);
00127   LCD_set_caddu(0);
00128   for (counter = 0; counter < 4096; counter++) {
00129     LCD_write_data(0x00);
00130   }
00131   LCD_set_caddl(0);
00132   LCD_set_caddu(0);
00133 }
00134 
00135 void LCD_clr_scr_char(int screen) {
00136  int row=screen*12;
00137  int i;
00138  LCD_set_char_add(row,0);
00139  for (i=0; i<12; i++) {
00140    LCD_print_string("                                        ");
00141  }
00142 }

Generated on Sun Apr 30 17:44:00 2006 for RFID by  doxygen 1.4.6-NO