-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpydisplay.c
143 lines (117 loc) · 3.22 KB
/
pydisplay.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include <linux/ppdev.h>
#include <linux/parport.h>
#include <sys/ioctl.h>
#include <stdio.h>
void gu3900_write(int fd, char* data, int len)
{
// for each byte in the input sequence
int i = 0;
for (; i < len; ++i)
{
// write this byte to the data pins
char d = data[i];
ioctl(fd, PPWDATA, &d);
// wait for RDY
int status = PARPORT_STATUS_BUSY;
do {
ioctl(fd, PPRSTATUS, &status);
} while (status & PARPORT_STATUS_BUSY);
// toggle WR
struct ppdev_frob_struct frob = { PARPORT_CONTROL_STROBE, 0 };
frob.val = PARPORT_CONTROL_STROBE;
ioctl(fd, PPFCONTROL, &frob);
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);
}
}
#include <time.h>
void ndelay(int delay)
{
int spin = 0;
while (spin++ < delay/4) {}
}
#define ndelay(x)
int _delay = 0;//1000;// * 1000;
void sed1330_command(int fd, char cmd)
{
struct ppdev_frob_struct frob = { 0, 0 };
// set CS = 0
frob.mask = PARPORT_CONTROL_INIT;
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
// set A0 = 1
frob.mask = PARPORT_CONTROL_SELECT;
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
// write this byte to the data pins
char arg = cmd;
ioctl(fd, PPWDATA, &arg);
ndelay(_delay);
// toggle WR
frob.mask = PARPORT_CONTROL_STROBE;
frob.val = PARPORT_CONTROL_STROBE;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
}
void sed1330_write(int fd, char* data, int len)
{
struct ppdev_frob_struct frob = { 0, 0 };
// set CS = 0
frob.mask = PARPORT_CONTROL_INIT;
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
// set A0 = 0
frob.mask = PARPORT_CONTROL_SELECT;
frob.val = PARPORT_CONTROL_SELECT;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
// for each byte in the input sequence
int i = 0;
for (; i < len; ++i)
{
// write this byte to the data pins
char arg = data[i];
ioctl(fd, PPWDATA, &arg);
ndelay(_delay);
// toggle WR
frob.mask = PARPORT_CONTROL_STROBE;
frob.val = PARPORT_CONTROL_STROBE;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
}
}
void gu300_write(int fd, char* data, int len)
{
struct ppdev_frob_struct frob = { 0, 0 };
// set CS = 0
frob.mask = PARPORT_CONTROL_AUTOFD;
frob.val = PARPORT_CONTROL_AUTOFD;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
// for each byte in the input sequence
int i = 0;
for (; i < len; ++i)
{
// write this byte to the data pins
char arg = data[i];
ioctl(fd, PPWDATA, &arg);
ndelay(_delay);
// toggle WR
frob.mask = PARPORT_CONTROL_STROBE;
frob.val = PARPORT_CONTROL_STROBE;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);
ndelay(_delay);
}
}