annotate target-utils/lunadrv/regcmd.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 36e6a1ff9608
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
702
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Handy commands for reading and writing LCD controller registers.
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "types.h"
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "luna.h"
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 void
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 cmd_rd(argbulk)
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 char *argbulk;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 {
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 char *argv[2];
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 u_long regno;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 if (parse_args(argbulk, 1, 1, argv, 0) < 0)
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 return;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (parse_hexarg(argv[0], 4, &regno) < 0) {
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 printf("ERROR: regno argument must be a valid 16-bit hex word\n");
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 return;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 }
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 LCD_IR = regno;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 printf("%04X\n", LCD_DR);
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 void
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 cmd_wr(argbulk)
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 char *argbulk;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 {
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 char *argv[3];
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 u_long regno, value;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (parse_args(argbulk, 2, 2, argv, 0) < 0)
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 return;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 if (parse_hexarg(argv[0], 4, &regno) < 0) {
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 printf("ERROR: regno argument must be a valid 16-bit hex word\n");
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 return;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (parse_hexarg(argv[1], 4, &value) < 0) {
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 printf("ERROR: value argument must be a valid 16-bit hex word\n");
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 return;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 LCD_IR = regno;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 LCD_DR = value;
36e6a1ff9608 lunadrv: rd and wr commands added
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }