Copyright © Parallax Inc.
Page 9 of 12
start
send(WRITE)
send(SUB1)
send(data)
stop
PUB Read_1B(SUB3) | rxd
''Read single byte from Gyroscope
start
send(WRITE)
send(SUB3)
stop
start
send(READ)
rxd := receive(false)
stop
result := rxd
PUB Read_MultiB(SUB3)
''Read multiple bytes from Gyroscope
start
send(WRITE)
send(SUB3)
stop
start
send(READ)
multiBYTE[x_idx] := (receive(true)) | (receive(true)) << 8
multiBYTE[y_idx] := (receive(true)) | (receive(true)) << 8
multiBYTE[z_idx] := (receive(true)) | (receive(false)) << 8
stop
x := ~~multiBYTE[x_idx]
y := ~~multiBYTE[y_idx]
z := ~~multiBYTE[z_idx]
PRI send(value)
value := ((!value) >< 8)
repeat 8
dira[SDApin] := value
dira[SCLpin] := false
dira[SCLpin] := true
value >>= 1
dira[SDApin] := false
dira[SCLpin] := false
result := not(ina[SDApin])
dira[SCLpin] := true
dira[SDApin] := true
PRI receive(aknowledge)