Gecko3 - CCC Event Weblog
Gecko3 - CCC Event Weblog
Gecko3 - CCC Event Weblog
Erfolgreiche ePaper selbst erstellen
Machen Sie aus Ihren PDF Publikationen ein blätterbares Flipbook mit unserer einzigartigen Google optimierten e-Paper Software.
E. Quellcode<br />
loop = count ; // i f t h e end o f t r a n s a c t i o n t h e b y t e s in t h e FIFO<br />
counter i s > 8 ; // w r i t e h i g h b y t e o f memory<br />
a d r e s s<br />
b u f f e r [ 1 ] = eeprom address & 0xFF ; // w r i t e low b y t e o f memory a d r e s s<br />
}<br />
w r i t e s t a t e = w r i t e n o k ; // rearm w r i t e t r a n s a c t i o n<br />
90 SYNCDELAY;<br />
EP2BCL = 0 x80 ; // re (arm) EP2OUT<br />
SYNCDELAY;<br />
}<br />
}<br />
95<br />
void eeprom rd (WORD r e a d c o u n t ) // read count i s t h e number o f b y t e s to read<br />
t h a t have to send t h e Host with t h e c o r r e s p o n d e t<br />
{ // vendor r e q u e s t<br />
WORD count , i , temp=0;<br />
100 switch ( e e p r o m r e a d s t a t e )<br />
{<br />
case i n i t :<br />
{<br />
b u f f e r [ 0 ] = 0 x00 ; // f i r s t two b y t e s in b u f f e r are always high and low<br />
b y t e a d r e s s from EEPROM memory<br />
105 b u f f e r [ 1 ] = 0 x00 ;<br />
// Autopointer d e s t i n a t i o n a d r e s s<br />
AUTOPTRH2 = MSB( &EP4FIFOBUF ) ;<br />
AUTOPTRL2 = LSB( &EP4FIFOBUF ) ;<br />
110<br />
EZUSB WriteI2C ( c o n t r o l , 0x02 , &b u f f e r [ 0 ] ) ; // s e t w r i t e o p e r a t i o n and w r i t e<br />
t h e a d r e s s word<br />
EZUSB WaitForEEPROMWrite( c o n t r o l ) ; // wait t i l l EEPROM i s ready f o r next<br />
data<br />
count = r e a d c o u n t ; // s e t counter e q u a l number o f b y t e s to read<br />
e e p r o m r e a d s t a t e = read ; // s e t read s t a t e<br />
115 break ;<br />
}<br />
case read :<br />
{<br />
i f ( ! ( EP2468STAT & bmEP4FULL) ) { // check EP4 FULL( busy ) b i t in<br />
EP2468STAT (SFR) , core s e t ’ s t h i s b i t when FIFO i s f u l l<br />
120 // Autopointer source a d r e s s<br />
AUTOPTRH1 = MSB( &b u f f e r [ 0 ] ) ;<br />
AUTOPTRL1 = LSB( &b u f f e r [ 0 ] ) ;<br />
i f ( count > 64) {<br />
125 loop = 6 4 ; // b u f f e r array i s 64 b y t e s because page w r i t e<br />
l i m i t a t i o n o f EEPROM<br />
76 Matthias Zurbrügg, Christoph Zimmermann