home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / oslib / oslib_1 / OSLib / Computer / h / osserialop < prev    next >
Encoding:
Text File  |  1995-06-29  |  9.4 KB  |  284 lines

  1. #ifndef osserialop_H
  2. #define osserialop_H
  3.  
  4. /* C header file for OSSerialOp
  5.  * written by DefMod (Jun 20 1995) on Thu Jun 29 16:56:39 1995
  6.  * Jonathan Coxhead, Acorn Computers Ltd
  7.  */
  8.  
  9. #ifndef types_H
  10. #include "types.h"
  11. #endif
  12.  
  13. #ifndef os_H
  14. #include "os.h"
  15. #endif
  16.  
  17. /**********************************
  18.  * SWI names and SWI reason codes *
  19.  **********************************/
  20. #undef  OS_SerialOp
  21. #define OS_SerialOp                             0x57
  22. #undef  XOS_SerialOp
  23. #define XOS_SerialOp                            0x20057
  24. #undef  OSSerialOp_Status
  25. #define OSSerialOp_Status                       0x0
  26. #undef  OSSerialOp_DataFormat
  27. #define OSSerialOp_DataFormat                   0x1
  28. #undef  OSSerialOp_Break
  29. #define OSSerialOp_Break                        0x2
  30. #undef  OSSerialOp_BPut
  31. #define OSSerialOp_BPut                         0x3
  32. #undef  OSSerialOp_BGet
  33. #define OSSerialOp_BGet                         0x4
  34. #undef  OSSerialOp_RxBaudRate
  35. #define OSSerialOp_RxBaudRate                   0x5
  36. #undef  OSSerialOp_TxBaudRate
  37. #define OSSerialOp_TxBaudRate                   0x6
  38. #undef  OSSerialOp_RxThreshold
  39. #define OSSerialOp_RxThreshold                  0x8
  40. #undef  OSSerialOp_EnumerateBaudRates
  41. #define OSSerialOp_EnumerateBaudRates           0x9
  42. #undef  SerialV
  43. #define SerialV                                 0x24
  44. #undef  Event_RS423Error
  45. #define Event_RS423Error                        0x7
  46.  
  47. /********************
  48.  * Type definitions *
  49.  ********************/
  50. typedef bits osserialop_rs423_status;
  51.  
  52. typedef bits osserialop_format_flags;
  53.  
  54. typedef int osserialop_baud_rate;
  55.  
  56. /************************
  57.  * Constant definitions *
  58.  ************************/
  59. #define osserialop_RS423_PARITY_ERROR           ((osserialop_rs423_status) 0x20u)
  60. #define osserialop_RS423_OVERRUN_ERROR          ((osserialop_rs423_status) 0x10u)
  61. #define osserialop_RS423_FRAMING_ERROR          ((osserialop_rs423_status) 0x8u)
  62. #define osserialop_DATA_FORMAT_WORD_SIZE        ((osserialop_format_flags) 0x3u)
  63. #define osserialop_DATA_FORMAT_WORD_SIZE_SHIFT  0
  64. #define osserialop_DATA_FORMAT_WORD_SIZE8_BIT   0
  65. #define osserialop_DATA_FORMAT_WORD_SIZE7_BIT   1
  66. #define osserialop_DATA_FORMAT_WORD_SIZE6_BIT   3
  67. #define osserialop_DATA_FORMAT_EXTRA_STOP_BITS  ((osserialop_format_flags) 0x4u)
  68. #define osserialop_DATA_FORMAT_PARITY_ENABLE    ((osserialop_format_flags) 0x8u)
  69. #define osserialop_DATA_FORMAT_PARITY           ((osserialop_format_flags) 0x30u)
  70. #define osserialop_DATA_FORMAT_PARITY_SHIFT     4
  71. #define osserialop_DATA_FORMAT_PARITY_ODD       0
  72. #define osserialop_DATA_FORMAT_PARITY_EVEN      1
  73. #define osserialop_DATA_FORMAT_PARITY1          2
  74. #define osserialop_DATA_FORMAT_PARITY0          3
  75. #define osserialop_BAUD_RATE9600                ((osserialop_baud_rate) 0x7u)
  76. #define osserialop_BAUD_RATE75                  ((osserialop_baud_rate) 0x1u)
  77. #define osserialop_BAUD_RATE150                 ((osserialop_baud_rate) 0x2u)
  78. #define osserialop_BAUD_RATE300                 ((osserialop_baud_rate) 0x3u)
  79. #define osserialop_BAUD_RATE1200                ((osserialop_baud_rate) 0x4u)
  80. #define osserialop_BAUD_RATE2400                ((osserialop_baud_rate) 0x5u)
  81. #define osserialop_BAUD_RATE4800                ((osserialop_baud_rate) 0x6u)
  82. #define osserialop_BAUD_RATE19200               ((osserialop_baud_rate) 0x8u)
  83. #define osserialop_BAUD_RATE50                  ((osserialop_baud_rate) 0x9u)
  84. #define osserialop_BAUD_RATE110                 ((osserialop_baud_rate) 0xAu)
  85. #define osserialop_BAUD_RATE134PT5              ((osserialop_baud_rate) 0xBu)
  86. #define osserialop_BAUD_RATE600                 ((osserialop_baud_rate) 0xCu)
  87. #define osserialop_BAUD_RATE1800                ((osserialop_baud_rate) 0xDu)
  88. #define osserialop_BAUD_RATE3600                ((osserialop_baud_rate) 0xEu)
  89. #define osserialop_BAUD_RATE7200                ((osserialop_baud_rate) 0xFu)
  90. #define osserialop_BAUD_RATE38400               ((osserialop_baud_rate) 0x10u)
  91. #define osserialop_BAUD_RATE57600               ((osserialop_baud_rate) 0x11u)
  92. #define osserialop_BAUD_RATE115200              ((osserialop_baud_rate) 0x12u)
  93.  
  94. /*************************
  95.  * Function declarations *
  96.  *************************/
  97.  
  98. #ifdef __cplusplus
  99.    extern "C" {
  100. #endif
  101.  
  102. /* ------------------------------------------------------------------------
  103.  * Function:      osserialop_status()
  104.  *
  105.  * Description:   Reads/writes the serial status
  106.  *
  107.  * Input:         eor_mask - value of R1 on entry
  108.  *                and_mask - value of R2 on entry
  109.  *
  110.  * Output:        old_value - value of R1 on exit (X version only)
  111.  *                new_value - value of R2 on exit
  112.  *
  113.  * Returns:       R1 (non-X version only)
  114.  *
  115.  * Other notes:   Calls SWI 0x57 with R0 = 0x0.
  116.  */
  117.  
  118. extern os_error *xosserialop_status (bits eor_mask,
  119.       bits and_mask,
  120.       bits *old_value,
  121.       bits *new_value);
  122. extern bits osserialop_status (bits eor_mask,
  123.       bits and_mask,
  124.       bits *new_value);
  125.  
  126. /* ------------------------------------------------------------------------
  127.  * Function:      osserialop_data_format()
  128.  *
  129.  * Description:   Reads/writes the data format
  130.  *
  131.  * Input:         data_format - value of R1 on entry
  132.  *
  133.  * Output:        old_value - value of R1 on exit (X version only)
  134.  *
  135.  * Returns:       R1 (non-X version only)
  136.  *
  137.  * Other notes:   Calls SWI 0x57 with R0 = 0x1.
  138.  */
  139.  
  140. extern os_error *xosserialop_data_format (osserialop_format_flags data_format,
  141.       osserialop_format_flags *old_value);
  142. extern osserialop_format_flags osserialop_data_format (osserialop_format_flags data_format);
  143.  
  144. /* ------------------------------------------------------------------------
  145.  * Function:      osserialop_break()
  146.  *
  147.  * Description:   Sends a break
  148.  *
  149.  * Input:         period - value of R1 on entry
  150.  *
  151.  * Other notes:   Calls SWI 0x57 with R0 = 0x2.
  152.  */
  153.  
  154. extern os_error *xosserialop_break (int period);
  155. extern void osserialop_break (int period);
  156.  
  157. /* ------------------------------------------------------------------------
  158.  * Function:      osserialop_bput()
  159.  *
  160.  * Description:   Sends a byte
  161.  *
  162.  * Input:         c - value of R1 on entry
  163.  *
  164.  * Output:        psr - processor status register on exit (X version only)
  165.  *
  166.  * Returns:       psr (non-X version only)
  167.  *
  168.  * Other notes:   Calls SWI 0x57 with R0 = 0x3.
  169.  */
  170.  
  171. extern os_error *xosserialop_bput (byte c,
  172.       bits *psr);
  173. extern bits osserialop_bput (byte c);
  174.  
  175. /* ------------------------------------------------------------------------
  176.  * Function:      osserialop_bget()
  177.  *
  178.  * Description:   Gets a byte from the serial buffer
  179.  *
  180.  * Output:        c - value of R1 on exit
  181.  *                psr - processor status register on exit (X version only)
  182.  *
  183.  * Returns:       psr (non-X version only)
  184.  *
  185.  * Other notes:   Calls SWI 0x57 with R0 = 0x4.
  186.  */
  187.  
  188. extern os_error *xosserialop_bget (byte *c,
  189.       bits *psr);
  190. extern bits osserialop_bget (byte *c);
  191.  
  192. /* ------------------------------------------------------------------------
  193.  * Function:      osserialop_rx_baud_rate()
  194.  *
  195.  * Description:   Reads/writes the receive baud rate
  196.  *
  197.  * Input:         rx_rate - value of R1 on entry
  198.  *
  199.  * Output:        old_rx_rate - value of R1 on exit (X version only)
  200.  *
  201.  * Returns:       R1 (non-X version only)
  202.  *
  203.  * Other notes:   Calls SWI 0x57 with R0 = 0x5.
  204.  */
  205.  
  206. extern os_error *xosserialop_rx_baud_rate (osserialop_baud_rate rx_rate,
  207.       osserialop_baud_rate *old_rx_rate);
  208. extern osserialop_baud_rate osserialop_rx_baud_rate (osserialop_baud_rate rx_rate);
  209.  
  210. /* ------------------------------------------------------------------------
  211.  * Function:      osserialop_tx_baud_rate()
  212.  *
  213.  * Description:   Reads/writes the transmit baud rate
  214.  *
  215.  * Input:         tx_rate - value of R1 on entry
  216.  *
  217.  * Output:        old_tx_rate - value of R1 on exit (X version only)
  218.  *
  219.  * Returns:       R1 (non-X version only)
  220.  *
  221.  * Other notes:   Calls SWI 0x57 with R0 = 0x6.
  222.  */
  223.  
  224. extern os_error *xosserialop_tx_baud_rate (osserialop_baud_rate tx_rate,
  225.       osserialop_baud_rate *old_tx_rate);
  226. extern osserialop_baud_rate osserialop_tx_baud_rate (osserialop_baud_rate tx_rate);
  227.  
  228. /* ------------------------------------------------------------------------
  229.  * Function:      osserialop_rx_threshold()
  230.  *
  231.  * Description:   Sets the receive threshold - RISC O S 3.5+
  232.  *
  233.  * Input:         rx_threshold - value of R1 on entry
  234.  *
  235.  * Output:        old_rx_threshold - value of R1 on exit (X version only)
  236.  *
  237.  * Returns:       R1 (non-X version only)
  238.  *
  239.  * Other notes:   Calls SWI 0x57 with R0 = 0x8.
  240.  */
  241.  
  242. extern os_error *xosserialop_rx_threshold (bits rx_threshold,
  243.       bits *old_rx_threshold);
  244. extern bits osserialop_rx_threshold (bits rx_threshold);
  245.  
  246. /* ------------------------------------------------------------------------
  247.  * Function:      osserialop_enumerate_baud_rates()
  248.  *
  249.  * Description:   Enumerates the available serial port speeds - RISC O S
  250.  *                3.5+
  251.  *
  252.  * Output:        table - value of R1 on exit
  253.  *                table_size - value of R2 on exit
  254.  *
  255.  * Other notes:   Calls SWI 0x57 with R0 = 0x9.
  256.  */
  257.  
  258. extern os_error *xosserialop_enumerate_baud_rates (int **table,
  259.       int *table_size);
  260. extern void osserialop_enumerate_baud_rates (int **table,
  261.       int *table_size);
  262.  
  263. /* ------------------------------------------------------------------------
  264.  * Function:      event_rs423_error()
  265.  *
  266.  * Description:   Calls reason code 7 of SWI 0x22
  267.  *
  268.  * Input:         status - value of R1 on entry
  269.  *                b - value of R2 on entry
  270.  *
  271.  * Other notes:   Before entry, R0 = 0x7.
  272.  */
  273.  
  274. extern os_error *xevent_rs423_error (osserialop_rs423_status status,
  275.       byte b);
  276. extern void event_rs423_error (osserialop_rs423_status status,
  277.       byte b);
  278.  
  279. #ifdef __cplusplus
  280.    }
  281. #endif
  282.  
  283. #endif
  284.