Main Page
Related Pages
Modules
Classes
Files
File List
File Members
lnp.h
Go to the documentation of this file.
1
6
/*
7
* The contents of this file are subject to the Mozilla Public License
8
* Version 1.0 (the "License"); you may not use this file except in
9
* compliance with the License. You may obtain a copy of the License
10
* at http://www.mozilla.org/MPL/
11
*
12
* Software distributed under the License is distributed on an "AS IS"
13
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
* the License for the specific language governing rights and
15
* limitations under the License.
16
*
17
* The Original Code is legOS code, released October 17, 1999.
18
*
19
* The Initial Developer of the Original Code is Markus L. Noga.
20
* Portions created by Markus L. Noga are Copyright (C) 1999
21
* Markus L. Noga. All Rights Reserved.
22
*
23
* Contributor(s): Markus L. Noga <markus@noga.de>
24
*/
25
26
#ifndef __lnp_h__
27
#define __lnp_h__
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
33
#include <
config.h
>
34
35
#ifdef CONF_LNP
36
37
#ifdef CONF_RCX_MESSAGE
38
#include <
unistd.h
>
39
#endif
40
42
//
43
// Definitions
44
//
46
48
50
typedef
void (*
lnp_integrity_handler_t
) (
const
unsigned
char
*,
unsigned
char);
51
53
55
typedef
void (*
lnp_addressing_handler_t
) (
const
unsigned
char
*,
unsigned
char,
unsigned
char);
56
58
#define LNP_DUMMY_INTEGRITY ((lnp_integrity_handler_t)0)
59
61
#define LNP_DUMMY_ADDRESSING ((lnp_addressing_handler_t)0)
62
63
#ifdef CONF_RCX_PROTOCOL
64
65
67
typedef
void (*
lnp_remote_handler_t
) (
unsigned
int);
68
70
#define LNP_DUMMY_REMOTE ((lnp_remote_handler_t)0)
71
#endif
72
74
//
75
// Variables
76
//
78
80
// one handler.
81
extern
volatile
lnp_integrity_handler_t
lnp_integrity_handler
;
82
84
extern
volatile
lnp_addressing_handler_t
lnp_addressing_handler
[];
85
87
extern
unsigned
char
lnp_hostaddr
;
88
89
#ifdef CONF_RCX_PROTOCOL
90
91
extern
lnp_remote_handler_t
lnp_remote_handler
;
92
#endif
93
95
//
96
// Functions
97
//
99
101
extern
inline
void
lnp_integrity_set_handler
(
lnp_integrity_handler_t
handler)
102
{
103
lnp_integrity_handler = handler;
104
}
105
107
extern
inline
void
lnp_addressing_set_handler
(
unsigned
char
port,
lnp_addressing_handler_t
handler)
108
{
109
if
(!(port &
CONF_LNP_HOSTMASK
))
// sanity check.
110
111
lnp_addressing_handler[port] = handler;
112
}
113
115
extern
inline
void
lnp_set_hostaddr
(
unsigned
char
host)
116
{
117
lnp_hostaddr = ((host << 4) &
CONF_LNP_HOSTMASK
);
118
}
119
120
#ifdef CONF_RCX_PROTOCOL
121
122
extern
inline
void
lnp_remote_set_handler
(
lnp_remote_handler_t
handler)
123
{
124
lnp_remote_handler = handler;
125
}
126
#endif
127
128
#ifdef CONF_RCX_MESSAGE
129
130
extern
unsigned
char
lnp_rcx_message
;
131
133
extern
int
send_msg
(
unsigned
char
msg);
134
136
extern
inline
void
clear_msg
(
void
)
137
{
138
lnp_rcx_message = 0;
139
}
140
142
wakeup_t
msg_received
(
wakeup_t
m);
143
145
extern
inline
unsigned
char
get_msg
(
void
)
146
{
147
clear_msg
();
148
if
(
wait_event
(
msg_received
, 0) == 0)
149
return
0;
150
return
lnp_rcx_message;
151
}
152
153
#endif
154
156
158
extern
int
lnp_integrity_write
(
const
unsigned
char
*data,
unsigned
char
length);
159
161
163
extern
int
lnp_addressing_write
(
const
unsigned
char
*data,
unsigned
char
length,
164
unsigned
char
dest,
unsigned
char
srcport);
165
166
#endif // CONF_LNP
167
168
#ifdef __cplusplus
169
}
170
#endif
171
172
#endif // _lnp_h__
brickOS
is released under the
Mozilla Public License
.
Original code copyright 1998-2005 by the authors.
Generated on Sat Mar 15 2014 11:28:21 for brickOS Kernel Developer by
1.8.1.2