You can use FullDuplexSerialPlus (available in the obex {edit: it's for some reason not available in the obex, but a google search will turn it up.}) as a serial communication object (like SEROUT and SERIN).
For the transceiver, anything that you send on the serial line will be replicated by the receiver unit on it's RX line. From the documentation, for BS2:
Code:
DO
PULSOUT 0, 1200 'Sync pulse for the receiver
SEROUT 0, 16468, [ "!", x.HIGHBYTE, x.LOWBYTE, y.HIGHBYTE, y.LOWBYTE ]
x = x + 1
y = y + 1
PAUSE 10
LOOP
So, in this example the transmitter sends 5 bytes: a ! and two two-byte numbers.
Most objects in Spin will require some sort of initialization at the beginning of the program, and FullDuplexSerial plus is no different. To send it in Spin using the FullDuplexSerialPlus object would be something like:
Code:
serialobj.start(rxpin, txpin, 0, 9600)
DIRA[radio_pulse_pin]~~ 'set the pin to output
'somewhere later...
OUTA[radio_pulse_pin]~~ 'set the pin high
waitcnt(clkfreq/1000*100 + cnt) 'pulse high time
OUTA[radio_pulse_pin]~ 'set the pin low
serialobj.tx("!")
serialobj.tx( (x&$FF00)>>8) 'get the high byte of x
serialobj.tx( (x&$FF) ) 'get the low byte of x
The GPS module will use a similar procedure, but you'll probably want to have the bs2 code open so you can just mechanically translate it to spin.
Bookmarks