KallistiOS  2.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Macros | Typedefs | Enumerations | Functions
modem.h File Reference

Definitions to use the Dreamcast modem. More...

#include "mconst.h"

Go to the source code of this file.

Macros

#define MODEM_MODE_REMOTE   0
 Connect to a remote modem.
#define MODEM_MODE_ANSWER   1
 Answer a call when a ring is detected.
#define MODEM_MODE_NULL   255
 Modem not in use. Do not attempt to set this mode yourself!
#define MODEM_SPEED_V22BIS_1200   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V22BIS, MODEM_SPEED_1200)
 1200bps, V.22bis
#define MODEM_SPEED_V22BIS_2400   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V22BIS, MODEM_SPEED_2400)
 2400bps, V.22bis
#define MODEM_SPEED_V22_1200   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V22, MODEM_SPEED_1200)
 1200bps, V.22
#define MODEM_SPEED_V32_4800   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V32, MODEM_SPEED_4800)
 4800bps, V.32
#define MODEM_SPEED_V32_9600   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V32, MODEM_SPEED_9600)
 9600bps, V.32
#define MODEM_SPEED_V32BIS_7200   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V32BIS, MODEM_SPEED_7200)
 7200bps, V.32bis
#define MODEM_SPEED_V32BIS_12000   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V32BIS, MODEM_SPEED_12000)
 12000bps, V.32bis
#define MODEM_SPEED_V32BIS_14400   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V32BIS, MODEM_SPEED_14400)
 14400bps, V.32bis
#define MODEM_SPEED_V8_2400   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_2400)
 2400bps, V.8
#define MODEM_SPEED_V8_4800   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_4800)
 4800bps, V.8
#define MODEM_SPEED_V8_7200   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_7200)
 7200bps, V.8
#define MODEM_SPEED_V8_9600   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_9600)
 9600bps, V.8
#define MODEM_SPEED_V8_12000   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_12000)
 12000bps, V.8
#define MODEM_SPEED_V8_14400   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_14400)
 14400bps, V.8
#define MODEM_SPEED_V8_16800   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_16800)
 16800bps, V.8
#define MODEM_SPEED_V8_19200   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_19200)
 19200bps, V.8
#define MODEM_SPEED_V8_21600   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_21600)
 21600bps, V.8
#define MODEM_SPEED_V8_24000   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_24000)
 24000bps, V.8
#define MODEM_SPEED_V8_26400   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_26400)
 26400bps, V.8
#define MODEM_SPEED_V8_28000   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_28000)
 28000bps, V.8
#define MODEM_SPEED_V8_31200   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_31200)
 31200bps, V.8
#define MODEM_SPEED_V8_33600   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_33600)
 33600bps, V.8
#define MODEM_SPEED_V8_AUTO   MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_1200)
 Automatically set speed, V.8.

Typedefs

typedef void(* MODEMEVENTHANDLERPROC )(modemEvent_t event)
 Type of a modem event handling function.

Enumerations

enum  modemEvent_t {
  MODEM_EVENT_CONNECTION_FAILED = 0, MODEM_EVENT_CONNECTED, MODEM_EVENT_DISCONNECTED, MODEM_EVENT_RX_NOT_EMPTY,
  MODEM_EVENT_OVERFLOW, MODEM_EVENT_TX_EMPTY
}
 Modem event types. More...

Functions

int modem_init (void)
 Initialize the modem.
void modem_shutdown (void)
 Shut down the modem.
int modem_set_mode (int mode, modem_speed_t speed)
 Set the modem up for the specified mode.
int modem_wait_dialtone (int ms_timeout)
 Wait for the modem to detect a dialtone.
int modem_dial (const char *digits)
 Dial the specified number on the modem.
void modem_set_event_handler (MODEMEVENTHANDLERPROC eventHandler)
 Set the event handler for the modem.
void modem_disconnect (void)
 Disconnect the modem.
