annotate target-utils/c139explore/dac.c @ 231:a58a7bbc0618

CHANGES: first changes since fc-host-tools-r5
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 03 Aug 2017 03:21:39 +0000
parents ce636b0ffb3d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Code for exercising Motorola's vibrator, which is driven
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * via the Iota auxiliary DAC on this phone.
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "types.h"
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "abbdefs.h"
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
110
ce636b0ffb3d target-utils/c139explore/dac.c: added missing extern u_long strtoul();
Mychaela Falconia <falcon@freecalypso.org>
parents: 40
diff changeset
10 extern u_long strtoul();
ce636b0ffb3d target-utils/c139explore/dac.c: added missing extern u_long strtoul();
Mychaela Falconia <falcon@freecalypso.org>
parents: 40
diff changeset
11
39
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 void
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 cmd_dacon()
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 {
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 abb_reg_write(TOGBR1, 0x20);
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 }
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 void
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 cmd_dac(argbulk)
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 char *argbulk;
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 char *argv[2];
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 u32 val;
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (parse_args(argbulk, 1, 1, argv, 0) < 0)
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 return;
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 val = strtoul(argv[0], 0, 0);
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 if (val > 0x3FF) {
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 printf("ERROR: argument out of range\n");
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 return;
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 abb_reg_write(AUXDAC, val);
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
40
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
34
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
35 void
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
36 cmd_vibe(argbulk)
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
37 char *argbulk;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
38 {
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
39 char *argv[2];
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
40 u32 val;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
41 int c;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
42
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
43 if (parse_args(argbulk, 1, 1, argv, 0) < 0)
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
44 return;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
45 val = strtoul(argv[0], 0, 0);
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
46 if (val > 0x3FF) {
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
47 printf("ERROR: argument out of range\n");
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
48 return;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
49 }
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
50 abb_reg_write(AUXDAC, val);
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
51 for (;;) {
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
52 c = serial_in_poll();
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
53 if (c >= 0)
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
54 break;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
55 }
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
56 abb_reg_write(AUXDAC, 0);
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
57 }