27220 Parallax Inc, 27220 Datasheet - Page 192

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
' Random location read
' -- pass device slave address in "slvAddr"
' -- pass bytes in word address (0, 1 or 2) in "addrLen"
' -- word address to write passed in "wrdAddr"
' -- data byte read is returned in "i2cData"
Read_Byte:
' -----[ Low Level I2C Subroutines ]---------------------------------------
' *** Start Sequence ***
I2C_Start:
Clock_Hold:
' *** Transmit Byte ***
I2C_TX_Byte:
GOSUB I2C_Start
IF (addrLen > 0) THEN
ENDIF
i2cWork = slvAddr | %00000001
GOSUB I2C_TX_Byte
GOSUB I2C_RX_Byte_Nak
GOSUB I2C_Stop
i2cData = i2cWork
RETURN
INPUT SDA
INPUT SCL
LOW SDA
DO : LOOP UNTIL (SCL = 1)
RETURN
SHIFTOUT SDA, SCL, MSBFIRST, [i2cWork\8]
SHIFTIN SDA, SCL, MSBPRE, [i2cAck\1]
RETURN
i2cWork = slvAddr & %11111110
GOSUB I2C_TX_Byte
IF (i2cAck = Nak) THEN Read_Byte
IF (addrLen = 2) THEN
ENDIF
i2cWork = wrdAddr.BYTE0
GOSUB I2C_TX_Byte
GOSUB I2C_Start
i2cWork = wrdAddr.BYTE1
GOSUB I2C_TX_Byte
' send Start
' send slave ID (write)
' wait until not busy
' send word address (1)
' send word address (0)
' send slave ID (read)
' I2C start bit sequence
' wait for clock release
' send byte to device
' get acknowledge bit

Related parts for 27220