\ 2010-05-24 EW ewlib/spi.fs \ spi, using hw interface \ needs in dict_appl.inc: \ .include "words/spirw.asm" \ words: \ +spi ( -- ) \ -spi ( -- ) \ > $51 \ needs these defined before loading: PORTB 4 portpin: /ss \ PORTB 5 portpin: _mosi \ PORTB 6 portpin: _miso \ PORTB 7 portpin: _clk : +spi ( -- ) /ss high \ activate pullup! _mosi high _mosi pin_output _clk low _clk pin_output \ not needed, see datasheet \ _miso pin_pullup_on \ enable, master mode, f/128 data rate $53 SPCR c! ; : -spi 0 SPCR c! ; \ transfer 1 byte \ use spirw ( c -- c' ) \ transfer 1 cell : >< spirw swap spirw swap >< + ; \ fin