#define HI(N) set(N, 1)
#define LO(N) set(N, 0)
+void test_7seg();
+
void kd2() {
- usleep(10000);
+ usleep(5000);
}
void kdh() {
- usleep(5000);
+ usleep(2500);
}
void kd1() {
usleep(1);
}
+uint8_t sample(char *name) {
+ struct gpio_pin_op op;
+ struct pin2dev *p = pin(name);
+ int fd = num2fd(p->dev), t;
+
+ strlcpy(op.gp_name, name, GPIOPINMAXNAME);
+
+ t = ioctl(fd, GPIOPINREAD, &op);
+
+// printf("read %d, err: %d\n", op.gp_value, t);
+
+ return op.gp_value;
+}
+
void test_pins() {
for(;;) {
HI("clk");
HI("clk");
kd2();
}
+ sample("srq1");
}
void clear() {
kd2();
}
+uint8_t sample_byte(char *name) {
+ uint8_t ret = 0;
+ int i = 8;
+
+ for(; i > 0; i--) {
+ ret |= (sample(name) << i);
+ kd2();
+ LO("clk");
+ kd2();
+ HI("clk");
+ }
+
+ return ret;
+}
+
+void sample_bytes() {
+ uint8_t ret[6];
+ int i = 8, j = 0;
+ char *s;
+
+ s = calloc(10, 1);
+ memset(&ret[0], 0, 6);
+
+ for(; i > 0; i--) {
+ for(j = 0; j < 6; j++) {
+ sprintf(s, "srq%d", j + 1);
+ ret[j] |= sample(s);
+ }
+ kd2();
+ LO("clk");
+ kd2();
+ HI("clk");
+ }
+
+ for(i = 0; i < 6; i++)
+ printf("SRQ%d: %02x\n", i + 1, ret[i]);
+
+ printf("\n\n\n");
+}
+
int main(int argc, char *argv[]) {
+ uint8_t b;
+
signal(SIGINT, inth);
pins_init();
-// config_pins();
+ config_pins();
pincnt();
- pcfg(1, 6, -1, INPUT | PULLDOWN, "ser");
+ pcfg(1, 7, -1, INPUT | PULLDOWN, "srq1");
+ pcfg(1, 3, -1, INPUT | PULLDOWN, "srq2");
+ pcfg(1, 12, -1, INPUT | PULLDOWN, "srq3");
+ pcfg(0, 26, -1, INPUT | PULLDOWN, "srq4");
+ pcfg(1, 14, -1, INPUT | PULLDOWN, "srq5");
+ pcfg(2, 1, -1, INPUT | PULLDOWN, "srq6");
pcfg(1, 13, 0, OUTPUT, "clk");
pcfg(1, 15, 0, OUTPUT, "shld");
pcfg(0, 27, 0, OUTPUT, "clr");
- pcfg(1, 2, 0, OUTPUT, "clkinh");
+ pcfg(2, 2, 0, OUTPUT, "clkinh");
+
+ /* 7 seg */
+ pcfg(2, 10, 0, OUTPUT, "ss-rst");
+ pcfg(2, 12, 0, OUTPUT, "ss-clk");
+// test_7seg();
+
+ start();
+ byte(0x8f);
+ stop();
LO("clk");
HI("clkinh");
kdh();
HI("clk");
kd2();
- tick(2);
LO("clk");
LO("clkinh");
kd2();
HI("clk");
+
+ b = sample_byte("srq1");
+ printf("TEST: 0x%02x\n", b);
+// sample_bytes();
+
kd2();
- tick(8);
+// tick(16);
+// tick(7);
+}
}
+
+void test_7seg() {
+
+ HI("ss-rst");
+ sleep(1);
+ LO("ss-rst");
+
+ for(;;) {
+ HI("ss-clk");
+ usleep(50000);
+ LO("ss-clk");
+ usleep(50000);
+ }
+
}
#!/bin/ksh
+# dial inputs
+gpioctl gpio1 13 set out clk
+gpioctl gpio1 15 set out shld
+gpioctl gpio0 27 set out clr
+gpioctl gpio2 2 set out clkinh
-gpioctl gpio1 13 set output clk
-gpioctl gpio1 6 set input pd srser
-gpioctl gpio1 15 set output shld
-gpioctl gpio0 27 set output clr
+gpioctl gpio1 7 set in pd srq1
+gpioctl gpio1 3 set in pd srq2
+gpioctl gpio1 12 set in pd srq3
+gpioctl gpio0 26 set in pd srq4
+gpioctl gpio1 14 set in pd srq5
+gpioctl gpio2 1 set in pd srq6
+
+
+# 7seg
+gpioctl gpio2 10 set out ss-rst
+gpioctl gpio2 12 set out ss-clk