retroforth/vm/nga-c-native-x86/x86/serial.retro
crc 01b9700489 retro-native: fix use of old word names
FossilOrigin-Name: 447d56fbf6f9906299262f4657a95a2e77c260226a8bb3a4bf8cae4f2d81b429
2020-08-27 19:17:38 +00:00

23 lines
997 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 ;
~~~