Main Page | File List | Globals

main.c

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <string.h>
00003 #include <eZ8.h>
00004 #include <sio.h>
00005 #include "driver.h"
00006 #include "main.h"
00007 
00008 char mych;                           
00009 char chararray[]="0123456789abcdef"; 
00010 char *loc;                           
00011 unsigned char datahigh;              
00012 unsigned char datalow;               
00013 
00014 /*
00015 void writeFlash(void){
00016   x=0x45;
00017   WRITE_FLASH((rom const *)0x4010,x);           // write to addr =0x4010
00018   x=0x44;
00019   WRITE_FLASH((rom const *)0x4011,x);           // write to addr =0x4010
00020   x=0x57;
00021   WRITE_FLASH((rom const *)0x4012,x);           // write to addr =0x4010
00022   x=0x49;
00023   WRITE_FLASH((rom const *)0x4013,x);           // write to addr =0x4010
00024   x=0x4E;
00025   WRITE_FLASH((rom const *)0x4014,x);           // write to addr =0x4010
00026   x=0xAA;
00027   x = READ_FLASH((rom const *)0x4010);          // read from addr=0x4010
00028 }
00029 */
00030 
00038 char getinput(){
00039   mych = getch();
00040   return mych;
00041 }
00042 
00051 char chartohex(unsigned char tempchar){
00052   loc = strchr(chararray, (int)tempchar);
00053   return (char)loc;
00054 }
00055 
00064 void bytetotwoascii(unsigned char tempdata){
00065   datahigh = 0xF0 & tempdata;
00066   datahigh = datahigh >> 4;
00067   datalow  = 0x0F & tempdata;
00068   printf("\n%c%c", chararray[datahigh], chararray[datalow]);
00069 }
00070 
00079 void main (){
00080   char inputisok = 0;
00081   char tempdata = 0;
00082   int ch;
00083   unsigned char adresshigh, adresslow;
00084   INIT_FLASH(_DEFFREQ/1000);
00085   writeFlash();
00086   init_uart(_UART1,_DEFFREQ,_DEFBAUD);
00087   bussetup();
00088   ADBUSOUT = 0x00;  
00089   while(1){ 
00090     getinput();
00091     if(mych == 'k'){
00092       inputisok = 1;
00093       tempdata = singleadconverting();
00094       bytetotwoascii(tempdata);
00095     }
00096     if(mych == 's'){
00097       inputisok = 1;
00098       adresshigh = chartohex(getinput());
00099       adresslow = chartohex(getinput());
00100       adressingboard((adresshigh << 4) + adresslow);
00101     }
00102     if(mych == 'i'){
00103       inputisok = 1;
00104       tempdata = bytein();
00105       bytetotwoascii(tempdata);
00106     }
00107     if(mych == 'o'){
00108       inputisok = 1;
00109       datahigh = chartohex(getinput());
00110       datalow = chartohex(getinput());
00111       byteout((datahigh << 4) + datalow);
00112     }
00113     if(mych == 'y'){
00114       inputisok = 1;
00115       if(delaycycles){
00116         delaycycles = 0;
00117       } else {
00118         delaycycles = 65000;
00119       }
00120     }
00121     if(inputisok != 1){
00122     }
00123     printf("x\n");      
00124     inputisok = 0;
00125   }
00126 }

Generated on Mon Jan 3 09:13:09 2005 for RapierZ8 by  doxygen 1.4.0