home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 1 / RISC_DISC_1.iso / pd_share / code / oslib / h / osserialop < prev    next >
Encoding:
Text File  |  1994-09-07  |  8.9 KB  |  284 lines

  1. #ifndef osserialop_H
  2. #define osserialop_H
  3.  
  4. /* C header file for OSSerialOp
  5.  * written by DefMod (Sep  7 1994) on Wed Sep  7 21:20:29 1994
  6.  * Copyright © Acorn Computers Ltd, 1994
  7.  */
  8.  
  9. /*************************************************************************
  10.  * This source file was written by Acorn Computers Limited. It is part   *
  11.  * of the OSLib library for writing applications for RISC OS. It may be  *
  12.  * used freely in the creation of programs for RISC OS.                  *
  13.  *************************************************************************/
  14.  
  15. #ifndef types_H
  16.    #include "types.h"
  17. #endif
  18.  
  19. #ifndef os_H
  20.    #include "os.h"
  21. #endif
  22.  
  23. /**********************************
  24.  * SWI names and SWI reason codes *
  25.  **********************************/
  26. #undef  OS_SerialOp
  27. #define OS_SerialOp                             0x57
  28. #undef  XOS_SerialOp
  29. #define XOS_SerialOp                            0x20057
  30. #undef  OSSerialOp_Status
  31. #define OSSerialOp_Status                       0x0
  32. #undef  OSSerialOp_DataFormat
  33. #define OSSerialOp_DataFormat                   0x1
  34. #undef  OSSerialOp_Break
  35. #define OSSerialOp_Break                        0x2
  36. #undef  OSSerialOp_BPut
  37. #define OSSerialOp_BPut                         0x3
  38. #undef  OSSerialOp_BGet
  39. #define OSSerialOp_BGet                         0x4
  40. #undef  OSSerialOp_RxBaudRate
  41. #define OSSerialOp_RxBaudRate                   0x5
  42. #undef  OSSerialOp_TxBaudRate
  43. #define OSSerialOp_TxBaudRate                   0x6
  44. #undef  OSSerialOp_RxThreshold
  45. #define OSSerialOp_RxThreshold                  0x8
  46. #undef  OSSerialOp_EnumerateBaudRates
  47. #define OSSerialOp_EnumerateBaudRates           0x9
  48. #undef  SerialV
  49. #define SerialV                                 0x24
  50. #undef  Event_RS423Error
  51. #define Event_RS423Error                        0x7
  52.  
  53. /************************
  54.  * Constant definitions *
  55.  ************************/
  56. #define osserialop_RS423_PARITY_ERROR           0x20u
  57. #define osserialop_RS423_OVERRUN_ERROR          0x10u
  58. #define osserialop_RS423_FRAMING_ERROR          0x8u
  59. #define osserialop_DATA_FORMAT_WORD_SIZE        0x3u
  60. #define osserialop_DATA_FORMAT_WORD_SIZE_SHIFT  0
  61. #define osserialop_DATA_FORMAT_WORD_SIZE8_BIT   0
  62. #define osserialop_DATA_FORMAT_WORD_SIZE7_BIT   1
  63. #define osserialop_DATA_FORMAT_WORD_SIZE6_BIT   3
  64. #define osserialop_DATA_FORMAT_EXTRA_STOP_BITS  0x4u
  65. #define osserialop_DATA_FORMAT_PARITY_ENABLE    0x8u
  66. #define osserialop_DATA_FORMAT_PARITY           0x30u
  67. #define osserialop_DATA_FORMAT_PARITY_SHIFT     4
  68. #define osserialop_DATA_FORMAT_PARITY_ODD       0
  69. #define osserialop_DATA_FORMAT_PARITY_EVEN      1
  70. #define osserialop_DATA_FORMAT_PARITY1          2
  71. #define osserialop_DATA_FORMAT_PARITY0          3
  72. #define osserialop_BAUD_RATE9600                7
  73. #define osserialop_BAUD_RATE75                  1
  74. #define osserialop_BAUD_RATE150                 2
  75. #define osserialop_BAUD_RATE300                 3
  76. #define osserialop_BAUD_RATE1200                4
  77. #define osserialop_BAUD_RATE2400                5
  78. #define osserialop_BAUD_RATE4800                6
  79. #define osserialop_BAUD_RATE19200               8
  80. #define osserialop_BAUD_RATE50                  9
  81. #define osserialop_BAUD_RATE110                 10
  82. #define osserialop_BAUD_RATE134PT5              11
  83. #define osserialop_BAUD_RATE600                 12
  84. #define osserialop_BAUD_RATE1800                13
  85. #define osserialop_BAUD_RATE3600                14
  86. #define osserialop_BAUD_RATE7200                15
  87.  
  88. /*************************
  89.  * Function declarations *
  90.  *************************/
  91.  
  92. #ifdef __cplusplus
  93.    extern "C" {
  94. #endif
  95.  
  96. /*************************************************************
  97.  * NOTE: The following functions provide direct access to    *
  98.  *       the SWI's noted in the function description.        *
  99.  *       Please read the relevant PRM section for more       *
  100.  *       information on their input/output parameters.       *
  101.  *************************************************************/
  102.  
  103. /* ------------------------------------------------------------------------
  104.  * Function:      osserialop_status()
  105.  *
  106.  * Description:   Reads/writes the serial status
  107.  *
  108.  * Input:         eor_mask - value of R1 on entry
  109.  *                and_mask - value of R2 on entry
  110.  *
  111.  * Output:        old_value - value of R1 on exit (X version only)
  112.  *                new_value - value of R2 on exit
  113.  *
  114.  * Returns:       R1 (non-X version only)
  115.  *
  116.  * Other notes:   Calls SWI 0x57 with R0 = 0x0.
  117.  */
  118.  
  119. extern os_error *xosserialop_status (bits eor_mask,
  120.       bits and_mask,
  121.       bits *old_value,
  122.       bits *new_value);
  123. extern bits osserialop_status (bits eor_mask,
  124.       bits and_mask,
  125.       bits *new_value);
  126.  
  127. /* ------------------------------------------------------------------------
  128.  * Function:      osserialop_data_format()
  129.  *
  130.  * Description:   Reads/writes the data format
  131.  *
  132.  * Input:         data_format - value of R1 on entry
  133.  *
  134.  * Output:        old_value - value of R1 on exit (X version only)
  135.  *
  136.  * Returns:       R1 (non-X version only)
  137.  *
  138.  * Other notes:   Calls SWI 0x57 with R0 = 0x1.
  139.  */
  140.  
  141. extern os_error *xosserialop_data_format (bits data_format,
  142.       bits *old_value);
  143. extern bits osserialop_data_format (bits data_format);
  144.  
  145. /* ------------------------------------------------------------------------
  146.  * Function:      osserialop_break()
  147.  *
  148.  * Description:   Sends a break
  149.  *
  150.  * Input:         period - value of R1 on entry
  151.  *
  152.  * Other notes:   Calls SWI 0x57 with R0 = 0x2.
  153.  */
  154.  
  155. extern os_error *xosserialop_break (int period);
  156. extern void osserialop_break (int period);
  157.  
  158. /* ------------------------------------------------------------------------
  159.  * Function:      osserialop_bput()
  160.  *
  161.  * Description:   Sends a byte
  162.  *
  163.  * Input:         c - value of R1 on entry
  164.  *
  165.  * Output:        psr - processor status register on exit (X version only)
  166.  *
  167.  * Returns:       psr (non-X version only)
  168.  *
  169.  * Other notes:   Calls SWI 0x57 with R0 = 0x3.
  170.  */
  171.  
  172. extern os_error *xosserialop_bput (byte c,
  173.       bits *psr);
  174. extern bits osserialop_bput (byte c);
  175.  
  176. /* ------------------------------------------------------------------------
  177.  * Function:      osserialop_bget()
  178.  *
  179.  * Description:   Gets a byte from the serial buffer
  180.  *
  181.  * Output:        c - value of R1 on exit
  182.  *                psr - processor status register on exit (X version only)
  183.  *
  184.  * Returns:       psr (non-X version only)
  185.  *
  186.  * Other notes:   Calls SWI 0x57 with R0 = 0x4.
  187.  */
  188.  
  189. extern os_error *xosserialop_bget (byte *c,
  190.       bits *psr);
  191. extern bits osserialop_bget (byte *c);
  192.  
  193. /* ------------------------------------------------------------------------
  194.  * Function:      osserialop_rx_baud_rate()
  195.  *
  196.  * Description:   Reads/writes the receive baud rate
  197.  *
  198.  * Input:         rx_rate - value of R1 on entry
  199.  *
  200.  * Output:        old_rx_rate - value of R1 on exit (X version only)
  201.  *
  202.  * Returns:       R1 (non-X version only)
  203.  *
  204.  * Other notes:   Calls SWI 0x57 with R0 = 0x5.
  205.  */
  206.  
  207. extern os_error *xosserialop_rx_baud_rate (int rx_rate,
  208.       bits *old_rx_rate);
  209. extern bits osserialop_rx_baud_rate (int rx_rate);
  210.  
  211. /* ------------------------------------------------------------------------
  212.  * Function:      osserialop_tx_baud_rate()
  213.  *
  214.  * Description:   Reads/writes the transmit baud rate
  215.  *
  216.  * Input:         tx_rate - value of R1 on entry
  217.  *
  218.  * Output:        old_tx_rate - value of R1 on exit (X version only)
  219.  *
  220.  * Returns:       R1 (non-X version only)
  221.  *
  222.  * Other notes:   Calls SWI 0x57 with R0 = 0x6.
  223.  */
  224.  
  225. extern os_error *xosserialop_tx_baud_rate (int tx_rate,
  226.       bits *old_tx_rate);
  227. extern bits osserialop_tx_baud_rate (int tx_rate);
  228.  
  229. /* ------------------------------------------------------------------------
  230.  * Function:      osserialop_rx_threshold()
  231.  *
  232.  * Description:   Sets the receive threshold
  233.  *
  234.  * Input:         rx_threshold - value of R1 on entry
  235.  *
  236.  * Output:        old_rx_threshold - value of R1 on exit (X version only)
  237.  *
  238.  * Returns:       R1 (non-X version only)
  239.  *
  240.  * Other notes:   Calls SWI 0x57 with R0 = 0x8.
  241.  */
  242.  
  243. extern os_error *xosserialop_rx_threshold (int rx_threshold,
  244.       bits *old_rx_threshold);
  245. extern bits osserialop_rx_threshold (int rx_threshold);
  246.  
  247. /* ------------------------------------------------------------------------
  248.  * Function:      osserialop_enumerate_baud_rates()
  249.  *
  250.  * Description:   Enumerates the available serial port speeds
  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 (bits status,
  275.       byte b);
  276. extern void event_rs423_error (bits status,
  277.       byte b);
  278.  
  279. #ifdef __cplusplus
  280.    }
  281. #endif
  282.  
  283. #endif
  284.