annotate target-utils/libcommon/buzzer.c @ 752:c79aaed75bd8

compile-fc-batt: allow possible third field in source lines Battery tables maintained in the fc-battery-conf repository will now have a third field added, defining thresholds for the battery bars icon, and there will be a new utility to compile them into the new /etc/batterytab2 file read by the FC Tourmaline version of our FCHG driver. For backward compatibility with the original Magnetite version of FCHG, compile-fc-batt remains the tool for compiling the original /etc/batterytab file format, and it needs to ignore the newly added third field in battery table sources.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 05 Nov 2020 20:37:55 +0000
parents 4be951811791
children
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
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 }