Parallax 28560 Manual page 17

Mouse sensor kit
Table of Contents

Advertisement

sd = addr
GOSUB WriteNeg
GOSUB ReadNeg
#ELSE
SHIFTOUT sdio, sclk, MSBFIRST, [addr\8]
INPUT sdio
SHIFTIN sdio, sclk, MSBPOST, [dat\8]
#ENDIF
RETURN
WriteAddr:
' WriteAddr writes data to a sensor chip register.
'
Inputs:
addr = address ($00 - $7F) to write.
'
dat
= data to write to the addressed register.
#IF (NEG_CLK) #THEN
sd = addr | $80
GOSUB WriteNeg
sd = dat
GOSUB WriteNeg
#ELSE
SHIFTOUT sdio, sclk, MSBFIRST, [addr|$80\8, dat\8]
#ENDIF
RETURN
WriteNeg:
' WriteNeg simulates the SHIFTOUT instruction, but with a
' negative-going (inverted) clock.
'
Inputs: sd = data to write, MSB first.
OUTPUT sdio
FOR i = 0 TO 7
sdio = sd.BIT7
PULSOUT sclk, 25
sd = sd << 1
NEXT
INPUT sdio
RETURN
ReadNeg:
' ReadNeg simulates the SHIFTIN instruction, but with a
' negative-going (inverted) clock.
'
Outputs: dat = data read from serial bus, MSB first.
FOR i = 0 TO 7
dat = dat << 1
PULSOUT sclk, 25
dat.BIT0 = sdio
NEXT
RETURN
Copyright © Parallax Inc.
Mouse Sensor Kit (#28560)
v1.0 6/1/2010 Page 17 of 18

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the 28560 and is the answer not in the manual?

Table of Contents