annotate target-utils/libcommon/buzzer.c @ 76:5bbba2cab6f3

target-utils: buzplayer started
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 27 Oct 2016 03:50:40 +0000
parents 29d0965ebf86
children 4be951811791
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #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
11 #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
12 #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
13
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 void
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 cmd_buzlev(argbulk)
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char *argbulk;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char *argv[2];
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 u32 arg;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 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
22 return;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (argv[0]) {
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 arg = strtoul(argv[0], 0, 0);
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 if (arg > 0xFFFF) {
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 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
27 return;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 }
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 BUZZ_LEVEL_REG = arg;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 } else
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 printf("%04X\n", BUZZ_LEVEL_REG);
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 void
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 cmd_buz(argbulk)
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 char *argbulk;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 {
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 char *argv[2];
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 u32 arg;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 int c;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 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
43 return;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 arg = strtoul(argv[0], 0, 0);
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (arg > 0xFFFF) {
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 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
47 return;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 ARMIO_LOAD_TIM = arg;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 BUZZ_LIGHT_REG = 1;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 for (;;) {
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 c = serial_in_poll();
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 if (c >= 0)
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 break;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 }
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 BUZZ_LIGHT_REG = 0;
29d0965ebf86 target-utils: buzzer exercising code written, added to c139explore
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 }