sgdk
lsd.h
00001 /************************************************************************/
00032 /*
00033  * Frame format is:
00034  *
00035  * STX : CH-LENH : LENL : DATA : ETX
00036  *
00037  * - STX and ETX are the start/end of transmission characters (1 byte each).
00038  * - CH-LENH is the channel number (first 4 bits) and the 4 high bits of the
00039  *   data length.
00040  * - LENL is the low 8 bits of the data length.
00041  * - DATA is the payload, of the previously specified length.
00042  */
00043 #ifndef _LSD_H_
00044 #define _LSD_H_
00045 
00046 #include "16c550.h"
00047 #include "mw-msg.h"
00048 
00049 #if (MODULE_MEGAWIFI != 0)
00050 
00052 #define LSD_OVERHEAD            4
00053 
00055 #define LSD_MAX_CH              4
00056 
00058 #define LSD_MAX_LEN              4095
00059 
00061 #define LSD_BUF_FRAMES          2
00062 
00064 enum lsd_status {
00065         LSD_STAT_ERR_FRAMING = -5,              
00066         LSD_STAT_ERR_INVALID_CH = -4,           
00067         LSD_STAT_ERR_FRAME_TOO_LONG = -3,       
00068         LSD_STAT_ERR_IN_PROGRESS = -2,          
00069         LSD_STAT_ERROR = -1,                    
00070         LSD_STAT_COMPLETE = 0,                  
00071         LSD_STAT_BUSY = 1                       
00072 };
00073 
00075 typedef void (*lsd_send_cb)(enum lsd_status stat, void *ctx);
00077 typedef void (*lsd_recv_cb)(enum lsd_status stat, uint8_t ch,
00078                 char *data, uint16_t len, void *ctx);
00079 
00080 /************************************************************************/
00083 void lsd_init(void);
00084 
00085 /************************************************************************/
00092 int lsd_ch_enable(uint8_t ch);
00093 
00094 /************************************************************************/
00101 int lsd_ch_disable(uint8_t ch);
00102 
00103 
00104 /************************************************************************/
00118 enum lsd_status lsd_send(uint8_t ch, const char *data, int16_t len,
00119                 void *ctx, lsd_send_cb send_cb);
00120 
00121 /************************************************************************/
00131 enum lsd_status lsd_send_sync(uint8_t ch, const char *data, int16_t len);
00132 
00133 /************************************************************************/
00143 enum lsd_status lsd_recv(char *buf, int16_t len, void *ctx,
00144                 lsd_recv_cb recv_cb);
00145 
00146 /************************************************************************/
00158 enum lsd_status lsd_recv_sync(char *buf, uint16_t *len, uint8_t *ch);
00159 
00160 /************************************************************************/
00166 void lsd_process(void);
00167 
00168 /************************************************************************/
00175 void lsd_line_sync(void);
00176 
00177 #endif // MODULE_MEGAWIFI
00178 
00179 #endif //_LSD_H_
00180 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines