Search
lxdream.org :: lxdream/src/serial.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/serial.h
changeset 1081:ef31ae97bb8b
prev1077:136fc24d17ef
author nkeynes
date Fri Dec 23 08:20:17 2011 +1000 (12 years ago)
permissions -rw-r--r--
last change Move the exception exit macros up to sh4core.h
view annotate diff log raw
     1 /**
     2  * $Id$
     3  * External interface to the dreamcast serial port, implemented by 
     4  * sh4/scif.c
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     8  * This program is free software; you can redistribute it and/or modify
     9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 2 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16  * GNU General Public License for more details.
    17  */
    18 #ifndef lxdream_serial_H
    19 #define lxdream_serial_H 1
    21 #include <stdint.h>
    23 #include "lxdream.h"
    25 #ifdef __cplusplus
    26 extern "C" {
    27 #endif
    29 #define SERIAL_8BIT        0x00
    30 #define SERIAL_7BIT        0x40
    31 #define SERIAL_PARITY_OFF  0x00
    32 #define SERIAL_PARITY_EVEN 0x20
    33 #define SERIAL_PARITY_ODD  0x30
    34 #define SERIAL_1STOPBIT    0x00
    35 #define SERIAL_2STOPBITS   0x08
    37 typedef struct serial_device {
    38     void (*attach)(struct serial_device *dev);
    39     void (*detach)(struct serial_device *dev);
    40     void (*destroy)(struct serial_device *dev);
    41     void (*set_line_speed)(struct serial_device *dev, uint32_t bps);
    42     void (*set_line_params)(struct serial_device *dev, int flags);
    43     void (*receive_data)(struct serial_device *dev, uint8_t value);
    44 } *serial_device_t;
    46 serial_device_t serial_attach_device( serial_device_t dev );
    47 serial_device_t serial_detach_device( );
    48 serial_device_t serial_get_device( );
    50 void serial_init();
    52 /**
    53  * Destroy a serial device.
    54  */
    55 void serial_destroy_device( serial_device_t dev );
    58 void serial_transmit_data( char *data, int length );
    59 void serial_transmit_break( void );
    61 /**
    62  * Create a serial device on a host device identified by the given
    63  * file (ie /dev/tty). If filename identifies a regular file, it is opened
    64  * for output only.
    65  */
    66 serial_device_t serial_fd_device_new_filename( const gchar *filename );
    68 /**
    69  * Create a serial device on the host console (stdin/stdout).
    70  */
    71 serial_device_t serial_fd_device_new_console();
    73 /**
    74  * Create a serial device on a pair of file streams (in and out)
    75  */
    76 serial_device_t serial_fd_device_new_file( FILE *in, FILE *out, gboolean closeOnDestroy );
    78 #ifdef __cplusplus
    79 }
    80 #endif
    82 #endif /* !lxdream_serial_H */
.