Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

include/lnp/sys/lnp.h

Go to the documentation of this file.
00001 
00006 /*
00007  *  The contents of this file are subject to the Mozilla Public License
00008  *  Version 1.0 (the "License"); you may not use this file except in
00009  *  compliance with the License. You may obtain a copy of the License
00010  *  at http://www.mozilla.org/MPL/
00011  *
00012  *  Software distributed under the License is distributed on an "AS IS"
00013  *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00014  *  the License for the specific language governing rights and
00015  *  limitations under the License.
00016  *
00017  *  The Original Code is legOS code, released October 17, 1999.
00018  *
00019  *  The Initial Developer of the Original Code is Markus L. Noga.
00020  *  Portions created by Markus L. Noga are Copyright (C) 1999
00021  *  Markus L. Noga. All Rights Reserved.
00022  *
00023  *  Contributor(s): Markus L. Noga <markus@noga.de>
00024  */
00025 
00026 #ifndef __sys_lnp_h__
00027 #define __sys_lnp_h__
00028 
00029 #ifdef  __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 #include "../lnp.h"
00034 
00035 #ifdef CONF_LNP
00036 
00038 //
00039 // Definitions
00040 //
00042 
00043 #define LNP_HOSTMASK  CONF_LNP_HOSTMASK   
00044 
00045 
00046 #define LNP_PORTMASK  (0x00ff & ~CONF_LNP_HOSTMASK)
00047 
00048 #if defined(CONF_RCX_PROTOCOL) || defined(CONF_RCX_MESSAGE)
00049 
00050 #define LNP_RCX_HEADER_LENGTH (3-1)
00051 
00053 #define LNP_RCX_REMOTE_OP_LENGTH (5-3)
00054 
00056 #define LNP_RCX_MSG_OP_LENGTH (5-3)
00057 #endif
00058 
00060 typedef enum {
00061   LNPwaitHeader,
00062   LNPwaitLength,
00063   LNPwaitData,
00064   LNPwaitCRC,
00065 
00066 #if defined(CONF_RCX_PROTOCOL) || defined(CONF_RCX_MESSAGE)
00067 
00068   LNPwaitRMH1,  // note that first byte is consumed by LNPwaitHeader
00069   LNPwaitRMH2,  // inverted header
00070   LNPwaitRMH3,  // actually, RCX opcode dispatch
00071   LNPwaitRMH4,  // remote opcode inverted
00072 #endif
00073 
00074 
00075 #ifdef CONF_RCX_PROTOCOL
00076 
00077   LNPwaitRB0, // high-byte
00078   LNPwaitRB0I,
00079   LNPwaitRB1, // low-byte
00080   LNPwaitRB1I,
00081   LNPwaitRC,  // RCX checksum
00082   LNPwaitRCI,
00083 #endif
00084 
00085 #ifdef CONF_RCX_MESSAGE
00086 
00087   LNPwaitMH3, // RCX message OP
00088   LNPwaitMH4,
00089   LNPwaitMN,  // message number
00090   LNPwaitMNC,
00091   LNPwaitMC,  // RCX checksum
00092   LNPwaitMCC,
00093 #endif
00094 } lnp_integrity_state_t;
00095 
00096 
00098 //
00099 // Variables
00100 //
00102 
00104 extern volatile unsigned short lnp_timeout_counter;
00105 
00107 extern unsigned short lnp_timeout;
00108 
00110 extern lnp_integrity_state_t lnp_integrity_state;
00111 
00112 
00114 //
00115 // Functions
00116 //
00118 
00120 extern unsigned char lnp_checksum_copy( unsigned char *dest,
00121           const unsigned char *data,
00122           unsigned length );
00123 
00126 
00128 extern void lnp_integrity_byte(unsigned char b);
00129 
00131 extern void lnp_integrity_reset(void)
00132 #ifdef CONF_RCX_COMPILER
00133 __attribute__ ((rcx_interrupt))
00134 #endif
00135 ;
00136 
00138 
00140 extern inline int lnp_integrity_active(void) {
00141   return lnp_integrity_state!=LNPwaitHeader;
00142 }
00143 
00145 extern void lnp_timeout_reset(void)
00146 #ifdef CONF_RCX_COMPILER
00147 __attribute__ ((rcx_interrupt))
00148 #endif
00149 ;
00150 
00153 
00155 extern inline void lnp_timeout_set(unsigned short timeout) {
00156   lnp_timeout_counter=lnp_timeout=timeout;
00157 }
00158 
00160 
00163 extern void lnp_init(void);
00164 
00165 #endif  // CONF_LNP
00166 
00167 #ifdef  __cplusplus
00168 }
00169 #endif
00170 
00171 #endif  // __sys_lnp_h__
00172 

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

Generated on Mon Feb 16 21:02:10 2004 for brickOS Kernel Developer by doxygen 1.3.5