cd49a5c9482e91c3e372659401b4238e0aafbbaa
10 #include <sys/types.h>
12 #include <sys/ioctl.h>
16 #define UP(N) set_pin(N, 1)
17 #define DOWN(N) set_pin(N, 0)
19 #define HI(N) set(N, 1)
20 #define LO(N) set(N, 0)
36 uint8_t sample(char *name
) {
37 struct gpio_pin_op op
;
38 struct pin2dev
*p
= pin(name
);
39 int fd
= num2fd(p
->dev
), t
;
41 strlcpy(op
.gp_name
, name
, GPIOPINMAXNAME
);
43 t
= ioctl(fd
, GPIOPINREAD
, &op
);
45 // printf("read %d, err: %d\n", op.gp_value, t);
65 /* call when clk is hi */
92 uint8_t sample_byte(char *name
) {
97 ret
|= (sample(name
) << i
);
107 void sample_bytes() {
113 memset(&ret
[0], 0, 6);
116 for(j
= 0; j
< 6; j
++) {
117 sprintf(s
, "srq%d", j
+ 1);
126 for(i
= 0; i
< 6; i
++)
127 printf("SRQ%d: %02x\n", i
+ 1, ret
[i
]);
132 int main(int argc
, char *argv
[]) {
136 signal(SIGINT
, inth
);
142 pcfg(1, 7, -1, INPUT
| PULLDOWN
, "srq1");
143 pcfg(1, 3, -1, INPUT
| PULLDOWN
, "srq2");
144 pcfg(1, 12, -1, INPUT
| PULLDOWN
, "srq3");
145 pcfg(0, 26, -1, INPUT
| PULLDOWN
, "srq4");
146 pcfg(1, 14, -1, INPUT
| PULLDOWN
, "srq5");
147 pcfg(2, 1, -1, INPUT
| PULLDOWN
, "srq6");
148 pcfg(1, 13, 0, OUTPUT
, "clk");
149 pcfg(1, 15, 0, OUTPUT
, "shld");
150 pcfg(0, 27, 0, OUTPUT
, "clr");
151 pcfg(2, 2, 0, OUTPUT
, "clkinh");
154 pcfg(2, 10, 0, OUTPUT
, "ss-rst");
155 pcfg(2, 12, 0, OUTPUT
, "ss-clk");
196 b
= sample_byte("srq1");
197 printf("TEST: 0x%02x\n", b
);