Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DRESULT disk_writep (const BYTE* buff, DWORD sc){
- static WORD wr_cnt;
- if(sd_blsize == 0xff) return RES_NOTRDY;
- if (!buff) {
- if (sc) {
- CS_LOW
- spi_io(0xff);
- spi_io(0xff);
- if(sd_blsize == 0x00) sc *= 512;
- spi_io(CMD_24);
- spi_io(((BYTE*) &sc)[3]);
- spi_io(((BYTE*) &sc)[2]);
- spi_io(((BYTE*) &sc)[1]);
- spi_io(((BYTE*) &sc)[0]);
- spi_io(0xff);
- if(in_oout() != 0X00) return RES_ERROR;
- spi_io(0xff);
- spi_io(0xfe);
- writep_status=1;
- wr_cnt = 512;
- } else {
- // Finalize write process
- if(writep_status == 0) return RES_NOTRDY;
- while(wr_cnt--){
- spi_io(0x00);
- }
- in_oout();
- while(spi_io(0xff) != 0xff);
- writep_status = 0x00;
- CS_HIGH
- }
- } else {
- if(writep_status == 0) return RES_NOTRDY;
- wr_cnt -= (WORD)sc;
- while(sc--){
- spi_io(*buff++);
- }
- }
- return RES_OK;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement