blob: dca80edbabd8b9f974a379f4214b36a25ca74b73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
/**
** @file sio.h
**
** @author Warren R. Carithers
**
** @brief SIO definitions
*/
#ifndef SIO_H_
#define SIO_H_
// compatibility definitions
#include <compat.h>
/*
** General (C and/or assembly) definitions
*/
// sio interrupt settings
#define SIO_TX 0x01
#define SIO_RX 0x02
#define SIO_BOTH (SIO_TX | SIO_RX)
#ifndef ASM_SRC
/*
** Start of C-only definitions
*/
#include <common.h>
#include <procs.h>
/*
** PUBLIC GLOBAL VARIABLES
*/
// queue for read-blocked processes
extern QTYPE QNAME;
/*
** PUBLIC FUNCTIONS
*/
/**
** sio_init()
**
** Initialize the UART chip.
*/
void sio_init( void );
/**
** sio_enable()
**
** Enable SIO interrupts
**
** usage: uint8_t old = sio_enable( uint8_t which )
**
** @param which Bit mask indicating which interrupt(s) to enable
**
** @return the prior IER setting
*/
uint8_t sio_enable( uint8_t which );
/**
** sio_disable()
**
** Disable SIO interrupts
**
** usage: uint8_t old = sio_disable( uint8_t which )
**
** @param which Bit mask indicating which interrupt(s) to disable
**
** @return the prior IER setting
*/
uint8_t sio_disable( uint8_t which );
/**
** sio_inq_length()
**
** Get the input queue length
**
** usage: int num = sio_inq_length()
**
** @return the count of characters still in the input queue
*/
int sio_inq_length( void );
/**
** sio_readc()
**
** Get the next input character
**
** usage: int ch = sio_readc()
**
** @return the next character, or -1 if no character is available
*/
int sio_readc( void );
/**
** sio_read()
**
** Read the entire input buffer into a user buffer of a specified size
**
** usage: int num = sio_read( char *buffer, int length )
**
** @param buf The destination buffer
** @param length Length of the buffer
**
** @return the number of bytes copied, or 0 if no characters were available
*/
int sio_read( char *buffer, int length );
/**
** sio_writec( ch )
**
** Write a character to the serial output
**
** usage: sio_writec( int ch )
**
** @param ch Character to be written (in the low-order 8 bits)
*/
void sio_writec( int ch );
/**
** sio_write( ch )
**
** Write a buffer of characters to the serial output
**
** usage: int num = sio_write( const char *buffer, int length )
**
** @param buffer Buffer containing characters to write
** @param length Number of characters to write
**
** @return the number of characters copied into the SIO output buffer
*/
int sio_write( const char *buffer, int length );
/**
** sio_puts( buf )
**
** Write a NUL-terminated buffer of characters to the serial output
**
** usage: n = sio_puts( const char *buffer );
**
** @param buffer The buffer containing a NUL-terminated string
**
** @return the count of bytes transferred
*/
int sio_puts( const char *buffer );
/**
** sio_dump( full )
**
** Dump the contents of the SIO buffers to the console
**
** usage: sio_dump(true) or sio_dump(false)
**
** @param full Boolean indicating whether or not a "full" dump
** is being requested (which includes the contents
** of the queues)
*/
void sio_dump( bool_t full );
#endif /* !ASM_SRC */
#endif
|