SPI Single IO NOR Flash Library for Nucleo F767ZI Interfacing
Fork of W25X40BV by
Diff: S25FL256S.cpp
- Revision:
- 8:9f5a31575cdd
- Parent:
- 6:ef894010def4
--- a/S25FL256S.cpp Tue May 22 09:44:34 2018 +0000
+++ b/S25FL256S.cpp Tue Oct 23 10:22:44 2018 +0000
@@ -25,6 +25,7 @@
void S25FL256S::readStream(int addr, char* buf, int count)
{
+ int i;
if (count < 1)
return;
chipEnable();
@@ -33,10 +34,11 @@
this->write((addr & ADDR_BMASK2) >> ADDR_BSHIFT2);
this->write((addr & ADDR_BMASK1) >> ADDR_BSHIFT1);
this->write((addr & ADDR_BMASK0) >> ADDR_BSHIFT0);
- for (int i = 0; i < count; i++) {
+ for ( i = 0; i < count; i++) {
buf[i] = this->write(DUMMY_ADDR);
- printf("i= %d :%c \r\n",i,buf[i]);
+ // printf("i= %d :%c \r\n",i,buf[i]);
}
+ buf[i]='\0';
chipDisable();
}
@@ -71,10 +73,16 @@
for (int i = 0; i < count; i++) {
this->write(buf[i]);
}
- wait(0.1);
+
chipDisable();
writeDisable();
- wait(WAIT_TIME);
+ uint8_t busy=checkIfBusy();
+ while(busy)
+ {
+ busy=checkIfBusy();
+ }
+
+
}
void S25FL256S::writeString(int addr, string str)
@@ -104,9 +112,10 @@
this->write(RDSR1);
uint8_t val=this->write(DUMMY_ADDR);
chipDisable();
- //wait(WAIT_TIME);//instead of wait poll for WIP flag of status reg or use checkIfBusy() function...see main for more dtails
- //printf("value of reg is %X \r\n",val);
- return(val);
+ if(val&0x01==0x01)
+ return 1;
+ else
+ return 0;
}
//ERASING
@@ -132,7 +141,7 @@
wait(WAIT_TIME);//instead of wait poll for WIP flag of status reg or use checkIfBusy() function...see main for more dtails
}
-void S25FL256S::sectorErase(int addr)
+int S25FL256S::sectorErase(int addr)
{
writeEnable();
chipEnable();
@@ -143,7 +152,15 @@
this->write((addr & ADDR_BMASK0) >> ADDR_BSHIFT0);
chipDisable();
writeDisable();
- wait(WAIT_TIME);//instead of wait poll for WIP flag of status reg or use checkIfBusy() function...see main for more dtails
+ uint8_t busy=checkIfBusy();
+ while(busy)
+ {
+ busy=checkIfBusy();
+
+ printf(" Am Here \r\n\r\n");
+ }//instead of wait poll for WIP flag of status reg or use checkIfBusy() function...see main for more dtails
+
+ return 1;
}
void S25FL256S::reset()
{
@@ -157,7 +174,7 @@
uint8_t S25FL256S::checkIfBusy()
{
uint8_t value=readRegister();
- printf("Value of Status Reg=%X\r\n\r\n",value);
+ // printf("Value of Status Reg=%X\r\n\r\n",value);
if((value&0x01)==0x01)
return 1;
else
