- while(blocks--){
- for(i=0;i<len;i++)
- serial_tx(spitrans8(0));
-
- /* old fashioned
- for(i=0;i<len;i++)
- cmddata[i]=spitrans8(0);
- txdata(app,verb,len);
- */
- }
- P5OUT|=SS; //Raise !SS to end transaction.
+ while(len--)
+ serial_tx(spitrans8(0));
+
+ SETSS; //Raise !SS to end transaction.
+}
+
+
+//! Erase a sector.
+void spiflash_erasesector(unsigned long adr){
+ //debugstr("Erasing a 4kB sector.");
+
+ //Write enable.
+ spiflash_wrten();
+
+ //Begin
+ CLRSS;
+
+ //Second command.
+ spitrans8(0x20);
+ //Send address
+ spitrans8((adr&0xFF0000)>>16);
+ spitrans8((adr&0xFF00)>>8);
+ spitrans8(adr&0xFF);
+
+ SETSS;
+ while(spiflash_status()&0x01);//while busy
+ //debugstr("Erased.");
+}
+
+
+//! Wake an EM260 Radio
+void em260_wake(){
+ //debugstr("Waking EM260.");
+ #define RST BIT6
+ P2DIR|=RST;
+ SETRST;
+ delay(1024);
+
+ CLRRST;//Wake chip.
+ while(P4IN&1);
+ SETRST;//Woken.
+ //debugstr("EM260 is now awake.");
+ delay(1024); //DO NOT REMOVE, fails without.