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