fuck meaningful commit messages master
authorIan Sutton <ian.sutton@ibm.com>
Wed, 16 Jan 2019 01:58:07 +0000 (19:58 -0600)
committerIan Sutton <ian.sutton@ibm.com>
Wed, 16 Jan 2019 01:58:07 +0000 (19:58 -0600)
Makefile [changed mode: 0755->0644]
pins.c [changed mode: 0755->0644]
pins.h [changed mode: 0755->0644]
seg.c [changed mode: 0755->0644]
seg.h [changed mode: 0755->0644]
sr.sh

old mode 100755 (executable)
new mode 100644 (file)
diff --git a/pins.c b/pins.c
old mode 100755 (executable)
new mode 100644 (file)
index 48433c5..cd49a5c
--- a/pins.c
+++ b/pins.c
 #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");
@@ -56,6 +72,7 @@ void tick(int n) {
                HI("clk");
                kd2();
        }
+       sample("srq1");
 }
 
 void clear() {
@@ -72,19 +89,75 @@ 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");
@@ -115,12 +188,32 @@ for(;;){
        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);
+       }
+
 }
diff --git a/pins.h b/pins.h
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/seg.c b/seg.c
old mode 100755 (executable)
new mode 100644 (file)
index 2f6867f..6f7b25f
--- a/seg.c
+++ b/seg.c
@@ -26,21 +26,21 @@ int main(int argc, char *argv[]) {
        config_pins();
        pincnt();
 
-       start();
-       byte(0x8f);
-       stop();
+//     start();
+//     byte(0x8f);
+//     stop();
 
        start();
        byte(0x40);
        stop();
        start();
-       byte(0xc0 | 0x00);
-       byte(0x00);
-       byte(0x00);
-       byte(0x00);
-       byte(0x00);
-       byte(0x00);
-       byte(0x00);
+       byte(0xc0 | 0x03);
+       byte(0xff);
+       byte(0xff);
+       byte(0xff);
+       byte(0xff);
+       byte(0xff);
+       byte(0xff);
 /*for(;;) {
        arc4random_buf(ent, 32);
        byte(ent[0]);
@@ -50,12 +50,12 @@ int main(int argc, char *argv[]) {
        usleep(DEL);
 }*/
 
-for(;;) {
+/*for(;;) {
        UP("clk");
        usleep(1);
        DOWN("clk");
        usleep(1);
-}
+}*/
 
 for(;;) {
        byte(dig(0x0c));
diff --git a/seg.h b/seg.h
old mode 100755 (executable)
new mode 100644 (file)
index d3c5679..c815510
--- a/seg.h
+++ b/seg.h
@@ -76,13 +76,15 @@ uint8_t dig(uint8_t d) {
 
 void kd() {
 
+       usleep(1);
+/*
        asm("movs r0, #0");
 
        for(int i = 0; i < 10; i++) {
                asm("movs  r0, #10\n\t"  
                "1: subs  r0, r0, #1\n\t"
                "bne   1b");
-       }
+       }*/ 
 
 /*     volatile int t = 0;
 
diff --git a/sr.sh b/sr.sh
index 97d1b88f08782f284d2e989a7868812c7d6f3f24..fa82e044a724adb380cd61da50359ea625fa55dc 100755 (executable)
--- a/sr.sh
+++ b/sr.sh
@@ -1,7 +1,19 @@
 #!/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