home *** CD-ROM | disk | FTP | other *** search
- #ifndef osserialop_H
- #define osserialop_H
-
- /* C header file for OSSerialOp
- * written by DefMod (Sep 7 1994) on Wed Sep 7 21:20:29 1994
- * Copyright © Acorn Computers Ltd, 1994
- */
-
- /*************************************************************************
- * This source file was written by Acorn Computers Limited. It is part *
- * of the OSLib library for writing applications for RISC OS. It may be *
- * used freely in the creation of programs for RISC OS. *
- *************************************************************************/
-
- #ifndef types_H
- #include "types.h"
- #endif
-
- #ifndef os_H
- #include "os.h"
- #endif
-
- /**********************************
- * SWI names and SWI reason codes *
- **********************************/
- #undef OS_SerialOp
- #define OS_SerialOp 0x57
- #undef XOS_SerialOp
- #define XOS_SerialOp 0x20057
- #undef OSSerialOp_Status
- #define OSSerialOp_Status 0x0
- #undef OSSerialOp_DataFormat
- #define OSSerialOp_DataFormat 0x1
- #undef OSSerialOp_Break
- #define OSSerialOp_Break 0x2
- #undef OSSerialOp_BPut
- #define OSSerialOp_BPut 0x3
- #undef OSSerialOp_BGet
- #define OSSerialOp_BGet 0x4
- #undef OSSerialOp_RxBaudRate
- #define OSSerialOp_RxBaudRate 0x5
- #undef OSSerialOp_TxBaudRate
- #define OSSerialOp_TxBaudRate 0x6
- #undef OSSerialOp_RxThreshold
- #define OSSerialOp_RxThreshold 0x8
- #undef OSSerialOp_EnumerateBaudRates
- #define OSSerialOp_EnumerateBaudRates 0x9
- #undef SerialV
- #define SerialV 0x24
- #undef Event_RS423Error
- #define Event_RS423Error 0x7
-
- /************************
- * Constant definitions *
- ************************/
- #define osserialop_RS423_PARITY_ERROR 0x20u
- #define osserialop_RS423_OVERRUN_ERROR 0x10u
- #define osserialop_RS423_FRAMING_ERROR 0x8u
- #define osserialop_DATA_FORMAT_WORD_SIZE 0x3u
- #define osserialop_DATA_FORMAT_WORD_SIZE_SHIFT 0
- #define osserialop_DATA_FORMAT_WORD_SIZE8_BIT 0
- #define osserialop_DATA_FORMAT_WORD_SIZE7_BIT 1
- #define osserialop_DATA_FORMAT_WORD_SIZE6_BIT 3
- #define osserialop_DATA_FORMAT_EXTRA_STOP_BITS 0x4u
- #define osserialop_DATA_FORMAT_PARITY_ENABLE 0x8u
- #define osserialop_DATA_FORMAT_PARITY 0x30u
- #define osserialop_DATA_FORMAT_PARITY_SHIFT 4
- #define osserialop_DATA_FORMAT_PARITY_ODD 0
- #define osserialop_DATA_FORMAT_PARITY_EVEN 1
- #define osserialop_DATA_FORMAT_PARITY1 2
- #define osserialop_DATA_FORMAT_PARITY0 3
- #define osserialop_BAUD_RATE9600 7
- #define osserialop_BAUD_RATE75 1
- #define osserialop_BAUD_RATE150 2
- #define osserialop_BAUD_RATE300 3
- #define osserialop_BAUD_RATE1200 4
- #define osserialop_BAUD_RATE2400 5
- #define osserialop_BAUD_RATE4800 6
- #define osserialop_BAUD_RATE19200 8
- #define osserialop_BAUD_RATE50 9
- #define osserialop_BAUD_RATE110 10
- #define osserialop_BAUD_RATE134PT5 11
- #define osserialop_BAUD_RATE600 12
- #define osserialop_BAUD_RATE1800 13
- #define osserialop_BAUD_RATE3600 14
- #define osserialop_BAUD_RATE7200 15
-
- /*************************
- * Function declarations *
- *************************/
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /*************************************************************
- * NOTE: The following functions provide direct access to *
- * the SWI's noted in the function description. *
- * Please read the relevant PRM section for more *
- * information on their input/output parameters. *
- *************************************************************/
-
- /* ------------------------------------------------------------------------
- * Function: osserialop_status()
- *
- * Description: Reads/writes the serial status
- *
- * Input: eor_mask - value of R1 on entry
- * and_mask - value of R2 on entry
- *
- * Output: old_value - value of R1 on exit (X version only)
- * new_value - value of R2 on exit
- *
- * Returns: R1 (non-X version only)
- *
- * Other notes: Calls SWI 0x57 with R0 = 0x0.
- */
-
- extern os_error *xosserialop_status (bits eor_mask,
- bits and_mask,
- bits *old_value,
- bits *new_value);
- extern bits osserialop_status (bits eor_mask,
- bits and_mask,
- bits *new_value);
-
- /* ------------------------------------------------------------------------
- * Function: osserialop_data_format()
- *
- * Description: Reads/writes the data format
- *
- * Input: data_format - value of R1 on entry
- *
- * Output: old_value - value of R1 on exit (X version only)
- *
- * Returns: R1 (non-X version only)
- *
- * Other notes: Calls SWI 0x57 with R0 = 0x1.
- */
-
- extern os_error *xosserialop_data_format (bits data_format,
- bits *old_value);
- extern bits osserialop_data_format (bits data_format);
-
- /* ------------------------------------------------------------------------
- * Function: osserialop_break()
- *
- * Description: Sends a break
- *
- * Input: period - value of R1 on entry
- *
- * Other notes: Calls SWI 0x57 with R0 = 0x2.
- */
-
- extern os_error *xosserialop_break (int period);
- extern void osserialop_break (int period);
-
- /* ------------------------------------------------------------------------
- * Function: osserialop_bput()
- *
- * Description: Sends a byte
- *
- * Input: c - value of R1 on entry
- *
- * Output: psr - processor status register on exit (X version only)
- *
- * Returns: psr (non-X version only)
- *
- * Other notes: Calls SWI 0x57 with R0 = 0x3.
- */
-
- extern os_error *xosserialop_bput (byte c,
- bits *psr);
- extern bits osserialop_bput (byte c);
-
- /* ------------------------------------------------------------------------
- * Function: osserialop_bget()
- *
- * Description: Gets a byte from the serial buffer
- *
- * Output: c - value of R1 on exit
- * psr - processor status register on exit (X version only)
- *
- * Returns: psr (non-X version only)
- *
- * Other notes: Calls SWI 0x57 with R0 = 0x4.
- */
-
- extern os_error *xosserialop_bget (byte *c,
- bits *psr);
- extern bits osserialop_bget (byte *c);
-
- /* ------------------------------------------------------------------------
- * Function: osserialop_rx_baud_rate()
- *
- * Description: Reads/writes the receive baud rate
- *
- * Input: rx_rate - value of R1 on entry
- *
- * Output: old_rx_rate - value of R1 on exit (X version only)
- *
- * Returns: R1 (non-X version only)
- *
- * Other notes: Calls SWI 0x57 with R0 = 0x5.
- */
-
- extern os_error *xosserialop_rx_baud_rate (int rx_rate,
- bits *old_rx_rate);
- extern bits osserialop_rx_baud_rate (int rx_rate);
-
- /* ------------------------------------------------------------------------
- * Function: osserialop_tx_baud_rate()
- *
- * Description: Reads/writes the transmit baud rate
- *
- * Input: tx_rate - value of R1 on entry
- *
- * Output: old_tx_rate - value of R1 on exit (X version only)
- *
- * Returns: R1 (non-X version only)
- *
- * Other notes: Calls SWI 0x57 with R0 = 0x6.
- */
-
- extern os_error *xosserialop_tx_baud_rate (int tx_rate,
- bits *old_tx_rate);
- extern bits osserialop_tx_baud_rate (int tx_rate);
-
- /* ------------------------------------------------------------------------
- * Function: osserialop_rx_threshold()
- *
- * Description: Sets the receive threshold
- *
- * Input: rx_threshold - value of R1 on entry
- *
- * Output: old_rx_threshold - value of R1 on exit (X version only)
- *
- * Returns: R1 (non-X version only)
- *
- * Other notes: Calls SWI 0x57 with R0 = 0x8.
- */
-
- extern os_error *xosserialop_rx_threshold (int rx_threshold,
- bits *old_rx_threshold);
- extern bits osserialop_rx_threshold (int rx_threshold);
-
- /* ------------------------------------------------------------------------
- * Function: osserialop_enumerate_baud_rates()
- *
- * Description: Enumerates the available serial port speeds
- *
- * Output: table - value of R1 on exit
- * table_size - value of R2 on exit
- *
- * Other notes: Calls SWI 0x57 with R0 = 0x9.
- */
-
- extern os_error *xosserialop_enumerate_baud_rates (int **table,
- int *table_size);
- extern void osserialop_enumerate_baud_rates (int **table,
- int *table_size);
-
- /* ------------------------------------------------------------------------
- * Function: event_rs423_error()
- *
- * Description: Calls reason code 7 of SWI 0x22
- *
- * Input: status - value of R1 on entry
- * b - value of R2 on entry
- *
- * Other notes: Before entry, R0 = 0x7.
- */
-
- extern os_error *xevent_rs423_error (bits status,
- byte b);
- extern void event_rs423_error (bits status,
- byte b);
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif
-