comparison lcdtest/busops.c @ 12:5eaf832d57d0

lcdtest program started, skeleton compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 06 Apr 2018 06:15:11 +0000
parents
children 238a77db4134
comparison
equal deleted inserted replaced
11:03017bfeb3ce 12:5eaf832d57d0
1 #include <sys/types.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <unistd.h>
5 #include <ftdi.h>
6
7 extern struct ftdi_context ftdi;
8
9 do_ftdi_write(cmd, cmdlen)
10 u_char *cmd;
11 {
12 if (ftdi_write_data(&ftdi, cmd, cmdlen) != cmdlen) {
13 fprintf(stderr, "FTDI write error: %s\n", ftdi.error_str);
14 exit(1);
15 }
16 }
17
18 set_gpio_pins(rs, reset)
19 {
20 u_char cmd[3];
21
22 cmd[0] = 0x82;
23 cmd[1] = (rs ? 1 : 0) | (reset ? 2 : 0);
24 cmd[2] = 0x03;
25 do_ftdi_write(cmd, 3);
26 }
27
28 reset_pulse()
29 {
30 set_gpio_pins(0, 0);
31 usleep(50000);
32 set_gpio_pins(0, 1);
33 return(0);
34 }
35
36 write_ir(val16)
37 unsigned val16;
38 {
39 u_char cmd[9];
40
41 /* set RS low */
42 cmd[0] = 0x82;
43 cmd[1] = 0x02;
44 cmd[2] = 0x03;
45 /* write upper byte */
46 cmd[3] = 0x92;
47 cmd[4] = 0; /* dummy addr */
48 cmd[5] = val16 >> 8;
49 /* write lower byte */
50 cmd[6] = 0x92;
51 cmd[7] = 0; /* dummy addr */
52 cmd[8] = val16;
53 do_ftdi_write(cmd, 9);
54 }
55
56 write_dr(val16)
57 unsigned val16;
58 {
59 u_char cmd[9];
60
61 /* set RS high */
62 cmd[0] = 0x82;
63 cmd[1] = 0x03;
64 cmd[2] = 0x03;
65 /* write upper byte */
66 cmd[3] = 0x92;
67 cmd[4] = 0; /* dummy addr */
68 cmd[5] = val16 >> 8;
69 /* write lower byte */
70 cmd[6] = 0x92;
71 cmd[7] = 0; /* dummy addr */
72 cmd[8] = val16;
73 do_ftdi_write(cmd, 9);
74 }