fixaroonie
[bort-panel.git] / pins.c
diff --git a/pins.c b/pins.c
old mode 100644 (file)
new mode 100755 (executable)
index 1c60712..48433c5
--- a/pins.c
+++ b/pins.c
 #define HI(N)  set(N, 1)
 #define LO(N)  set(N, 0)
 
+void kd2() {
+       usleep(10000);
+}
+
+void kdh() {
+    usleep(5000);
+}
+
+void kd1() {
+       usleep(1);
+}
+
+void test_pins() {
+       for(;;) {
+               HI("clk");
+               HI("clkinh");
+               LO("shld");
+               HI("clr");
+               kd1();
+               LO("clk");
+               LO("clkinh");
+               LO("shld");
+               LO("clr");
+               kd1();
+       }
+}
+
+/* call when clk is hi */
+void tick(int n) {
+       int i = 0;
+
+       for(; i < n; i++) {
+               LO("clk");
+               kd2();
+               HI("clk");
+               kd2();
+       }
+}
+
+void clear() {
+       HI("clk");
+       LO("clkinh");
+       kdh();
+       LO("clr");
+       kdh();
+       LO("clk");
+       kdh();
+       HI("clr");
+       kdh();
+       HI("clk");
+       kd2();
+}
+
 int main(int argc, char *argv[]) {
+
+       signal(SIGINT, inth);
+
        pins_init();
-       config_pins();
+//     config_pins();
        pincnt();
 
-       sleep(1);
-
        pcfg(1, 6,  -1, INPUT | PULLDOWN, "ser");
        pcfg(1, 13,  0, OUTPUT, "clk");
        pcfg(1, 15,  0, OUTPUT, "shld");
        pcfg(0, 27,  0, OUTPUT, "clr");
+       pcfg(1, 2,   0, OUTPUT, "clkinh");
 
-       for(;;) {
-           HI("shld");
-           usleep(1);
-           LO("shld");
-           usleep(1);
-       }
+       LO("clk");
+       HI("clkinh");
+       HI("clr");
+       HI("shld");
+
+       sleep(1);
+for(;;){
+       LO("clk");
+       HI("clkinh");
+       HI("clr");
+       HI("shld");
+       kd2();
+       kd2();
+       clear();
+
+       LO("clk");
+       LO("shld");
+       kd2();
+       HI("clk");
+       kdh();
+       HI("clkinh");
+       kdh();
+       LO("clk");
+
+       HI("shld");
+       kdh();
+       kdh();
+       HI("clk");
+       kd2();
+       tick(2);
+       LO("clk");
+       LO("clkinh");
+       kd2();
+       HI("clk");
+       kd2();
+       tick(8);
+}
 }