annotate target-utils/c139explore/dac.c @ 59:819335e06fd1

c139explore and pirexplore host wrapper shell scripts added
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 26 Oct 2016 15:28:29 +0000
parents 7ecb70b0ac36
children ce636b0ffb3d
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
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 void
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 cmd_dacon()
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 {
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 abb_reg_write(TOGBR1, 0x20);
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
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 void
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 cmd_dac(argbulk)
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char *argbulk;
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 char *argv[2];
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 u32 val;
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 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
24 return;
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 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
26 if (val > 0x3FF) {
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 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
28 return;
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 abb_reg_write(AUXDAC, val);
280826b807e3 c139explore: dac and dacon commands added for exercising the vibrator
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 }
40
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
32
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
33 void
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
34 cmd_vibe(argbulk)
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
35 char *argbulk;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
36 {
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
37 char *argv[2];
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
38 u32 val;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
39 int c;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
40
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
41 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
42 return;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
43 val = strtoul(argv[0], 0, 0);
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
44 if (val > 0x3FF) {
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
45 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
46 return;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
47 }
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
48 abb_reg_write(AUXDAC, val);
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
49 for (;;) {
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
50 c = serial_in_poll();
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
51 if (c >= 0)
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
52 break;
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
53 }
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
54 abb_reg_write(AUXDAC, 0);
7ecb70b0ac36 c139explore: vibe command added that works like buz
Mychaela Falconia <falcon@freecalypso.org>
parents: 39
diff changeset
55 }