mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-20 18:18:05 +11:00
1a6a549857
Working on programming AVR chips exposes a glaring omission in my first design of the SPI Relay: not allowing multiple devices make this task hard. I constantly have to unplug my SD card before, plug the AVR chip holder, then play a bit, then unplug the AVR holder, then replug the SD card... My prototype for a SPI relay design is built, but I haven't tested it yet. I need to adapt the code first, which is what I do here. When the prototype is tested, I'll update the SDC recipe with a new schema.
16 lines
588 B
Plaintext
16 lines
588 B
Plaintext
( 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 _x 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 ) 5000 0 DO LOOP
|
|
( enable prog ) 0xac (spix) DROP
|
|
0x53 _x DROP 0 _xc DROP 0 _x DROP ;
|
|
: asperase 0 0 0x80 0xac _cmd asprdy ;
|