\ 2006-07-09 EW i2c bus master \ No Error Checking whatsoever ! \ \ expects: \ PinSDA PinSCL \ PortI2C PddrI2C \ provides: \ NB>i2c ( xN .. x1.msB N addr -- ) \ send N bytes to i2c device at addr \ NBi2c ( f -- ) IF sda1 ELSE sda0 ENDIF i2c_tick scl1 2i2c_tick scl0 i2c_tick ; \ send 1 Byte, 8 Bit, msb first : >i2c ( x -- ) 8 0 DO dup 8 I 1+ - getBit bit>i2c LOOP drop ; \ read 1 Byte, 8 Bit, msb first : i2c ( x1 .. xN.msB N addr -- ) i2c_start >i2c acki2c acki2c ack IF 0 DO \ loop N-1 times i2c \ read byte, send ACK LOOP ENDIF i2c \ read last byte, send NACK i2c_stop ;