Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

include/lnp/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 __lnp_h__
00027 #define __lnp_h__
00028 
00029 #ifdef  __cplusplus
00030 extern "C" {
00031 #endif
00032 
00033 #include <config.h>
00034 
00035 #ifdef CONF_LNP
00036 
00037 #ifdef CONF_RCX_MESSAGE
00038 #include <unistd.h>
00039 #endif
00040 
00042 //
00043 // Definitions
00044 //
00046 
00048 
00050 typedef void (*lnp_integrity_handler_t) (const unsigned char *, unsigned char);
00051 
00053 
00055 typedef void (*lnp_addressing_handler_t) (const unsigned char *, unsigned char, unsigned char);
00056 
00058 #define LNP_DUMMY_INTEGRITY ((lnp_integrity_handler_t)0)
00059 
00061 #define LNP_DUMMY_ADDRESSING ((lnp_addressing_handler_t)0)
00062 
00063 #ifdef CONF_RCX_PROTOCOL
00064 
00065 
00067 typedef void (*lnp_remote_handler_t) (unsigned int);
00068 
00070 #define LNP_DUMMY_REMOTE ((lnp_remote_handler_t)0)
00071 #endif
00072 
00074 //
00075 // Variables
00076 //
00078 
00080 //  one handler.
00081 extern volatile lnp_integrity_handler_t lnp_integrity_handler;
00082 
00084 extern volatile lnp_addressing_handler_t lnp_addressing_handler[];
00085 
00087 extern unsigned char lnp_hostaddr;
00088 
00089 #ifdef CONF_RCX_PROTOCOL
00090 
00091 extern lnp_remote_handler_t lnp_remote_handler;
00092 #endif
00093 
00095 //
00096 // Functions
00097 //
00099 
00101 extern inline void lnp_integrity_set_handler(lnp_integrity_handler_t handler)
00102 {
00103   lnp_integrity_handler = handler;
00104 }
00105 
00107 extern inline void lnp_addressing_set_handler(unsigned char port, lnp_addressing_handler_t handler)
00108 {
00109   if (!(port & CONF_LNP_HOSTMASK))  // sanity check.
00110 
00111     lnp_addressing_handler[port] = handler;
00112 }
00113 
00115 extern inline void lnp_set_hostaddr(unsigned char host)
00116 {
00117     lnp_hostaddr = ((host << 4) & CONF_LNP_HOSTMASK);
00118 }
00119 
00120 #ifdef CONF_RCX_PROTOCOL
00121 
00122 extern inline void lnp_remote_set_handler(lnp_remote_handler_t handler)
00123 {
00124   lnp_remote_handler = handler;
00125 }
00126 #endif
00127 
00128 #ifdef CONF_RCX_MESSAGE
00129 
00130 extern unsigned char lnp_rcx_message;
00131 
00133 extern int send_msg(unsigned char msg);
00134 
00136 extern inline void clear_msg(void)
00137 {
00138    lnp_rcx_message = 0;
00139 }
00140 
00142 wakeup_t msg_received(wakeup_t m);
00143 
00145 extern inline unsigned char get_msg(void)
00146 {
00147    clear_msg();
00148    if (wait_event(msg_received, 0) == 0)
00149      return 0;
00150    return lnp_rcx_message;
00151 }
00152 
00153 #endif
00154 
00156 
00158 extern int lnp_integrity_write(const unsigned char *data,unsigned char length);
00159 
00161 
00163 extern int lnp_addressing_write(const unsigned char *data,unsigned char length,
00164                          unsigned char dest,unsigned char srcport);
00165 
00166 #endif // CONF_LNP
00167 
00168 #ifdef  __cplusplus
00169 }
00170 #endif
00171 
00172 #endif // _lnp_h__

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

Generated on Mon Feb 16 21:01:52 2004 for brickOS C by doxygen 1.3.5