Explorar el Código

Optimize SD card subsystem a bit

master
Virgil Dupras hace 3 años
padre
commit
480cf342fa
Se han modificado 7 ficheros con 24 adiciones y 33 borrados
  1. +3
    -8
      blk/424
  2. +1
    -1
      blk/428
  3. +10
    -10
      blk/431
  4. +5
    -5
      blk/432
  5. +2
    -4
      blk/433
  6. +1
    -1
      blk/434
  7. +2
    -4
      blk/435

+ 3
- 8
blk/424 Ver fichero

@@ -5,11 +5,6 @@
( spix 0xff until the response is something else than 0xff
for a maximum of 20 times. Returns 0xff if no response. )
: _wait
0 ( cnt )
BEGIN
_idle
DUP 0xff = IF DROP ELSE NIP EXIT THEN
1+
DUP 20 = UNTIL
DROP 0xff
;
0 ( dummy ) 20 0 DO
DROP _idle DUP 0xff = NOT IF LEAVE THEN
LOOP ;

+ 1
- 1
blk/428 Ver fichero

@@ -10,7 +10,7 @@
_s+crc _s+crc ( a2 crc )
SWAP 256 /MOD ROT ( h l crc )
_s+crc _s+crc ( crc )
0x01 OR ( ensure stop bit )
1 OR ( ensure stop bit )
(spix) DROP ( send CRC )
_wait ( wait for a valid response... )
;

+ 10
- 10
blk/431 Ver fichero

@@ -1,16 +1,16 @@
: SDC$
10 0 DO _idle DROP LOOP
0 ( dummy ) 10 0 DO ( r )
DROP 0x40 0 0 SDCMDR1 ( CMD0 )
DUP 0x01 = IF LEAVE THEN
LOOP 0x01 = NOT IF _err THEN
10 0 DO ( r )
0x40 0 0 SDCMDR1 ( CMD0 )
DUP 1 = IF LEAVE ELSE DROP THEN
LOOP 1 = NOT IF _err THEN
0x48 0 0x1aa ( CMD8 ) SDCMDR7 ( r arg1 arg2 )
0x1aa = NOT IF _err THEN ( arg2 check )
0 = NOT IF _err THEN ( arg1 check )
0x01 = NOT IF _err THEN ( r check )
( expected 1 0 0x1aa )
0x1aa = ROT ( arg1 f r ) 1 = AND SWAP ( f&f arg1 )
NOT ( 0 expected ) AND ( f&f&f ) NOT IF _err THEN
BEGIN
0x77 0 0 SDCMDR1 ( CMD55 )
0x01 = NOT IF _err THEN
0x69 0x4000 0x0000 SDCMDR1 ( CMD41 )
DUP 0x01 > IF _err THEN
1 = NOT IF _err THEN
0x69 0x4000 0 SDCMDR1 ( CMD41 )
DUP 1 > IF _err THEN
NOT UNTIL ; ( out of idle mode, success! )

+ 5
- 5
blk/432 Ver fichero

@@ -1,14 +1,14 @@
: _sdc@ ( dstaddr blkno -- )
: _ ( dstaddr blkno -- )
[ SDC_DEVID LITN ] (spie)
0x51 ( CMD17 ) 0 ROT ( a cmd 0 blkno ) _cmd
IF _err THEN
_wait 0xfe = NOT IF _err THEN
0 SWAP ( crc a )
512 0 DO ( crc a )
DUP _idle ( crc a a n )
DUP ROT C! ( crc a n )
ROT SWAP _crc16 ( a crc )
SWAP 1+ ( crc a+1 )
_idle ( crc a n )
DUP ROT C!+ ( crc n a+1 )
ROT> _crc16 ( a+1 crc )
SWAP ( crc a+1 )
LOOP
DROP ( crc1 )
_idle 8 LSHIFT _idle + ( crc2 )


+ 2
- 4
blk/433 Ver fichero

@@ -1,6 +1,4 @@
: SDC@
2 * DUP BLK( SWAP ( b a b )
_sdc@
1+ BLK( 512 + SWAP
_sdc@
2 * DUP BLK( SWAP ( b a b ) _
1+ BLK( 512 + SWAP _
;

+ 1
- 1
blk/434 Ver fichero

@@ -1,4 +1,4 @@
: _sdc! ( srcaddr blkno -- )
: _ ( srcaddr blkno -- )
[ SDC_DEVID LITN ] (spie)
0x58 ( CMD24 ) 0 ROT ( a cmd 0 blkno ) _cmd
IF _err THEN


+ 2
- 4
blk/435 Ver fichero

@@ -1,6 +1,4 @@
: SDC!
2 * DUP BLK( SWAP ( b a b )
_sdc!
1+ BLK( 512 + SWAP
_sdc!
2 * DUP BLK( SWAP ( b a b ) _
1+ BLK( 512 + SWAP _
;

Cargando…
Cancelar
Guardar