KallistiOS
2.0.0
Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
kernel
arch
dreamcast
include
dc
scif.h
Go to the documentation of this file.
1
/* KallistiOS 2.0.0
2
3
dc/scif.h
4
Copyright (C) 2000,2001,2004 Dan Potter
5
Copyright (C) 2012 Lawrence Sebald
6
7
*/
8
9
/** \file dc/scif.h
10
\brief Serial port functionality.
11
12
This file deals with raw access to the serial port on the Dreamcast.
13
14
\author Dan Potter
15
\author Lawrence Sebald
16
*/
17
18
#ifndef __DC_SCIF_H
19
#define __DC_SCIF_H
20
21
#include <sys/cdefs.h>
22
__BEGIN_DECLS
23
24
#include <
arch/types.h
>
25
#include <
kos/dbgio.h
>
26
27
/** \brief Set serial parameters.
28
\param baud The bitrate to set.
29
\param fifo 1 to enable FIFO mode.
30
*/
31
void
scif_set_parameters
(
int
baud,
int
fifo);
32
33
// The rest of these are the standard dbgio interface.
34
35
/** \brief Enable or disable SCIF IRQ usage.
36
\param on 1 to enable IRQ usage, 0 for polled I/O.
37
\retval 0 On success (no error conditions defined).
38
*/
39
int
scif_set_irq_usage
(
int
on);
40
41
/** \brief Is the SCIF port detected? Of course it is!
42
\return 1
43
*/
44
int
scif_detected
();
45
46
/** \brief Initialize the SCIF port.
47
48
This function initializes the SCIF port to a sane state. If dcload-serial is
49
in use, this is effectively a no-op.
50
51
\retval 0 On success (no error conditions defined).
52
*/
53
int
scif_init
();
54
55
/** \brief Shutdown the SCIF port.
56
57
This function disables SCIF IRQs, if they were enabled and cleans up.
58
59
\retval 0 On success (no error conditions defined).
60
*/
61
int
scif_shutdown
();
62
63
/** \brief Read a single character from the SCIF port.
64
\return The character read if one is available, otherwise -1
65
and errno is set to EAGAIN.
66
*/
67
int
scif_read
();
68
69
/** \brief Write a single character to the SCIF port.
70
\param c The character to write (only the low 8-bits are
71
written).
72
\retval 1 On success.
73
\retval -1 If the SCIF port is disabled (errno set to EIO).
74
*/
75
int
scif_write
(
int
c);
76
77
/** \brief Flush any FIFO'd bytes out of the buffer.
78
79
This function sends any bytes that have been queued up for transmission but
80
have not left yet in FIFO mode.
81
82
\retval 0 On success.
83
\retval -1 If the SCIF port is disabled (errno set to EIO).
84
*/
85
int
scif_flush
();
86
87
/** \brief Write a whole buffer of data to the SCIF port.
88
89
This function writes a whole buffer of data to the SCIF port, optionally
90
making all newlines into carriage return + newline pairs.
91
92
\param data The buffer to write.
93
\param len The length of the buffer, in bytes.
94
\param xlat If set to 1, all newlines will be written as CRLF.
95
\return The number of bytes written on success, -1 on error.
96
*/
97
int
scif_write_buffer
(
const
uint8
*data,
int
len,
int
xlat);
98
99
/** \brief Read a buffer of data from the SCIF port.
100
101
This function reads a whole buffer of data from the SCIF port, blocking
102
until it has been filled.
103
104
\param data The buffer to read into.
105
\param len The number of bytes to read.
106
\return The number of bytes read on success, -1 on error.
107
*/
108
int
scif_read_buffer
(
uint8
*data,
int
len);
109
110
/** \brief SCIF debug I/O handler. Do not modify! */
111
extern
dbgio_handler_t
dbgio_scif
;
112
113
/* Low-level SPI related functionality below here... */
114
/** \brief Initialize the SCIF port for use of an SPI peripheral.
115
116
This function initializes the SCIF port for accessing the an SPI peripheral
117
that has been connected to the serial port. The design of the SCIF->SPI
118
wiring follows the wiring of the SD card adapter which is (at least now)
119
somewhat commonly available online and is the same as the one designed by
120
jj1odm.
121
122
\retval 0 On success.
123
\retval -1 On error (if dcload-serial is detected).
124
*/
125
int
scif_spi_init
(
void
);
126
127
/** \brief Shut down SPI card support over the SCIF port.
128
129
This function shuts down SPI support on the SCIF port. If you want to get
130
regular usage of the port back, you must call scif_init() after shutting
131
down SPI support.
132
133
\retval 0 On success (no errors defined).
134
*/
135
int
scif_spi_shutdown
(
void
);
136
137
/** \brief Set or clear the SPI /CS line.
138
139
This function sets or clears the /CS line (connected to the RTS line of the
140
SCIF port).
141
142
\param v Non-zero to output 1 on the line, zero to output 0.
143
*/
144
void
scif_spi_set_cs
(
int
v);
145
146
/** \brief Read and write one byte from the SPI port.
147
148
This function writes one byte and reads one back from the SPI device
149
simultaneously.
150
151
\param b The byte to write out to the port.
152
\return The byte returned from the card.
153
*/
154
uint8
scif_spi_rw_byte
(
uint8
b);
155
156
/** \brief Read and write one byte from the SPI device, slowly.
157
158
This function does the same thing as the scif_sd_rw_byte() function, but
159
with a 1.5usec delay between asserting the CLK line and reading back the bit
160
and a 1.5usec delay between clearing the CLK line and writing the next bit
161
out.
162
163
This ends up working out to a clock of about 333khz, or so.
164
165
\param b The byte to write out to the port.
166
\return The byte returned from the card.
167
*/
168
uint8
scif_spi_slow_rw_byte
(
uint8
b);
169
170
171
/** \brief Write a byte to the SPI device.
172
173
This function writes out the specified byte to the SPI device, one bit at a
174
time. The timing follows that of the scif_spi_rw_byte() function.
175
176
\param b The byte to write out to the port.
177
*/
178
void
scif_spi_write_byte
(
uint8
b);
179
180
/** \brief Read a byte from the SPI device.
181
182
This function reads a byte from the SPI device, one bit at a time. The
183
timing follows that of the scif_spi_rw_byte() function.
184
185
\return The byte returned from the card.
186
*/
187
uint8
scif_spi_read_byte
(
void
);
188
189
__END_DECLS
190
191
#endif
/* __DC_SCIF_H */
192
Generated by
1.8.1.1