1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-24 14:38:05 +11:00

drv/sdc: Implement SDC!

This has been tested in the RC2014 emulator. I could edit blocks with
the Block Editor and they would correctly be written to SDC.
This commit is contained in:
Virgil Dupras 2020-04-18 19:39:28 -04:00
parent 47a7133b8b
commit a70366aa43
2 changed files with 34 additions and 5 deletions

View File

@ -156,10 +156,7 @@
0
;
: _err
_desel
ABORT" SDC error"
;
: _err _desel ABORT" SDerr" ;
( dstaddr blkno -- )
: _sdc@
@ -194,3 +191,36 @@
1+ BLK( 512 + SWAP
_sdc@
;
( srcaddr blkno -- )
: _sdc!
_sel
0x58 ( CMD24 )
0 ROT ( a cmd 0 blkno )
_cmd
IF _err THEN
_idle DROP
0xfe _sdcSR DROP
0 SWAP ( crc a )
512 0 DO ( crc a )
C@+ ( crc a+1 n )
ROT OVER ( a n crc n )
_crc16 ( a n crc )
SWAP ( a crc n )
_sdcSR DROP ( a crc )
SWAP ( crc a )
LOOP
DROP ( crc )
256 /MOD ( lsb msb )
_sdcSR DROP ( lsb )
_sdcSR DROP
_wait DROP
_desel
;
: SDC!
2 * DUP BLK( SWAP ( b a b )
_sdc!
1+ BLK( 512 + SWAP
_sdc!
;

View File

@ -183,7 +183,6 @@ void sdc_spi_wr(SDC *sdc, uint8_t val)
return;
}
if (cmd == 24) {
fprintf(stderr, "cmd24\n");
if (sdc->fp) {
fseek(sdc->fp, arg2*512, SEEK_SET);
}