FreeCalypso > hg > freecalypso-tools
comparison target-utils/libcommon/buzzer.c @ 36:29d0965ebf86
target-utils: buzzer exercising code written, added to c139explore
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 25 Oct 2016 23:57:15 +0000 |
parents | |
children | 4be951811791 |
comparison
equal
deleted
inserted
replaced
35:2942c5ef76ed | 36:29d0965ebf86 |
---|---|
1 /* | |
2 * Commands for exercising the Calypso's buzzer output, whatever | |
3 * actual hardware (piezo buzzer or vibrator) it may be driving | |
4 * on a given Calypso device. | |
5 */ | |
6 | |
7 #include <sys/types.h> | |
8 #include "types.h" | |
9 | |
10 #define ARMIO_LOAD_TIM (*(volatile u16 *) 0xFFFE4808) | |
11 #define BUZZ_LIGHT_REG (*(volatile u16 *) 0xFFFE480E) | |
12 #define BUZZ_LEVEL_REG (*(volatile u16 *) 0xFFFE4812) | |
13 | |
14 void | |
15 cmd_buzlev(argbulk) | |
16 char *argbulk; | |
17 { | |
18 char *argv[2]; | |
19 u32 arg; | |
20 | |
21 if (parse_args(argbulk, 0, 1, argv, 0) < 0) | |
22 return; | |
23 if (argv[0]) { | |
24 arg = strtoul(argv[0], 0, 0); | |
25 if (arg > 0xFFFF) { | |
26 printf("ERROR: argument out of range\n"); | |
27 return; | |
28 } | |
29 BUZZ_LEVEL_REG = arg; | |
30 } else | |
31 printf("%04X\n", BUZZ_LEVEL_REG); | |
32 } | |
33 | |
34 void | |
35 cmd_buz(argbulk) | |
36 char *argbulk; | |
37 { | |
38 char *argv[2]; | |
39 u32 arg; | |
40 int c; | |
41 | |
42 if (parse_args(argbulk, 1, 1, argv, 0) < 0) | |
43 return; | |
44 arg = strtoul(argv[0], 0, 0); | |
45 if (arg > 0xFFFF) { | |
46 printf("ERROR: argument out of range\n"); | |
47 return; | |
48 } | |
49 ARMIO_LOAD_TIM = arg; | |
50 BUZZ_LIGHT_REG = 1; | |
51 for (;;) { | |
52 c = serial_in_poll(); | |
53 if (c >= 0) | |
54 break; | |
55 } | |
56 BUZZ_LIGHT_REG = 0; | |
57 } |