AirioBase + 2 chip PicoSSD board.
Dependencies: mbed EEPROM USBDevice
Diff: RawNAND.cpp
- Revision:
- 4:2e8b78a74493
- Parent:
- 3:28ceea26c918
--- a/RawNAND.cpp Wed Feb 10 03:45:12 2021 +0000 +++ b/RawNAND.cpp Wed Sep 15 16:32:12 2021 +0000 @@ -2,7 +2,7 @@ // TODO: Replace wait_us(int) to wait_ns -RawNAND::RawNAND(PinName ceb, PinName cle, +RawNAND::RawNAND(PinName ceb0,PinName ceb1, PinName cle, PinName ale, PinName web, PinName reb, PinName wpb, PinName rbb, @@ -10,22 +10,26 @@ PinName io3, PinName io4, PinName io5, PinName io6, PinName io7, PinName io8) - : _ceb(ceb,1),_cle(cle,1), + : _ceb0(ceb0,1),_ceb1(ceb1,1),_cle(cle,1), _ale(ale,1),_web(web,1), _reb(reb,1),_wpb(wpb,1), - _rbb(rbb,PullNone), + _rbb(rbb,PullUp), _io(io1,io2,io3,io4,io5,io6,io7,io8) { _io.mode(PullNone); _io.input(); } -void RawNAND::reset() { +void RawNAND::reset(uint8_t cs) { // wait ready while(_rbb==0){ __NOP(); } // RESET COMMAND (0xff) - _ceb = 0; + if(cs==0) { + _ceb0 = 0; + } else if (cs==1) { + _ceb1 = 1; + } _cle = 1; _ale = 0; _web = 0; @@ -40,11 +44,19 @@ while (_rbb==0){ __NOP(); } - _ceb = 1; + if(cs==0) { + _ceb0 = 1; + } else if (cs==1) { + _ceb1 = 1; + } } -void RawNAND::idRead(uint8_t * readData) { +void RawNAND::idRead(uint8_t cs, uint8_t * readData) { // ID READ COMMAND (0x90) - _ceb = 0; + if(cs==0) { + _ceb0 = 0; + } else if (cs==1) { + _ceb1 = 0; + } _cle = 1; _ale = 0; _web = 0; @@ -84,10 +96,14 @@ wait_us(tREH_US); } // wait io hiz - _ceb = 1; + if(cs==0) { + _ceb0 = 1; + } else if (cs==1) { + _ceb1 = 1; + } wait_us(tCHZ_US); } -uint8_t RawNAND::statusRead() { +uint8_t RawNAND::statusRead(uint8_t cs) { uint8_t status; // wait ready while(_rbb==0){ @@ -95,7 +111,11 @@ } // STATUS READ COMMAND (0x70) - _ceb = 0; + if(cs==0) { + _ceb0 = 0; + } else if (cs==1) { + _ceb1 = 0; + } _cle = 1; _ale = 0; _web = 0; @@ -117,7 +137,11 @@ _reb = 1; // wait tREH wait_us(tREH_US); - _ceb = 1; + if(cs==0) { + _ceb0 = 1; + } else if (cs==1) { + _ceb1 = 1; + } wait_us(tCHZ_US); // wait io hiz return status; @@ -129,14 +153,18 @@ wait_us(tWW_US); } -void RawNAND::pageRead(uint8_t * readData,uint16_t blockAddress,uint8_t pageAddress,uint16_t columnAddress,uint16_t beats){ +void RawNAND::pageRead(uint8_t cs, uint8_t * readData,uint16_t blockAddress,uint8_t pageAddress,uint16_t columnAddress,uint16_t beats){ // wait ready while(_rbb==0){ __NOP(); } // 1ST READ COMMAND (0x00) - _ceb = 0; + if(cs==0) { + _ceb0 = 0; + } else if (cs==1) { + _ceb1 = 0; + } _cle = 1; _ale = 0; _web = 0; @@ -225,21 +253,29 @@ wait_us(tREH_US); } - _ceb = 1; + if(cs==0) { + _ceb0 = 1; + } else if (cs==1) { + _ceb1 = 1; + } // wait io hiz wait_us(tCHZ_US); } -uint8_t RawNAND::erase(uint16_t blockAddress){ +uint8_t RawNAND::erase(uint8_t cs, uint16_t blockAddress){ // wait ready while(_rbb==0){ __NOP(); } // 1ST ERASE COMMAND (0x60) - _ceb = 0; + if(cs==0) { + _ceb0 = 0; + } else if (cs==1) { + _ceb1 = 0; + } _cle = 1; _ale = 0; _web = 0; @@ -295,17 +331,21 @@ __NOP(); } - return statusRead(); + return statusRead(cs); } -uint8_t RawNAND::pageProgram(const uint8_t * writeData,uint16_t blockAddress,uint8_t pageAddress,uint16_t columnAddress,uint16_t beats){ +uint8_t RawNAND::pageProgram(uint8_t cs, const uint8_t * writeData,uint16_t blockAddress,uint8_t pageAddress,uint16_t columnAddress,uint16_t beats){ // wait ready while(_rbb==0){ __NOP(); } // 1ST PROGRAM COMMAND (0x80) - _ceb = 0; + if(cs==0) { + _ceb0 = 0; + } else if (cs==1) { + _ceb1 = 0; + } _cle = 1; _ale = 0; _web = 0; @@ -395,5 +435,5 @@ __NOP(); } - return statusRead(); + return statusRead(cs); } \ No newline at end of file