00001 #include <spi.h>
00002 #include <stdio.h>
00003 #include <cubeos.h>
00004 #include <mc68332.h>
00005 #include <qsm.h>
00006 
00007 int _SPI_cmdcnt=0;
00008 
00009 
00010 int SPI_init()
00011 {
00012 int i;
00013 
00014 printf("SPI init\n");
00015 
00016 QSM_init();
00017 
00018 
00019 writeshort (QSM_PQSPAR, (readshort (QSM_PQSPAR)|0x1b01E)&0xFFFE );
00020 
00021 
00022 
00023 writeshort(SPI_SPCR1,readshort(SPI_SPCR1)&0x7FFF); 
00024 
00025 
00026 writeshort(SPI_SPCR0,0xA811);   
00027                                 
00028 writeshort(SPI_SPCR2,0x300);    
00029                                 
00030 writeshort(SPI_SPCR3,0x0);
00031                                 
00032                                 
00033 
00034 for (i=0;i<16;i+=2){ 
00035         writeshort(SPI_RDRAM+i,0);
00036         writeshort(SPI_TDRAM+i,0);
00037         writeshort(SPI_CMDRAM+i,0);
00038 }
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 return 0;
00070 }
00071 
00072 
00073 int SPI_resetcmd()
00074 {
00075   writeshort(SPI_SPCR1,0x0000); 
00076   _SPI_cmdcnt=0;
00077   return(0);
00078 }
00079 
00080 int SPI_newcommand(unsigned char command)
00081 {
00082  if (_SPI_cmdcnt<16)
00083 {
00084         writebyte(SPI_CMDRAM+(_SPI_cmdcnt++),command);
00085         return(_SPI_cmdcnt-1);
00086 } else {
00087         return(-1);
00088 }
00089 }
00090 
00091 int SPI_init_analog()
00092 {
00093 
00094 printf("SPI init analog\n");
00095 
00096 return 0;
00097 
00098 }
00099 
00100 int SPI_ReadAnalogIn(int chip, int channel)
00101 {
00102 
00103 print ("SPI ReadAnalogIn %d %d\n",chip,channel);
00104 
00105 return 15;
00106 }
00107 
00108 void QSM_qspi_int ()
00109 {
00110 
00111 
00112 }