mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-25 17:58:07 +11:00
eafcb0c440
also, verify all 3 first bytes of SPI commands. I'm not sure why I wasn't doing that, probably because I was getting a lot of AVR err and thought that only 2 bytes of the cmd were echoed. But now, with a reliable SPI setup, verifying 3 bytes seems to work.
17 lines
636 B
Plaintext
17 lines
636 B
Plaintext
( AVR Programmer, load range 160-163. doc/avr.txt )
|
|
( page size in words, 64 is default on atmega328P )
|
|
CREATE aspfpgsz 64 ,
|
|
VARIABLE aspprevx
|
|
: _x ( a -- b ) DUP aspprevx ! (spix) ;
|
|
: _xc ( a -- b ) DUP (spix) ( a b )
|
|
DUP aspprevx @ = NOT IF ABORT" AVR err" THEN ( a b )
|
|
SWAP aspprevx ! ( b ) ;
|
|
: _cmd ( b4 b3 b2 b1 -- r4 ) _xc DROP _xc DROP _xc DROP _x ;
|
|
: asprdy ( -- ) BEGIN 0 0 0 0xf0 _cmd 1 AND NOT UNTIL ;
|
|
: asp$ ( spidevid -- )
|
|
( RESET pulse ) DUP (spie) 0 (spie) (spie)
|
|
( wait >20ms ) 220 TICKS
|
|
( enable prog ) 0xac (spix) DROP
|
|
0x53 _x DROP 0 _xc DROP 0 _x DROP ;
|
|
: asperase 0 0 0x80 0xac _cmd asprdy ;
|