25.12.2013 Aufrufe

Gecko3 - CCC Event Weblog

Gecko3 - CCC Event Weblog

Gecko3 - CCC Event Weblog

MEHR ANZEIGEN
WENIGER ANZEIGEN

Sie wollen auch ein ePaper? Erhöhen Sie die Reichweite Ihrer Titel.

YUMPU macht aus Druck-PDFs automatisch weboptimierte ePaper, die Google liebt.

E.1. Firmware<br />

15 ∗ Source code o f EEPROM read / w r i t e f u n c t i o n s<br />

∗<br />

∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗/<br />

#include ” fx2 . h”<br />

20 #include ” f x 2 r e g s . h”<br />

#include ” f x 2 s d l y . h” // SYNCDELAY macro<br />

#define w r i t e n o k 1 // d e f i n i t i o n f o r w r i t e s t a t e<br />

#define w r i t e o k 0 // d e f i n i t i o n f o r w r i t e s t a t e<br />

25 #define i n i t 0 // d e f i n i t i o n f o r read s t a t e<br />

#define read 1 // d e f i n i t i o n f o r read s t a t e<br />

#define ep4in arm 2 // d e f i n i t i o n f o r read s t a t e<br />

#define i d l e 3 // d e f i n i t i o n f o r read s t a t e<br />

#define c o n t r o l b y t e 0xA2 // EEPROM and d e v i c e a d r e s s<br />

30<br />

// e x t e r n BOOL eeprom write mode ;<br />

extern BOOL s t a r t t r a n s a c t i o n ; // f o r s t a r t w r i t e t r a n s a c t i o n with vendor r e q u e s t<br />

EEPROM WRITE<br />

extern BYTE e e p r o m r e a d s t a t e ; // f o r s t a r t read t r a n s a c t i o n with vendor r e q u e s t<br />

EEPROM READ<br />

extern WORD eeprom address ; // f o r r e s e t t h e s t a r t a d r e s s o f EEPROM with vendro<br />

r e q u e s t DOWNLOADOK<br />

35<br />

BOOL w r i t e s t a t e = 1 ; // s e t t h e w r i t e s t a t e on not ok<br />

BYTE loop ;<br />

BYTE c o n t r o l = ( c o n t r o l b y t e >> 1) ; // one l e f t s h i f t because t h e t h e c y p r e s s i 2 c<br />

f u n c t i o n ( show i 2 c . c )<br />

BYTE xdata b u f f e r [ 6 6 ] ; // temporary s t o r e array<br />

40 BYTE l e n g t h ; // l e n g t h o f temporary s t o r e array ( f o r EEPROM w r i t e f u n c t i o n<br />

from Cypress )<br />

WORD bytecount = 0 ; // b y t e counter f o r read f u n c t i o n<br />

void eeprom wr ( void )<br />

45 {<br />

WORD count , i ;<br />

i f ( s t a r t t r a n s a c t i o n == 1) // i f a new firmware download i s s t a r t e d<br />

{<br />

50 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 b y t e<br />

a d r e s s from EEPROM memory<br />

b u f f e r [ 1 ] = 0 x00 ;<br />

s t a r t t r a n s a c t i o n = 0 ;<br />

}<br />

55 while ( ! ( EP2468STAT & bmEP2EMPTY) ) // check EP2 EMPTY( busy ) b i t in EP2468STAT (SFR) ,<br />

core s e t ’ s t h i s b i t when FIFO i s empty<br />

{<br />

// Autopointer source a d r e s s<br />

AUTOPTRH1 = MSB( &EP2FIFOBUF ) ;<br />

AUTOPTRL1 = LSB( &EP2FIFOBUF ) ;<br />

60<br />

count = (EP2BCH 64) {<br />

70 loop = 6 4 ; // t h e page w r i t e o f EEPROM may not be l o n g e r than 64<br />

b y t e s<br />

count −= 6 4 ; // t h e t o t a l b y t e s in t h e FIFO minus 64 b y t e s<br />

} else {<br />

Project Report 75

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!