annotate target-utils/c139explore/dac.c @ 39:280826b807e3

c139explore: dac and dacon commands added for exercising the vibrator
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 26 Oct 2016 01:53:12 +0000
parents
children 7ecb70b0ac36
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 }