FreeCalypso > hg > freecalypso-tools
annotate target-utils/libcommon/buzzer.c @ 926:6a0aa8d36d06
rvinterf backslash escape: introduce libprint
The new helper function library named libprint is meant to replace
the badly misnamed libg23, and will soon contain functions for
printing all of the same kinds of GPF TST packets that are now handled
in libg23. However, we are also moving safe_print_trace() from libasync
to this new library, and changing it to emit our new backslash escape
format.
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Tue, 23 May 2023 03:47:46 +0000 |
| parents | 4be951811791 |
| children |
| rev | line source |
|---|---|
|
36
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Commands for exercising the Calypso's buzzer output, whatever |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * actual hardware (piezo buzzer or vibrator) it may be driving |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * on a given Calypso device. |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/types.h> |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include "types.h" |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
|
107
4be951811791
target-utils/libcommon: extern u_long strtoul(); added where needed
Mychaela Falconia <falcon@freecalypso.org>
parents:
36
diff
changeset
|
10 extern u_long strtoul(); |
|
4be951811791
target-utils/libcommon: extern u_long strtoul(); added where needed
Mychaela Falconia <falcon@freecalypso.org>
parents:
36
diff
changeset
|
11 |
|
36
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #define ARMIO_LOAD_TIM (*(volatile u16 *) 0xFFFE4808) |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #define BUZZ_LIGHT_REG (*(volatile u16 *) 0xFFFE480E) |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #define BUZZ_LEVEL_REG (*(volatile u16 *) 0xFFFE4812) |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 void |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 cmd_buzlev(argbulk) |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 char *argbulk; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 { |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 char *argv[2]; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 u32 arg; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (parse_args(argbulk, 0, 1, argv, 0) < 0) |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 return; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 if (argv[0]) { |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 arg = strtoul(argv[0], 0, 0); |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if (arg > 0xFFFF) { |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 printf("ERROR: argument out of range\n"); |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 return; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 } |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 BUZZ_LEVEL_REG = arg; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } else |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 printf("%04X\n", BUZZ_LEVEL_REG); |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 void |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 cmd_buz(argbulk) |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 char *argbulk; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 { |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 char *argv[2]; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 u32 arg; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 int c; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 if (parse_args(argbulk, 1, 1, argv, 0) < 0) |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 return; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 arg = strtoul(argv[0], 0, 0); |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 if (arg > 0xFFFF) { |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 printf("ERROR: argument out of range\n"); |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 return; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 ARMIO_LOAD_TIM = arg; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 BUZZ_LIGHT_REG = 1; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 for (;;) { |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 c = serial_in_poll(); |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 if (c >= 0) |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 break; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 BUZZ_LIGHT_REG = 0; |
|
29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 } |
