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

started documenting c1xx-calextr
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 19 Nov 2017 21:45:12 +0000
parents 7b1624cdc9c0
children 0f2db8baf8db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * ETM audio commands
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdio.h>
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "limits.h"
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "localtypes.h"
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "etm.h"
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
13 #include "exitcodes.h"
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
168
7b1624cdc9c0 fc-tmsh: consistent naming of audio command sending functions
Mychaela Falconia <falcon@freecalypso.org>
parents: 167
diff changeset
15 cmd_aul(argc, argv)
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char **argv;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int slen;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 slen = strlen(argv[1]);
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (slen > 9) {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 printf("error: audio config name is limited to 9 chars\n");
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
24 return(ERROR_USAGE);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 dp = cmdpkt + 1;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 *dp++ = ETM_AUDIO;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 *dp++ = 'L';
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 strcpy(dp, argv[1]);
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 dp += slen + 1;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
32 return(0);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
168
7b1624cdc9c0 fc-tmsh: consistent naming of audio command sending functions
Mychaela Falconia <falcon@freecalypso.org>
parents: 167
diff changeset
35 cmd_aus(argc, argv)
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 char **argv;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 u_char cmdpkt[MAX_PKT_TO_TARGET], *dp;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 int slen;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 slen = strlen(argv[1]);
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (slen > 9) {
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 printf("error: audio config name is limited to 9 chars\n");
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
44 return(ERROR_USAGE);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 dp = cmdpkt + 1;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *dp++ = ETM_AUDIO;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 *dp++ = 'S';
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 strcpy(dp, argv[1]);
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 dp += slen + 1;
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 send_etm_cmd(cmdpkt, dp - cmdpkt - 1);
69
2159f260ed13 fc-tmsh: all commands internally return values
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
52 return(0);
32
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
ea061975c883 fc-tmsh: implemented sending of ETM audio load and save commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
168
7b1624cdc9c0 fc-tmsh: consistent naming of audio command sending functions
Mychaela Falconia <falcon@freecalypso.org>
parents: 167
diff changeset
55 cmd_aur(argc, argv)
158
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
56 char **argv;
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
57 {
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
58 unsigned param;
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
59 u_char cmdpkt[5];
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
60
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
61 param = strtoul(argv[1], 0, 0);
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
62 if (param > 255) {
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
63 printf("error: argument is too large\n");
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
64 return(ERROR_USAGE);
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
65 }
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
66 cmdpkt[1] = ETM_AUDIO;
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
67 cmdpkt[2] = 'R';
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
68 cmdpkt[3] = param;
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
69 send_etm_cmd(cmdpkt, 3);
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
70 return(0);
86e4d8aea021 fc-tmsh: aur command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 69
diff changeset
71 }
167
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
72
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
73 cmd_auw(argc, argv)
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
74 char **argv;
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
75 {
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
76 u32 param, v;
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
77 u_char cmdpkt[MAX_PKT_TO_TARGET];
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
78 int di;
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
79 char **ap;
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
80
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
81 param = strtoul(argv[1], 0, 0);
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
82 if (param > 255) {
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
83 printf("error: parameter index argument is too large\n");
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
84 return(ERROR_USAGE);
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
85 }
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
86 cmdpkt[1] = ETM_AUDIO;
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
87 cmdpkt[2] = 'W';
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
88 cmdpkt[3] = param;
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
89 di = 4;
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
90 for (ap = argv + 2; *ap; ap++) {
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
91 v = strtol(*ap, 0, 0);
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
92 cmdpkt[di++] = v;
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
93 cmdpkt[di++] = v >> 8;
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
94 }
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
95 send_etm_cmd(cmdpkt, di - 1);
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
96 return(0);
6e4120cdb456 fc-tmsh: auw command sending implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 166
diff changeset
97 }