3 * External interface to the dreamcast serial port, implemented by
6 * Copyright (c) 2005 Nathan Keynes.
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.
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.
18 #ifndef lxdream_serial_H
19 #define lxdream_serial_H 1
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);
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( );
53 * Destroy a serial device.
55 void serial_destroy_device( serial_device_t dev );
58 void serial_transmit_data( char *data, int length );
59 void serial_transmit_break( void );
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
66 serial_device_t serial_fd_device_new_filename( const gchar *filename );
69 * Create a serial device on the host console (stdin/stdout).
71 serial_device_t serial_fd_device_new_console();
74 * Create a serial device on a pair of file streams (in and out)
76 serial_device_t serial_fd_device_new_file( FILE *in, FILE *out, gboolean closeOnDestroy );
82 #endif /* !lxdream_serial_H */
.