home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine 1997 / ARCHIVE_97.iso / discs / mag_discs / volume_08 / issue_06 / risc_os / kernel / Serial < prev    next >
Text File  |  1988-09-28  |  9KB  |  228 lines

  1. ; > &.Doc180.Kernel.Serial
  2.  
  3. Title:          Serial extensions/1
  4. Version:        0.06
  5. Started:        08-Apr-88
  6. Last updated:   28-Sep-88
  7. Status:         Complete
  8.  
  9. Serial Line Extensions
  10. ----------------------
  11.  
  12. The Arthur serial line interface is very closely modelled on the Beeb
  13. serial line interface. That in turn was modelled on the 6850 ACIA chip
  14. in the Beeb.
  15.  
  16. This document describes extensions to the RS423 serial line interface
  17. in RISC OS 2.00. These extensions are in addition to fixing some of the
  18. problems in Arthur 1.20, which are caused by a faulty ACIA chip.
  19.  
  20. Extensions to FX 7 and 8
  21. ------------------------
  22. OSBYTE calls 7 and 8 are used to set the receive and transmit baud rates
  23. respectively. The range of parameters has been extended to allow access to
  24. the baud rates available on the 6551 ACIA which were not available on earlier
  25. BBC machines. The full set of parameters is as follows:-
  26.  
  27. 0 => 9600                       9  => 50
  28. 1 => 75                         10 => 110
  29. 2 => 150                        11 => 134.5
  30. 3 => 300                        12 => 600
  31. 4 => 1200                       13 => 1800
  32. 5 => 2400                       14 => 3600
  33. 6 => 4800                       15 => 7200
  34. 7 => 9600
  35. 8 => 19200
  36.  
  37. SWI OS_SerialOp (&57)
  38. ---------------------
  39.  
  40. in:     R0 = reason code
  41.         Other input registers as determined by reason code
  42.  
  43. out:    V=1 => R0 -> error
  44.         V=0 => R0 preserved
  45.         Other registers may return values, as determined by reason code
  46.  
  47. Reason code R0=0 (Read/write serial states)
  48. -------------------------------------------
  49. This call is used to read and write various states of the serial system. These
  50. states are presented as a 32-bit word. The call performs the operation
  51.  
  52. New state = (Old state AND R2) EOR R1
  53.  
  54. in:     R1 = EOR mask
  55.         R2 = AND mask
  56.  
  57. out:    R1 = old value of state
  58.         R2 = new value of state
  59.  
  60. The bits in the serial state have the following meanings:-
  61.  
  62. Read/Write flags
  63. ----------------
  64. Bit     Meaning
  65. ---     -------
  66. 0       Clear => No software flow-control (must rely on hardware handshaking).
  67.  
  68.         Set   => Use XON/XOFF flow-control protocol. The hardware will still
  69.                  do CTS handshaking (ie if CTS goes low transmission will
  70.                  stop), but we will not make RTS go low from our end.
  71.  
  72. 1       Clear => If the ~DCD bit in the status register goes high, then cause
  73.                  an RS423 event. Also, if a character is received when ~DCD is
  74.                  high, then cause an RS423 event, and do not enter character
  75.                  into buffer.
  76.  
  77.         Set   => Ignore the state of the ~DCD bit (apart from maintaining a
  78.                  soft copy of this bit for the user to read). Note, however,
  79.                  that both GTE and CMD chips prevent reception when the ~DCD
  80.                  bit is high, and the GTE chip causes transmit problems when
  81.                  this bit is high.
  82.                  
  83. 2       Clear => If the ~DSR bit in the status register is high, then do not
  84.                  transmit characters.
  85.  
  86.         Set   => Ignore the state of the ~DSR bit (apart from maintaining a
  87.                  soft copy of this bit for the user to read).
  88.  
  89. 3       Clear => DTR bit in command register programmed to 1 (data terminal
  90.                  ready).
  91.  
  92.         Set   => DTR bit in command register programmed to 0 (data terminal
  93.                  not ready). Note that in this state, the ACIA cannot transmit
  94.                  or receive characters. Any characters currently being
  95.                  transmitted or received when this state is selected may be
  96.                  garbled. The user should deselect this state before attempting
  97.                  to transmit or receive again.
  98.  
  99. 4..15   Undefined - do not modify these bits.
  100.  
  101. Read-only flags
  102. ---------------
  103. Bit     Meaning
  104. ---     -------
  105. 16      Clear => Your transmission has not been stopped by the reception of an
  106.                  XOFF character (always clear if XON/XOFF not being used).
  107.  
  108.         Set   => Your transmission has been stopped by the reception of an XOFF
  109.                  character.
  110.  
  111. 17      Clear => You intend the other end to be in the XON (enabled) state.
  112.  
  113.         Set   => You intend the other end to be in the XOFF (disabled) state.
  114.  
  115.         When a character is received, and the buffer is nearly full (as
  116.         determined by OSBYTE 203), and XON/XOFF protocol is being used, then
  117.         this bit gets set, and on the next transmit interrupt an XOFF character
  118.         will be sent. When sufficient characters have been removed from the
  119.         input buffer to render it not nearly full, this bit is cleared and on
  120.         the next transmit interrupt an XON character is sent. Note that the
  121.         fact that this bit is set does not imply that the other end has
  122.         received an XOFF character yet.
  123.  
  124. 18      Clear => the ~DCD bit in the status register is low, indicating that
  125.                  carrier is present.
  126.  
  127.         Set   => the ~DCD bit in the status register is high, indicate absence
  128.                  of carrier. In this state the ACIA receiver is disabled (and
  129.                  on GTE chips transmission is affected, too)
  130.  
  131. 19      Clear => the ~DSR bit in the status register is low, indicating a
  132.                  'ready' state.
  133.  
  134.         Set   => the ~DSR bit in the status register is high, indicating a
  135.                  'not-ready' state. If bit 2 of the serial state is clear, then
  136.                  no characters will be transmitted in this state.
  137.  
  138. 20      Clear => the ring indicator bit in IOC is low.
  139.  
  140.         Set   => the ring indicator bit in IOC is high.
  141.  
  142. 21..31  Undefined - do not modify these bits.
  143.  
  144. Reason code R0=1 (Read/write data format)
  145. -----------------------------------------
  146.  
  147. in:     R1 = -1 => just read format
  148.         R1 <> -1 => R1 determines new format
  149.  
  150.           Bits 0,1 : 0 => 8 bit word
  151.                      1 => 7 bit word
  152.                      2 => 6 bit word
  153.                      3 => 5 bit word
  154.  
  155.           Bit 2    : 0 => 1 stop bit
  156.                      1 => 2 stop bits
  157.                   OR 1.5 stop bits if 5 bit word without parity
  158.                   OR 1   stop bit  if 8 bit word with parity
  159.  
  160.           Bit 3    : 0 => parity disabled (no parity bit)
  161.                      1 => parity enabled
  162.  
  163.           Bits 4,5 : 0 => odd parity
  164.                      1 => even parity
  165.                      2 => parity bit always 1 on TX (ignored on RX)
  166.                      3 => parity bit always 0 on TX (------""-----)
  167.  
  168. out:    R1 = old format in bits 0..5 as above
  169.  
  170. Reason code R0=2 (Send break)
  171. -----------------------------
  172.  
  173. in:     R1 = length of break in centiseconds
  174.  
  175. out:    R1 preserved
  176.  
  177. This call sets the ACIA to transmit a break, then waits in the foreground with
  178. IRQs on for R1 centiseconds before resetting it to normal. Note that any
  179. character being transmitted at the time the call is made may be garbled. After
  180. sending the break the remaining characters in the output buffer (if any) will
  181. be transmitted.
  182.  
  183. Reason code R0=3 (Send byte)
  184. ----------------------------
  185.  
  186. in:     R1 = character to be sent
  187.  
  188. out:    R1 preserved
  189.         C=0 => character sent
  190.         C=1 => character not sent (because buffer full)
  191.  
  192. This call puts a character in the RS423 output buffer, and reenables the
  193. transmit interrupt if it had previously been disabled by the MOS.
  194.  
  195. Reason code R0=4 (Get byte)
  196. ---------------------------
  197.  
  198. in:     -
  199.  
  200. out:    C=0 => R1 = character read
  201.         C=1 => R1 preserved, no character read, input buffer empty
  202.  
  203. This call removes a character from the RS423 input buffer, if one is present.
  204. If removing a character leaves the input buffer with more free spaces than are
  205. specified by OSBYTE 203, then the other end is encouraged to start transmitting
  206. again - this may involve either reenabling RTS or the transmission of an XON
  207. character, depending on which protocol has been selected (see above).
  208.  
  209. Note that reception must have been enabled with FX2,2 (or FX2,1) before this
  210. call can be used.
  211.  
  212. Reason code R0=5 (Read/set receive baud rate)
  213. ---------------------------------------------
  214.  
  215. in:     R1 = -1 => just read receive baud rate
  216.         R1 = 0..15 => set receive baud rate to this value (as for FX 7 or 8)
  217.  
  218. out:    R1 = old receive baud rate, in range 0..15
  219.  
  220. Reason code R0=6 (Read/set transmit baud rate)
  221. ---------------------------------------------
  222.  
  223. in:     R1 = -1 => just read transmit baud rate
  224.         R1 = 0..15 => set transmit baud rate to this value (as for FX 7 or 8)
  225.  
  226. out:    R1 = old transmit baud rate, in range 0..15
  227.  
  228.