Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
573B

  1. ( page size in words, 64 is default on atmega328P )
  2. CREATE aspfpgsz 64 ,
  3. VARIABLE aspprevx
  4. : _x ( a -- b ) DUP aspprevx ! (spix) ;
  5. : _xc ( a -- b ) DUP (spix) ( a b )
  6. DUP aspprevx @ = NOT IF ABORT" AVR err" THEN ( a b )
  7. SWAP aspprevx ! ( b ) ;
  8. : _cmd ( b4 b3 b2 b1 -- r4 ) _xc DROP _x DROP _xc DROP _x ;
  9. : asprdy ( -- ) BEGIN 0 0 0 0xf0 _cmd 1 AND NOT UNTIL ;
  10. : asp$ ( -- )
  11. ( RESET pulse ) (spie) (spid) (spie)
  12. ( wait >20ms ) 5000 0 DO LOOP
  13. ( enable prog ) 0xac (spix) DROP
  14. 0x53 _x DROP 0 _xc DROP 0 _x DROP ;
  15. : asperase 0 0 0x80 0xac _cmd asprdy ;