sgdk
Loading...
Searching...
No Matches
lsd.h
1/************************************************************************/
32/*
33 * Frame format is:
34 *
35 * STX : CH-LENH : LENL : DATA : ETX
36 *
37 * - STX and ETX are the start/end of transmission characters (1 byte each).
38 * - CH-LENH is the channel number (first 4 bits) and the 4 high bits of the
39 * data length.
40 * - LENL is the low 8 bits of the data length.
41 * - DATA is the payload, of the previously specified length.
42 */
43#ifndef _LSD_H_
44#define _LSD_H_
45
46#include "16c550.h"
47#include "mw-msg.h"
48
49#if (MODULE_MEGAWIFI != 0)
50
52#define LSD_OVERHEAD 4
53
55#define LSD_MAX_CH 4
56
58#define LSD_MAX_LEN 4095
59
61#define LSD_BUF_FRAMES 2
62
64enum lsd_status {
65 LSD_STAT_ERR_FRAMING = -5,
66 LSD_STAT_ERR_INVALID_CH = -4,
67 LSD_STAT_ERR_FRAME_TOO_LONG = -3,
68 LSD_STAT_ERR_IN_PROGRESS = -2,
69 LSD_STAT_ERROR = -1,
70 LSD_STAT_COMPLETE = 0,
71 LSD_STAT_BUSY = 1
72};
73
75typedef void (*lsd_send_cb)(enum lsd_status stat, void *ctx);
77typedef void (*lsd_recv_cb)(enum lsd_status stat, uint8_t ch,
78 char *data, uint16_t len, void *ctx);
79
80/************************************************************************/
83void lsd_init(void);
84
85/************************************************************************/
92int lsd_ch_enable(uint8_t ch);
93
94/************************************************************************/
101int lsd_ch_disable(uint8_t ch);
102
103
104/************************************************************************/
118enum lsd_status lsd_send(uint8_t ch, const char *data, int16_t len,
119 void *ctx, lsd_send_cb send_cb);
120
121/************************************************************************/
131enum lsd_status lsd_send_sync(uint8_t ch, const char *data, int16_t len);
132
133/************************************************************************/
143enum lsd_status lsd_recv(char *buf, int16_t len, void *ctx,
144 lsd_recv_cb recv_cb);
145
146/************************************************************************/
158enum lsd_status lsd_recv_sync(char *buf, uint16_t *len, uint8_t *ch);
159
160/************************************************************************/
166void lsd_process(void);
167
168/************************************************************************/
175void lsd_line_sync(void);
176
177#endif // MODULE_MEGAWIFI
178
179#endif //_LSD_H_
180
MegaWiFi command message definitions.