25.12.2013 Aufrufe

Gecko3 - CCC Event Weblog

Gecko3 - CCC Event Weblog

Gecko3 - CCC Event Weblog

MEHR ANZEIGEN
WENIGER ANZEIGEN

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 />

43 S P I s e l e c t D e v i c e (M25P16) ;<br />

SPIwriteByte (RDSR) ;<br />

i f ( SPIreadByte ( )&&0x01==1){<br />

value=TRUE;<br />

}<br />

48 S P I d e s e l e c t D e v i c e (M25P16) ;<br />

return value ;<br />

}<br />

// read one b y t e at t h e g i v e n a d r e s s<br />

53 byte readByte ( long a d r e s s ) {<br />

byte value ;<br />

S P I s e l e c t D e v i c e (M25P16) ;<br />

SPIwriteByte (READ) ;<br />

sendAdress ( a d r e s s ) ;<br />

58 value = SPIreadByte ( ) ;<br />

S P I d e s e l e c t D e v i c e (M25P16) ;<br />

return value ;<br />

}<br />

63 // s t a r t s a b l o c k read from t h e g i v e n a d r e s s<br />

byte startBlockRead ( long a d r e s s ) {<br />

S P I s e l e c t D e v i c e (M25P16) ;<br />

SPIwriteByte (READ) ;<br />

sendAdress ( a d r e s s ) ;<br />

68 return SPIreadByte ( ) ;<br />

}<br />

// reads t h e next b y t e ( s e q u e n t i a l readout )<br />

byte readBlock ( ) {<br />

73 return SPIreadByte ( ) ;<br />

}<br />

// reads t h e l a s t b y t e from a b l o c k and t e r m i n a t e s t h e b l o c k r e a d<br />

byte lastBlockRead ( ) {<br />

78 byte value ;<br />

value = SPIreadByte ( ) ;<br />

S P I d e s e l e c t D e v i c e (M25P16) ;<br />

return value ;<br />

}<br />

83<br />

// e n a b l e w r i t e a c c e s s<br />

void writeEnable ( ) {<br />

S P I s e l e c t D e v i c e (M25P16) ;<br />

SPIwriteByte (WREN) ;<br />

88 S P I d e s e l e c t D e v i c e (M25P16) ;<br />

}<br />

// e r a s e s t h e s e c t o r in wich t h e g i v e n a d r e s s i s<br />

void s e c t o r E r a s e ( long a d r e s s ) {<br />

93 writeEnable ( ) ;<br />

S P I s e l e c t D e v i c e (M25P16) ;<br />

SPIwriteByte (SE) ;<br />

sendAdress ( a d r e s s ) ;<br />

S P I d e s e l e c t D e v i c e (M25P16) ;<br />

98 while ( isBusy ( ) ) {<br />

}<br />

}<br />

// e r a s e s t h e whole f l a s h<br />

103 void bulkErase ( ) {<br />

writeEnable ( ) ;<br />

S P I s e l e c t D e v i c e (M25P16) ;<br />

SPIwriteByte (BE) ;<br />

S P I d e s e l e c t D e v i c e (M25P16) ;<br />

108 while ( isBusy ( ) ) {<br />

82 Matthias Zurbrügg, Christoph Zimmermann

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

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!