00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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
00076
00078
00080
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
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))
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__