SGDK
A free and open development kit for the Sega Mega Drive
Loading...
Searching...
No Matches
lsd.h
1/************************************************************************/
32
33/*
34 * Frame format is:
35 *
36 * STX : CH-LENH : LENL : DATA : ETX
37 *
38 * - STX and ETX are the start/end of transmission characters (1 byte each).
39 * - CH-LENH is the channel number (first 4 bits) and the 4 high bits of the
40 * data length.
41 * - LENL is the low 8 bits of the data length.
42 * - DATA is the payload, of the previously specified length.
43 */
44#ifndef _LSD_H_
45#define _LSD_H_
46
47#if (MODULE_MEGAWIFI == 1 && MODULE_EVERDRIVE == 0)
48 #include "16c550.h"
49#elif (MODULE_MEGAWIFI == 1 && MODULE_EVERDRIVE == 1)
50 #include "ssf.h"
51#endif
52#include "mw-msg.h"
53
54#if (MODULE_MEGAWIFI == 1)
55
57#define LSD_OVERHEAD 4
58
60#define LSD_MAX_CH 4
61
63#define LSD_MAX_LEN 4095
64
66#define LSD_BUF_FRAMES 2
67
69enum lsd_status {
70 LSD_STAT_ERR_FRAMING = -5,
71 LSD_STAT_ERR_INVALID_CH = -4,
72 LSD_STAT_ERR_FRAME_TOO_LONG = -3,
73 LSD_STAT_ERR_IN_PROGRESS = -2,
74 LSD_STAT_ERROR = -1,
75 LSD_STAT_COMPLETE = 0,
76 LSD_STAT_BUSY = 1
77};
78
80typedef void (*lsd_send_cb)(enum lsd_status stat, void *ctx);
82typedef void (*lsd_recv_cb)(enum lsd_status stat, uint8_t ch,
83 char *data, uint16_t len, void *ctx);
84
85/************************************************************************/
88void lsd_init(void);
89
90/************************************************************************/
97int lsd_ch_enable(uint8_t ch);
98
99/************************************************************************/
106int lsd_ch_disable(uint8_t ch);
107
108
109/************************************************************************/
123enum lsd_status lsd_send(uint8_t ch, const char *data, int16_t len,
124 void *ctx, lsd_send_cb send_cb);
125
126/************************************************************************/
136enum lsd_status lsd_send_sync(uint8_t ch, const char *data, int16_t len);
137
138/************************************************************************/
148enum lsd_status lsd_recv(char *buf, int16_t len, void *ctx,
149 lsd_recv_cb recv_cb);
150
151/************************************************************************/
163enum lsd_status lsd_recv_sync(char *buf, uint16_t *len, uint8_t *ch);
164
165/************************************************************************/
171void lsd_process(void);
172
173/************************************************************************/
180void lsd_line_sync(void);
181
182#endif // MODULE_MEGAWIFI
183
184#endif //_LSD_H_
185
MegaWiFi command message definitions.