--- /dev/null
+#!/bin/ksh
+
+gpioctl gpio1 6 set ser
+gpioctl gpio1 ser set in pd
+gpioctl gpio1 2 set clkinh
+gpioctl gpio1 clkinh set out
+gpioctl gpio1 13 set clk
+gpioctl gpio1 clk set out
+gpioctl gpio1 15 set shld
+gpioctl gpio1 shld set out
+gpioctl gpio0 27 set clr
+gpioctl gpio0 clr set out
+
#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");
+ LO("shld");
+
+ sleep(1);
+for(;;){
+ LO("clk");
+ HI("clkinh");
+ HI("clr");
+ LO("shld");
+ kd2();
+ kd2();
+ clear();
+
+ tick(4);
+ LO("clk");
+ LO("shld");
+ kd2();
+ HI("clk");
+ kdh();
+ HI("clkinh");
+ kdh();
+ LO("clk");
+
+ LO("shld");
+ kdh();
+ kdh();
+ HI("clk");
+ kd2();
+ tick(2);
+ LO("clk");
+ LO("clkinh");
+ kd2();
+ HI("clk");
+ kd2();
+ tick(10);
+}
}
int fd;
p = pin(name);
- op.gp_pin = p->pin;
+ strlcpy(op.gp_name, name, GPIOPINMAXNAME);
op.gp_value = val;
fd = num2fd(p->dev);
- //printf("given name: %s\nderived name: %s\nderived pin: %d\nval: %d\nfd: %d\nreal fd: %d\n", name, p->name,
- // p->pin, op.gp_value, fd, g1);
+// printf("given name: %s\nderived name: %s\nderived pin: %d\nval: %d\nfd: %d\nreal fd: %d\n", name, p->name,
+// p->pin, op.gp_value, fd, g1);
// printf("g0: %d g1: %d g2: %d\n", g0, g1, g2);
char *nm = calloc(1, 255);
char *md = calloc(1, 255);
- usleep(1000 * 500);
strlcpy(nm, name, GPIOPINMAXNAME);
if (mode & OUTPUT)
for(;;) {
UP("clk");
- kd();
+ usleep(1);
DOWN("clk");
- kd();
+ usleep(1);
}
for(;;) {