2020-10-06 10:32:42 +11:00
|
|
|
( AVR Programmer, load range 160-163. doc/avr.txt )
|
2020-09-06 04:07:13 +10:00
|
|
|
( 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 ) ;
|
2020-10-06 10:32:42 +11:00
|
|
|
: _cmd ( b4 b3 b2 b1 -- r4 ) _xc DROP _xc DROP _xc DROP _x ;
|
2020-09-06 04:07:13 +10:00
|
|
|
: asprdy ( -- ) BEGIN 0 0 0 0xf0 _cmd 1 AND NOT UNTIL ;
|
2020-09-17 23:36:16 +10:00
|
|
|
: asp$ ( spidevid -- )
|
|
|
|
( RESET pulse ) DUP (spie) 0 (spie) (spie)
|
2020-09-26 07:31:06 +10:00
|
|
|
( wait >20ms ) 220 TICKS
|
2020-09-06 04:07:13 +10:00
|
|
|
( enable prog ) 0xac (spix) DROP
|
|
|
|
0x53 _x DROP 0 _xc DROP 0 _x DROP ;
|
|
|
|
: asperase 0 0 0x80 0xac _cmd asprdy ;
|