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.

17 lines
640B

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