Gecko3 - CCC Event Weblog
Gecko3 - CCC Event Weblog
Gecko3 - CCC Event Weblog
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 />
// must l o o p t h e writePageProgram ( ) t w i c e fewer than<br />
82 // t h e v a l u e in count<br />
// t w i c e fewer because t h e startPageProgramm ( ) and<br />
lastPageProgramm ( )<br />
// send a l r e a d y one b y t e per f u n c t i o n<br />
}<br />
while ( w r i t e s t a t u s ) // w r i t e s t a t u s i s ok i f t h e FIFO b u f f e r c ontent i s<br />
send<br />
87 {<br />
startPageProgram ( s p i f l a s h a d d r e s s , EXTAUTODAT1) ; // s t a r t t h e communication<br />
with t h e SPI Flash and<br />
// w r i t e t h e f i r s t data b y t e from soucre a d r e s s to<br />
SPI Flash ( f u n c t i o n in m25p16 . c )<br />
for ( i = 0 x0000 ; i < ( count−o f f s e t ) ; i++ ) // countinue t h e page program<br />
sequenz and l o o p EP2OUT data to SPI Flash<br />
92 {<br />
writePageProgram (EXTAUTODAT1) ; // w r i t e data b y t e from soucre a d r e s s to<br />
SPI Flash ( f u n c t i o n in m25p16 . c )<br />
}<br />
lastPageProgram (EXTAUTODAT1) ; // w r i t e t h e l a s t data b y t e and c l o s e t h e<br />
communication with t h e SPI Flash ( f u n c t i o n in m25p16 . c )<br />
97 i f ( count > 256) { // i f t h e EP2 counter l o n g e r than 256 b y t e s than we<br />
have send now t h e maximum page programm<br />
count −= 2 5 6 ; // v a l u e o f 256 Bytes and must s u b t r a c t t h i s number<br />
from t h e EP2 c o n t e n t counter<br />
o f f s e t = 2 ; // and can s e t t h e o f f s e t to two because t h e EP2 FIFO<br />
b u f f e r have now at t h e most once more 256 Bytes<br />
// hence we must l o op t h e writePageProgram ( ) in maximum 254<br />
times<br />
// e . g . t h e EP2 FIFO content ( count ) i s 280 b y t e s then 254<br />
b y t e s was send and 26 b y t e s are l e f t to send<br />
102 // t h u s t h e o f f s e t i s two and t h e for −l o o p<br />
( writePageProgram ( ) ) r e p e a t 24 times<br />
// two b y t e send t h e startPageProgramm ( ) and<br />
lastPageProgramm ( ) f u n c t i o n s<br />
} else<br />
{<br />
w r i t e s t a t u s = w r i t e o k ; // i f EP2 counter s h o r t e r than 257 b y t e s t h e<br />
EP2 c o n t e n t was send<br />
107 }<br />
s p i f l a s h a d d r e s s += 2 5 6 ; // s e t t h e next s t a r t a d r e s s f o r SPI Flase<br />
w r i t e f u n c t i o n startPageProgramm ( )<br />
}<br />
w r i t e s t a t u s = w r i t e n o k ; // r e s e t w r i t e s t a t e f o r next communication<br />
SYNCDELAY;<br />
112 EP2BCL = 0 x80 ; // re (arm) EP2OUT<br />
SYNCDELAY;<br />
}<br />
}<br />
117 void s p i f l a s h r d ( void )<br />
{<br />
WORD i ; // counter f o r read i n s t r u c t i o n<br />
i f ( ! ( EP2468STAT & bmEP4FULL) ) // check EP4 FULL( busy ) b i t in EP2468STAT (SFR) ,<br />
core s e t ’ s t h i s b i t when FIFO i s f u l l<br />
122 {<br />
// a u t o p o i n t e r d e s t i n a t i o n a d r e s s from EP4IN<br />
AUTOPTRH2 = MSB( &EP4FIFOBUF ) ;<br />
AUTOPTRL2 = LSB( &EP4FIFOBUF ) ;<br />
127 EXTAUTODAT2 = startBlockRead ( s p i f l a s h a d d r e s s ) ; // w r i t e data b y t e from SPI<br />
Flash to d e s t i n a t i o n a d r e s s<br />
Project Report 79