retroforth/vm/nga-c-native-x86/x86/serial.retro
crc ea8e12d32a finish reorg of main sources
FossilOrigin-Name: 6a7ee82ed6b024ee1d8f7a51a9b91a66a8041cde06b53cce649d6bd383ae9677
2019-11-22 18:30:02 +00:00

23 lines
998 B
Text

# Serial Port
This was adapted from the RETRO9 serial driver. To use it,
set the `serial:Port` variable to the port you want to use.
Then do `serial:init` and read/write as necessary.
~~~
#1016 'serial:COM1 const
#760 'serial:COM2 const
#1000 'serial:COM3 const
#744 'serial:COM4 const
serial:COM1 'serial:Port var<n>
:serial:received? @serial:Port #5 + pio:in-byte #1 and n:-zero? ;
:serial:empty? @serial:Port #5 + pio:in-byte #32 and n:-zero? ;
:serial:read serial:received? [ @serial:Port pio:in-byte ] if; serial:read ;
:serial:write serial:empty? [ @serial:Port pio:out-byte ] if; serial:write ;
:serial:send [ serial:write ] s:for-each ;
:serial:init #0 @serial:Port #1 + pio:out-byte #128 @serial:Port #3 + pio:out-byte
#3 @serial:Port pio:out-byte #0 @serial:Port #1 + pio:out-byte
#3 @serial:Port #3 + pio:out-byte #199 @serial:Port #2 + pio:out-byte
#11 @serial:Port #4 + pio:out-byte ;
~~~