annotate target-utils/c139explore/lcd.c @ 950:cd34e0d534b9

c139explore: LCD output implemented, does not work
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Wed, 04 Nov 2015 01:43:44 +0000
parents
children eb27543ce18e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
950
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <sys/types.h>
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 #include "types.h"
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4 static void
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 send_cmd_data(cmdbyte, databyte)
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 {
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 send_via_uwire(cmdbyte);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8 send_via_uwire(databyte | 0x100);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 }
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 void
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 cmd_lcdinit()
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 {
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14 /* from OsmocomBB */
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 send_cmd_data(0x3F, 0x01);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16 send_cmd_data(0x20, 0x03);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17 send_cmd_data(0x31, 0x03);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 }
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
19
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20 static void
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 set_lcd_addr_region(xstart, xend, ystart, yend)
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 {
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 send_cmd_data(0x10, xstart);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 send_cmd_data(0x11, ystart);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 send_cmd_data(0x12, xend);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 send_cmd_data(0x13, yend);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 send_cmd_data(0x14, xstart);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 send_cmd_data(0x15, ystart);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 }
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 static void
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 send_pixel_value(pix)
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 {
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 send_via_uwire((pix >> 8) | 0x100);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 send_via_uwire((pix & 0xFF) | 0x100);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 }
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 void
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 cmd_lcdfill(argbulk)
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 char *argbulk;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 {
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 int argc;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 char *argv[6];
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 u_long pixval;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 int xstart, xend, ystart, yend;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 int npix;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 if (parse_args(argbulk, 1, 5, argv, &argc) < 0)
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 return;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 if (parse_hexarg(argv[0], 4, &pixval) < 0) {
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 printf("ERROR: arg1 must be a valid 16-bit hex value\n");
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 return;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 }
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 switch (argc) {
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 case 1:
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 xstart = ystart = 0;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 xend = 95;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 yend = 63;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 break;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 case 5:
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 xstart = atoi(argv[1]);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 if (xstart < 0 || xstart > 95) {
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 range_err: printf("ERROR: coordinate arg out of range\n");
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 return;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 }
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 xend = atoi(argv[2]);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 if (xend < 0 || xend > 95)
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 goto range_err;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 ystart = atoi(argv[3]);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 if (ystart < 0 || ystart > 63)
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 goto range_err;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 yend = atoi(argv[4]);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 if (yend < 0 || yend > 63)
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
74 goto range_err;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 if (xend < xstart || yend < ystart) {
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76 printf("ERROR: negative range\n");
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77 return;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
78 }
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
79 break;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 default:
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81 printf("ERROR: wrong number of arguments\n");
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
82 return;
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
83 }
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
84 set_lcd_addr_region(xstart, xend, ystart, yend);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
85 npix = (xend + 1 - xstart) * (yend + 1 - ystart);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
86 while (npix--)
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
87 send_pixel_value(pixval);
cd34e0d534b9 c139explore: LCD output implemented, does not work
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
88 }