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
30extern "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
46#define LNP_PORTMASK (0x00ff & ~CONF_LNP_HOSTMASK)
47
48#if defined(CONF_RCX_PROTOCOL) || defined(CONF_RCX_MESSAGE)
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
60typedef enum {
65
66#if defined(CONF_RCX_PROTOCOL) || defined(CONF_RCX_MESSAGE)
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
77 LNPwaitRB0, // high-byte
79 LNPwaitRB1, // low-byte
81 LNPwaitRC, // RCX checksum
83#endif
84
85#ifdef CONF_RCX_MESSAGE
87 LNPwaitMH3, // RCX message OP
89 LNPwaitMN, // message number
91 LNPwaitMC, // RCX checksum
93#endif
95
96
98//
99// Variables
100//
102
104extern volatile unsigned short lnp_timeout_counter;
105
107extern unsigned short lnp_timeout;
108
111
112
114//
115// Functions
116//
118
120extern unsigned char lnp_checksum_copy( unsigned char *dest,
121 const unsigned char *data,
122 unsigned length );
123
126
128extern void lnp_integrity_byte(unsigned char b);
129
131extern void lnp_integrity_reset(void)
132#ifdef CONF_RCX_COMPILER
133__attribute__ ((rcx_interrupt))
134#endif
135;
136
138
140extern inline int lnp_integrity_active(void) {
142}
143
145extern void lnp_timeout_reset(void)
146#ifdef CONF_RCX_COMPILER
147__attribute__ ((rcx_interrupt))
148#endif
149;
150
153
155extern inline void lnp_timeout_set(unsigned short timeout) {
157}
158
160
163extern void lnp_init(void);
164
165#endif // CONF_LNP
166
167#ifdef __cplusplus
168}
169#endif
170
171#endif // __sys_lnp_h__
172
void lnp_integrity_byte(unsigned char b)
receive a byte from the physical layer, decoding integrity layer packets.
void lnp_integrity_reset(void)
reset the integrity layer on error or timeout.
lnp_integrity_state_t
states for the integrity layer state machine
Definition: lnp.h:60
@ LNPwaitMH4
Definition: lnp.h:88
@ LNPwaitRC
Definition: lnp.h:81
@ LNPwaitRMH2
Definition: lnp.h:69
@ LNPwaitRB0I
Definition: lnp.h:78
@ LNPwaitRB0
states when waiting for remote buttons args
Definition: lnp.h:77
@ LNPwaitLength
Definition: lnp.h:62
@ LNPwaitHeader
Definition: lnp.h:61
@ LNPwaitRMH4
Definition: lnp.h:71
@ LNPwaitRB1
Definition: lnp.h:79
@ LNPwaitData
Definition: lnp.h:63
@ LNPwaitMH3
states when waiting for rcx message opcode
Definition: lnp.h:87
@ LNPwaitRCI
Definition: lnp.h:82
@ LNPwaitMN
Definition: lnp.h:89
@ LNPwaitMCC
Definition: lnp.h:92
@ LNPwaitMC
Definition: lnp.h:91
@ LNPwaitMNC
Definition: lnp.h:90
@ LNPwaitCRC
Definition: lnp.h:64
@ LNPwaitRB1I
Definition: lnp.h:80
@ LNPwaitRMH3
Definition: lnp.h:70
@ LNPwaitRMH1
states when waiting for rcx protocol message
Definition: lnp.h:68
lnp_integrity_state_t lnp_integrity_state
the integrity layer state
unsigned short lnp_timeout
the timeout length in ms
void lnp_timeout_reset(void)
reset the inter-byte timeout counter.
volatile unsigned short lnp_timeout_counter
the timeout counter in ms
unsigned char lnp_checksum_copy(unsigned char *dest, const unsigned char *data, unsigned length)
the LNP ‘copy and compute checksum’ function.
void lnp_timeout_set(unsigned short timeout)
set the inter-byte timeout and reset the timeout counter to that value.
Definition: lnp.h:155
void lnp_init(void)
Initialise protocol handlers.
int lnp_integrity_active(void)
return whether a packet is currently being received
Definition: lnp.h:140

brickOS is released under the Mozilla Public License.
Original code copyright 1998-2005 by the authors.

Generated for brickOS Kernel Developer by doxygen 1.9.4