int modem_is_connecting (void)
 Check if the modem is connecting.
int modem_is_connected (void)
 Check if the modem is connected.
unsigned long modem_get_connection_rate (void)
 Get the connection rate that the modem is connected at.
int modem_read_data (unsigned char *data, int size)
 Read data from the modem buffers.
int modem_write_data (unsigned char *data, int size)
 Write data to the modem buffers.
int modem_has_data (void)
 Check if the modem has data waiting to be read.

Detailed Description

Definitions to use the Dreamcast modem.

This file contains functions and constants to be used with the Dreamcast modem driver.

Author:
Nick Kochakian

Typedef Documentation

typedef void(* MODEMEVENTHANDLERPROC)(modemEvent_t event)

Type of a modem event handling function.


Enumeration Type Documentation

Modem event types.

These are teh events that a modem event handler should be expected to receive at any given point in time.

Enumerator:
MODEM_EVENT_CONNECTION_FAILED 

The modem tried to establish a connection, but failed.

MODEM_EVENT_CONNECTED 

A connection has been established.

MODEM_EVENT_DISCONNECTED 

The remote modem dropped the connection.

MODEM_EVENT_RX_NOT_EMPTY 

New data has entered the previously empty receive buffer.

MODEM_EVENT_OVERFLOW 

The receive buffer overflowed and was cleared.

MODEM_EVENT_TX_EMPTY 

The transmit buffer has been emptied.


Function Documentation

int modem_dial ( const char *  digits)

Dial the specified number on the modem.

Parameters:
digitsThe number to dial, as a string.
Return values:
0On failure.
1On success.
void modem_disconnect ( void  )

Disconnect the modem.

This function instructs the modem to disconnect from the remote modem.

unsigned long modem_get_connection_rate ( void  )

Get the connection rate that the modem is connected at.

Returns:
The connection rate in bits per second.
int modem_has_data ( void  )

Check if the modem has data waiting to be read.

Returns:
0 if no data available, non-zero otherwise.
int modem_init ( void  )

Initialize the modem.

This function initializes the modem for use.

Return values:
0On failure.
1On success.
int modem_is_connected ( void  )

Check if the modem is connected.

Returns:
0 if the modem is not currently connected, non-zero otherwise.
int modem_is_connecting ( void  )

Check if the modem is connecting.

Returns:
0 if the modem is not currently connecting, non-zero otherwise.
int modem_read_data ( unsigned char *  data,
int  size 
)

Read data from the modem buffers.

Parameters:
dataThe buffer to read into.
sizeThe maximum number of bytes to read.
Returns:
The actual number of bytes read.
void modem_set_event_handler ( MODEMEVENTHANDLERPROC  eventHandler)

Set the event handler for the modem.

This function sets up an event handler for when things happen on the modem.

Parameters:
eventHandlerThe function to call when an event occurs.
int modem_set_mode ( int  mode,
modem_speed_t  speed 
)

Set the modem up for the specified mode.

This function sets up the modem's registers for the specified mode and speed combination.

Parameters:
modeThe mode to use.
speedThe speed to use.
See also:
Modes of operation of the Dreamcast modem.
Modem V.22bis modes
Modem V.22 modes
Modem V.32 modes
Modem V.32 bis modes
Modem V.8 modes
void modem_shutdown ( void  )

Shut down the modem.

This function shuts down the modem after it has been initialized, resetting all of the registers to their defaults.

int modem_wait_dialtone ( int  ms_timeout)

Wait for the modem to detect a dialtone.

This function waits for a dialtone to be detected on the modem.

Parameters:
ms_timeoutThe number of milliseconds to wait, in multiples of 100.
Return values:
0If a dialtone is detected before timeout.
-1If no dialtone is detected.
int modem_write_data ( unsigned char *  data,
int  size 
)

Write data to the modem buffers.

Parameters:
dataThe buffer to write from.
sizeThe maximum number of bytes to write.
Returns:
The actual number of bytes written.