annotate rvinterf/tmsh/abbtm3.c @ 300:0cfb2e3aeda4

started documenting c1xx-calextr
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 19 Nov 2017 21:45:12 +0000
parents 74b9aeb25d79
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Old TM3 versions of ABB register read and write commands
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "pktmux.h"
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "limits.h"
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "localtypes.h"
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "tm3.h"
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include "exitcodes.h"
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern u_char rvi_msg[];
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 extern int rvi_msg_len;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
151
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
19 void
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
20 handle_oabbr_response()
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
21 {
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
22 char buf[80];
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
23 unsigned val;
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
24
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
25 if (rvi_msg[3]) {
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
26 if (rvi_msg_len == 5) {
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
27 sprintf(buf, "oabbr error %u (0x%02X)",
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
28 rvi_msg[3], rvi_msg[3]);
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
29 async_msg_output(buf);
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
30 } else
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
31 print_etm_pkt_raw("oabbr long error response");
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
32 return;
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
33 }
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
34 if (rvi_msg_len != 7) {
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
35 print_etm_pkt_raw("oabbr response wrong length");
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
36 return;
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
37 }
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
38 val = rvi_msg[4] | (rvi_msg[5] << 8);
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
39 sprintf(buf, "oabbr: %04X", val);
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
40 async_msg_output(buf);
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
41 }
74b9aeb25d79 fc-tmsh: oabbr and oabbw response handling implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 150
diff changeset
42
150
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 cmd_oabbr(argc, argv)
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 char **argv;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 {
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 u32 page, reg;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 u_char cmdpkt[5];
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 page = strtoul(argv[1], 0, 0);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 reg = strtoul(argv[2], 0, 0);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 if (page > 1 || reg > 31) {
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 printf("error: argument(s) out of range\n");
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 return(ERROR_USAGE);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 cmdpkt[1] = CODEC_READ;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 cmdpkt[2] = page << 5 | reg;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 cmdpkt[3] = 0;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 send_etm_cmd(cmdpkt, 3);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 return(0);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 cmd_oabbw(argc, argv)
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 char **argv;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 {
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 u32 page, reg, val;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 u_char cmdpkt[7];
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 page = strtoul(argv[1], 0, 0);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 reg = strtoul(argv[2], 0, 0);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 val = strtoul(argv[3], 0, 16);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 if (page > 1 || reg > 31 || val > 0x3FF) {
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 printf("error: argument(s) out of range\n");
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 return(ERROR_USAGE);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 }
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 cmdpkt[1] = CODEC_WRITE;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 cmdpkt[2] = page << 5 | reg;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 cmdpkt[3] = 0;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 cmdpkt[4] = val;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 cmdpkt[5] = val >> 8;
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 send_etm_cmd(cmdpkt, 5);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 return(0);
45d8c175f9b5 fc-tmsh: oabbr and oabbw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 }