comparison include/cmd_proto.h @ 1:f7c60e525801

cptest and cp_ping.py to test cmd_proto.c.
author Thinker K.F. Li <thinker@branda.to>
date Sat, 21 Feb 2009 20:20:06 +0800
parents
children abf221bf3ce4
comparison
equal deleted inserted replaced
0:a0ce8ebf2f18 1:f7c60e525801
1 #ifndef __CMD_PROTO_H_
2 #define __CMD_PROTO_H_
3
4 #define CP_MAGIC "JC"
5 #define CP_MAX_SZ 0x255
6 typedef enum {
7 CPCMD_DUMMY,
8 CPCMD_PING,
9 CPCMD_PONG,
10 CPCMD_DATA,
11 CPCMD_ACK,
12 CPCMD_NAK,
13 CPCMD_SHIFT_TDI,
14 CPCMD_SHIFT_TMS,
15 CPCMD_SHIFT_TDI_TDO,
16 CPCMD_MAX
17 } cp_ccode_t;
18
19 typedef struct {
20 int seq;
21 cp_ccode_t code;
22 int data_sz;
23 char *data;
24 } cp_cmd_t;
25
26 typedef struct {
27 cp_cmd_t cmds[2];
28 int receiving;
29 int status;
30 int seq;
31 int cnt;
32 int len;
33 char *bufs[2];
34 } cmd_proto_t;
35
36 extern cmd_proto_t *cmd_proto_new(void);
37 extern void cmd_proto_free(cmd_proto_t *cp);
38 extern cp_cmd_t *cmd_proto_rcv(cmd_proto_t *cp, int c);
39 /*
40 * \return size of filled command.
41 */
42 extern int cmd_proto_cmd_fill(char *buf, int seq,
43 cp_ccode_t code, int data_sz);
44 extern cp_cmd_t BAD_CMD;
45 extern cp_cmd_t CSUM_ERR_CMD;
46
47 #define CP_CMD_HEAD_SZ 5
48 #define CP_CMD_TAIL_SZ 1
49 #define CP_CMD_OVERHEAD (CP_CMD_HEAD_SZ + CP_CMD_TAIL_SZ)
50
51 #endif /* __CMD_PROTO_H_ */