annotate target-utils/buzplayer/pwt.c @ 962:e3706ce1d01c

CHANGES: document sms-pdu-decode -n option
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 05 Aug 2023 00:01:42 +0000
parents 7c02cc7f28df
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
820
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Commands for exercising the Calypso buzzer in PWT mode.
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <strings.h>
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "types.h"
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 extern u_long strtoul();
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #define ASIC_CONF_REG (*(volatile u16 *) 0xFFFEF008)
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #define PWT_MODE_MASK 0x0020
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #define PWT_FRC_REG (*(volatile u8 *) 0xFFFE8800)
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #define PWT_VCR_REG (*(volatile u8 *) 0xFFFE8801)
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #define PWT_GCR_REG (*(volatile u8 *) 0xFFFE8802)
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 void
821
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
19 pwt_on()
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
20 {
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
21 ASIC_CONF_REG |= PWT_MODE_MASK;
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
22 PWT_GCR_REG = 0x01;
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
23 }
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
24
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
25 void
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
26 pwt_off()
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
27 {
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
28 ASIC_CONF_REG &= ~PWT_MODE_MASK;
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
29 PWT_GCR_REG = 0;
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
30 }
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
31
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
32 void
820
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 cmd_pwt(argbulk)
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 char *argbulk;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 {
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 char *argv[2];
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 if (parse_args(argbulk, 1, 1, argv, 0) < 0)
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 return;
821
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
40 if (!strcmp(argv[0], "on"))
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
41 pwt_on();
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
42 else if (!strcmp(argv[0], "off"))
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
43 pwt_off();
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
44 else
820
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 printf("ERROR: \"on\" or \"off\" argument expected\n");
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 void
822
7c02cc7f28df buzplayer: PWT tone playing command shortened to bzt
Mychaela Falconia <falcon@freecalypso.org>
parents: 821
diff changeset
49 cmd_bzt(argbulk)
820
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 char *argbulk;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 {
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 char *argv[3];
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 u32 note, vol;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 int c;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 if (parse_args(argbulk, 1, 2, argv, 0) < 0)
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 return;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 note = strtoul(argv[0], 0, 0);
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 if (note > 47) {
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 printf("ERROR: note argument out of range\n");
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 return;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 }
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 if (argv[1]) {
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 vol = strtoul(argv[1], 0, 0);
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 if (vol > 63) {
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 printf("ERROR: volume argument out of range\n");
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 return;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 }
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 } else
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 vol = 63;
821
16bee7b6bd6b buzplayer: PWT needs to be turned on in order to not hang
Mychaela Falconia <falcon@freecalypso.org>
parents: 820
diff changeset
71 pwt_on();
820
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 PWT_FRC_REG = note;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 PWT_VCR_REG = (vol << 1) | 1;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 for (;;) {
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 c = serial_in_poll();
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 if (c >= 0)
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 break;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 }
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 PWT_VCR_REG = 0;
03457a66d860 buzplayer: add basic support for PWT
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 }