Search
lxdream.org :: lxdream/src/serial.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/serial.h
changeset 1077:136fc24d17ef
prev736:a02d1475ccfd
next1081:ef31ae97bb8b
author nkeynes
date Wed Oct 07 17:53:56 2009 +1000 (12 years ago)
permissions -rw-r--r--
last change Create a host attachment for the SCIF serial port. By default, uses /dev/console
Add general fd listening to netutil, and rename to ioutil
Add SCIF update on port read/write - fixes KOS timing problems but needs to
be redone properly.
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@1077
    50
/**
nkeynes@1077
    51
 * Destroy a serial device.
nkeynes@1077
    52
 */
nkeynes@1077
    53
void serial_destroy_device( serial_device_t dev );
nkeynes@1077
    54
nkeynes@19
    55
nkeynes@19
    56
void serial_transmit_data( char *data, int length );
nkeynes@19
    57
void serial_transmit_break( void );
nkeynes@19
    58
nkeynes@1077
    59
/**
nkeynes@1077
    60
 * Create a serial device on a host device identified by the given
nkeynes@1077
    61
 * file (ie /dev/tty). If filename identifies a regular file, it is opened
nkeynes@1077
    62
 * for output only.
nkeynes@1077
    63
 */
nkeynes@1077
    64
serial_device_t serial_fd_device_new_filename( const gchar *filename );
nkeynes@1077
    65
nkeynes@1077
    66
/**
nkeynes@1077
    67
 * Create a serial device on the host console (stdin/stdout).
nkeynes@1077
    68
 */
nkeynes@1077
    69
serial_device_t serial_fd_device_new_console();
nkeynes@1077
    70
nkeynes@1077
    71
/**
nkeynes@1077
    72
 * Create a serial device on a pair of file streams (in and out)
nkeynes@1077
    73
 */
nkeynes@1077
    74
serial_device_t serial_fd_device_new_file( FILE *in, FILE *out, gboolean closeOnDestroy );
nkeynes@1077
    75
nkeynes@19
    76
#ifdef __cplusplus
nkeynes@19
    77
}
nkeynes@19
    78
#endif
nkeynes@19
    79
nkeynes@736
    80
#endif /* !lxdream_serial_H */
.