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 __sys_lnp_h__
27
#define __sys_lnp_h__
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
33
#include "../lnp.h"
34
35
#ifdef CONF_LNP
36
38
//
39
// Definitions
40
//
42
43
#define LNP_HOSTMASK CONF_LNP_HOSTMASK
44
45
46
#define LNP_PORTMASK (0x00ff & ~CONF_LNP_HOSTMASK)
47
48
#if defined(CONF_RCX_PROTOCOL) || defined(CONF_RCX_MESSAGE)
49
50
#define LNP_RCX_HEADER_LENGTH (3-1)
51
53
#define LNP_RCX_REMOTE_OP_LENGTH (5-3)
54
56
#define LNP_RCX_MSG_OP_LENGTH (5-3)
57
#endif
58
60
typedef
enum
{
61
LNPwaitHeader
,
62
LNPwaitLength
,
63
LNPwaitData
,
64
LNPwaitCRC
,
65
66
#if defined(CONF_RCX_PROTOCOL) || defined(CONF_RCX_MESSAGE)
67
68
LNPwaitRMH1
,
// note that first byte is consumed by LNPwaitHeader
69
LNPwaitRMH2
,
// inverted header
70
LNPwaitRMH3
,
// actually, RCX opcode dispatch
71
LNPwaitRMH4
,
// remote opcode inverted
72
#endif
73
74
75
#ifdef CONF_RCX_PROTOCOL
76
77
LNPwaitRB0
,
// high-byte
78
LNPwaitRB0I
,
79
LNPwaitRB1
,
// low-byte
80
LNPwaitRB1I
,
81
LNPwaitRC
,
// RCX checksum
82
LNPwaitRCI
,
83
#endif
84
85
#ifdef CONF_RCX_MESSAGE
86
87
LNPwaitMH3
,
// RCX message OP
88
LNPwaitMH4
,
89
LNPwaitMN
,
// message number
90
LNPwaitMNC
,
91
LNPwaitMC
,
// RCX checksum
92
LNPwaitMCC
,
93
#endif
94
}
lnp_integrity_state_t
;
95
96
98
//
99
// Variables
100
//
102
104
extern
volatile
unsigned
short
lnp_timeout_counter
;
105
107
extern
unsigned
short
lnp_timeout
;
108
110
extern
lnp_integrity_state_t
lnp_integrity_state
;
111
112
114
//
115
// Functions
116
//
118
120
extern
unsigned
char
lnp_checksum_copy
(
unsigned
char
*dest,
121
const
unsigned
char
*data,
122
unsigned
length );
123
126
128
extern
void
lnp_integrity_byte
(
unsigned
char
b);
129
131
extern
void
lnp_integrity_reset
(
void
)
132
#ifdef CONF_RCX_COMPILER
133
__attribute__ ((rcx_interrupt))
134
#endif
135
;
136
138
140
extern
inline
int
lnp_integrity_active
(
void
) {
141
return
lnp_integrity_state!=
LNPwaitHeader
;
142
}
143
145
extern
void
lnp_timeout_reset
(
void
)
146
#ifdef CONF_RCX_COMPILER
147
__attribute__ ((rcx_interrupt))
148
#endif
149
;
150
153
155
extern
inline
void
lnp_timeout_set
(
unsigned
short
timeout) {
156
lnp_timeout_counter=lnp_timeout=timeout;
157
}
158
160
163
extern
void
lnp_init
(
void
);
164
165
#endif // CONF_LNP
166
167
#ifdef __cplusplus
168
}
169
#endif
170
171
#endif // __sys_lnp_h__
172
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