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