KallistiOS git master
Independent SDK for the Sega Dreamcast
Loading...
Searching...
No Matches
modem.h
Go to the documentation of this file.
1/* KallistiOS ##version##
2
3 modem.h
4 Copyright (C) 2002, 2004 Nick Kochakian
5
6 Distributed under the terms of the KOS license.
7
8*/
9
10/** \file dc/modem/modem.h
11 \brief Definitions to use the Dreamcast modem.
12 \ingroup modem
13
14 This file contains functions and constants to be used with the Dreamcast
15 modem driver.
16
17 \author Nick Kochakian
18*/
19
20#ifndef __DC_MODEM_MODEM_H
21#define __DC_MODEM_MODEM_H
22
23#include "mconst.h"
24
25/** \defgroup modem Modem
26 \brief Driver for the Dreamcast's built-in 56k Modem
27 \ingroup networking_drivers
28*/
29
30/** \defgroup modem_modes Modes of Operation
31 \brief Operating modes for modem
32 \ingroup modem
33
34 This group defines the modes that the Dreamcast modem can be in at any given
35 point in time.
36
37 @{
38*/
39/** \brief Connect to a remote modem. */
40#define MODEM_MODE_REMOTE 0
41
42/** \brief Answer a call when a ring is detected. */
43#define MODEM_MODE_ANSWER 1
44
45/** \brief Modem not in use. Do not attempt to set this mode yourself! */
46#define MODEM_MODE_NULL 255
47/** @} */
48
49/** \defgroup modem_v22bis V.22bis Modes
50 \brief Modem V.22bis Modes
51 \ingroup modem
52 @{
53*/
54/** \brief 1200bps, V.22bis */
55#define MODEM_SPEED_V22BIS_1200 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V22BIS, MODEM_SPEED_1200)
56
57/** \brief 2400bps, V.22bis */
58#define MODEM_SPEED_V22BIS_2400 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V22BIS, MODEM_SPEED_2400)
59/** @} */
60
61/** \defgroup modem_v22 V.22 Modes
62 \brief Modem V.22 Modes
63 \ingroup modem
64 @{
65*/
66/** \brief 1200bps, V.22 */
67#define MODEM_SPEED_V22_1200 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V22, MODEM_SPEED_1200)
68/** @} */
69
70/** \defgroup modem_v32 V.32 Modes
71 \brief Modem V.32 Modes
72 \ingroup modem
73 @{
74*/
75/** \brief 4800bps, V.32 */
76#define MODEM_SPEED_V32_4800 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V32, MODEM_SPEED_4800)
77
78/** \brief 9600bps, V.32 */
79#define MODEM_SPEED_V32_9600 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V32, MODEM_SPEED_9600)
80/** @} */
81
82/** \defgroup modem_v32bis V.32bis Modes
83 \brief Modem V.32 Modes
84 \ingroup modem
85 @{
86*/
87/** \brief 7200bps, V.32bis */
88#define MODEM_SPEED_V32BIS_7200 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V32BIS, MODEM_SPEED_7200)
89
90/** \brief 12000bps, V.32bis */
91#define MODEM_SPEED_V32BIS_12000 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V32BIS, MODEM_SPEED_12000)
92
93/** \brief 14400bps, V.32bis */
94#define MODEM_SPEED_V32BIS_14400 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V32BIS, MODEM_SPEED_14400)
95/** @} */
96
97/** \defgroup modem_v8 V.8 Modes
98 \brief Modem V.8 Modes
99 \ingroup modem
100 @{
101*/
102/** \brief 2400bps, V.8 */
103#define MODEM_SPEED_V8_2400 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_2400)
104
105/** \brief 4800bps, V.8 */
106#define MODEM_SPEED_V8_4800 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_4800)
107
108/** \brief 7200bps, V.8 */
109#define MODEM_SPEED_V8_7200 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_7200)
110
111/** \brief 9600bps, V.8 */
112#define MODEM_SPEED_V8_9600 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_9600)
113
114/** \brief 12000bps, V.8 */
115#define MODEM_SPEED_V8_12000 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_12000)
116
117/** \brief 14400bps, V.8 */
118#define MODEM_SPEED_V8_14400 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_14400)
119
120/** \brief 16800bps, V.8 */
121#define MODEM_SPEED_V8_16800 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_16800)
122
123/** \brief 19200bps, V.8 */
124#define MODEM_SPEED_V8_19200 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_19200)
125
126/** \brief 21600bps, V.8 */
127#define MODEM_SPEED_V8_21600 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_21600)
128
129/** \brief 24000bps, V.8 */
130#define MODEM_SPEED_V8_24000 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_24000)
131
132/** \brief 26400bps, V.8 */
133#define MODEM_SPEED_V8_26400 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_26400)
134
135/** \brief 28000bps, V.8 */
136#define MODEM_SPEED_V8_28000 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_28000)
137
138/** \brief 31200bps, V.8 */
139#define MODEM_SPEED_V8_31200 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_31200)
140
141/** \brief 33600bps, V.8 */
142#define MODEM_SPEED_V8_33600 MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_33600)
143
144/** \brief Automatically set speed, V.8 */
145#define MODEM_SPEED_V8_AUTO MODEM_MAKE_SPEED(MODEM_PROTOCOL_V8, MODEM_SPEED_1200)
146/** @} */
147
148/** \brief Modem Event Types.
149 \ingroup modem
150
151 These are the events that a modem event handler should be expected to
152 receive at any given point in time.
153*/
154typedef enum {
155 /** \brief The modem tried to establish a connection, but failed.*/
157
158 /** \brief A connection has been established. */
160
161 /** \brief The remote modem dropped the connection. */
163
164 /** \brief New data has entered the previously empty receive buffer. */
166
167 /** \brief The receive buffer overflowed and was cleared. */
169
170 /** \brief The transmit buffer has been emptied. */
173
174/** \brief Type of a modem event handling function.
175 \ingroup modem
176 */
177typedef void (*MODEMEVENTHANDLERPROC)(modemEvent_t event);
178
179/* From modem.c */
180/** \brief Initialize the modem.
181 \ingroup modem
182
183 This function initializes the modem for use.
184
185 \retval 0 On failure.
186 \retval 1 On success.
187*/
188int modem_init(void);
189
190/** \brief Shut down the modem.
191 \ingroup modem
192
193 This function shuts down the modem after it has been initialized, resetting
194 all of the registers to their defaults.
195*/
196void modem_shutdown(void);
197
198/** \brief Set the modem up for the specified mode.
199 \ingroup modem
200
201 This function sets up the modem's registers for the specified mode and speed
202 combination.
203
204 \param mode The mode to use.
205 \param speed The speed to use.
206 \see modem_modes
207 \see modem_v22bis
208 \see modem_v22
209 \see modem_v32
210 \see modem_v32bis
211 \see modem_v8
212*/
213int modem_set_mode(int mode, modem_speed_t speed);
214
215/** \brief Wait for the modem to detect a dialtone.
216 \ingroup modem
217
218 This function waits for a dialtone to be detected on the modem.
219
220 \param ms_timeout The number of milliseconds to wait, in multiples of 100.
221 \retval 0 If a dialtone is detected before timeout.
222 \retval -1 If no dialtone is detected.
223*/
224int modem_wait_dialtone(int ms_timeout);
225
226/** \brief Dial the specified number on the modem.
227 \ingroup modem
228
229 \param digits The number to dial, as a string.
230 \retval 0 On failure.
231 \retval 1 On success.
232*/
233int modem_dial(const char *digits);
234
235/** \brief Set the event handler for the modem.
236 \ingroup modem
237
238 This function sets up an event handler for when things happen on the modem.
239
240 \param eventHandler The function to call when an event occurs.
241*/
243
244/** \brief Disconnect the modem.
245 \ingroup modem
246
247 This function instructs the modem to disconnect from the remote modem.
248*/
250
251/** \brief Check if the modem is connecting.
252 \ingroup modem
253
254 \return 0 if the modem is not currently connecting, non-zero
255 otherwise.
256*/
258
259/** \brief Check if the modem is connected.
260 \ingroup modem
261
262 \return 0 if the modem is not currently connected, non-zero
263 otherwise.
264*/
266
267/** \brief Get the connection rate that the modem is connected at.
268 \ingroup modem
269
270 \return The connection rate in bits per second.
271*/
272unsigned long modem_get_connection_rate(void);
273
274/* From mdata.c */
275/** \brief Read data from the modem buffers.
276 \ingroup modem
277
278 \param data The buffer to read into.
279 \param size The maximum number of bytes to read.
280 \return The actual number of bytes read.
281*/
282int modem_read_data(unsigned char *data, int size);
283
284/** \brief Write data to the modem buffers.
285 \ingroup modem
286
287 \param data The buffer to write from.
288 \param size The maximum number of bytes to write.
289 \return The actual number of bytes written.
290*/
291int modem_write_data(unsigned char *data, int size);
292
293/** \brief Check if the modem has data waiting to be read.
294 \ingroup modem
295
296 \return 0 if no data available, non-zero otherwise.
297*/
299
300#endif
int modem_set_mode(int mode, modem_speed_t speed)
Set the modem up for the specified mode.
void(* MODEMEVENTHANDLERPROC)(modemEvent_t event)
Type of a modem event handling function.
Definition modem.h:177
void modem_shutdown(void)
Shut down the modem.
int modem_init(void)
Initialize the modem.
unsigned char modem_speed_t
Modem speed/protocol value type.
Definition mconst.h:123
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_is_connected(void)
Check if the modem is connected.
void modem_set_event_handler(MODEMEVENTHANDLERPROC eventHandler)
Set the event handler for the modem.
int modem_has_data(void)
Check if the modem has data waiting to be read.
unsigned long modem_get_connection_rate(void)
Get the connection rate that the modem is connected at.
int modem_dial(const char *digits)
Dial the specified number on the modem.
void modem_disconnect(void)
Disconnect the modem.
int modem_is_connecting(void)
Check if the modem is connecting.
int modem_wait_dialtone(int ms_timeout)
Wait for the modem to detect a dialtone.
modemEvent_t
Modem Event Types.
Definition modem.h:154
@ MODEM_EVENT_DISCONNECTED
The remote modem dropped the connection.
Definition modem.h:162
@ MODEM_EVENT_CONNECTION_FAILED
The modem tried to establish a connection, but failed.
Definition modem.h:156
@ MODEM_EVENT_RX_NOT_EMPTY
New data has entered the previously empty receive buffer.
Definition modem.h:165
@ MODEM_EVENT_OVERFLOW
The receive buffer overflowed and was cleared.
Definition modem.h:168
@ MODEM_EVENT_TX_EMPTY
The transmit buffer has been emptied.
Definition modem.h:171
@ MODEM_EVENT_CONNECTED
A connection has been established.
Definition modem.h:159
Constants used in the modem driver.