From 77338a6b34d6a164fc2f70e6d736eca8a5b7d251 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 5 Mar 2018 11:36:00 -0500 Subject: [PATCH] bug fixes, keypad work --- include/keypad.h | 24 ++++++++++++------------ initrd/init | 16 +--------------- libinterp.a | Bin 62140 -> 62136 bytes src/keypad.c | 26 +++++++++++++------------- src/main.c | 3 +++ xinitrd/init | 33 +++++++++++++++++++++++++++++++++ xinitrd/init2 | 21 +++++++++++++++++++++ 7 files changed, 83 insertions(+), 40 deletions(-) create mode 100644 xinitrd/init create mode 100644 xinitrd/init2 diff --git a/include/keypad.h b/include/keypad.h index 83e0626..5eec1fc 100644 --- a/include/keypad.h +++ b/include/keypad.h @@ -3,18 +3,18 @@ #include -#define K0 (1 << 0) -#define K1 (1 << 1) -#define K2 (1 << 2) -#define K3 (1 << 3) -#define K4 (1 << 4) -#define K5 (1 << 5) -#define K6 (1 << 6) -#define K7 (1 << 7) -#define K8 (1 << 8) -#define K9 (1 << 9) -#define KS (1 << 10) -#define KP (1 << 11) +#define K0 (uint16_t)(1 << 0) +#define K1 (uint16_t)(1 << 1) +#define K2 (uint16_t)(1 << 2) +#define K3 (uint16_t)(1 << 3) +#define K4 (uint16_t)(1 << 4) +#define K5 (uint16_t)(1 << 5) +#define K6 (uint16_t)(1 << 6) +#define K7 (uint16_t)(1 << 7) +#define K8 (uint16_t)(1 << 8) +#define K9 (uint16_t)(1 << 9) +#define KS (uint16_t)(1 << 10) +#define KP (uint16_t)(1 << 11) void keypad_init(void); diff --git a/initrd/init b/initrd/init index fcf9ec2..4351743 100644 --- a/initrd/init +++ b/initrd/init @@ -1,15 +1 @@ -do - getkey > input - if (input & 4) - rand 479 > x - rand 319 > y - rand 479 > i - rand 319 > j - rand 32767 > purple - - line x y i j purple - end -while (1) - -print "done" - +print "Hello, world!" diff --git a/libinterp.a b/libinterp.a index 561bb117745f0e49781af7e939807f7b499c1067..d52e2803bcf46de59182df5e14cd76914da2038a 100644 GIT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($PI(45QxHlSdOzpKDe!WdzJut+$aiTHV|=wXiN647@HYsJ1?_>9=QMIRFVmgsZB zD?+~jhpVD7__xLtr7=n2dZCs8 diff --git a/src/keypad.c b/src/keypad.c index 41fc924..06e0b6a 100644 --- a/src/keypad.c +++ b/src/keypad.c @@ -1,18 +1,18 @@ #include #include -#define PIN_0 GPIO_PORT(A, 11) -#define PIN_1 GPIO_PORT(B, 13) -#define PIN_2 GPIO_PORT(B, 2) -#define PIN_3 GPIO_PORT(A, 12) -#define PIN_4 GPIO_PORT(B, 14) -#define PIN_5 GPIO_PORT(B, 11) -#define PIN_6 GPIO_PORT(C, 5) -#define PIN_7 GPIO_PORT(B, 15) -#define PIN_8 GPIO_PORT(B, 12) -#define PIN_9 GPIO_PORT(C, 6) -#define PIN_S GPIO_PORT(B, 1) -#define PIN_P GPIO_PORT(C, 8) +#define PIN_0 GPIO_PORT(B, 2) +#define PIN_1 GPIO_PORT(B, 1) +#define PIN_2 GPIO_PORT(A, 11) +#define PIN_3 GPIO_PORT(C, 8) +#define PIN_4 GPIO_PORT(B, 15) +#define PIN_5 GPIO_PORT(B, 12) +#define PIN_6 GPIO_PORT(C, 6) +#define PIN_7 GPIO_PORT(B, 14) +#define PIN_8 GPIO_PORT(B, 11) +#define PIN_9 GPIO_PORT(C, 5) +#define PIN_S GPIO_PORT(B, 13) +#define PIN_P GPIO_PORT(A, 12) typedef struct { GPIO_TypeDef *port; @@ -43,7 +43,7 @@ void keypad_init(void) gpio_mode(p, pin, OUTPUT); gpio_dout(p, pin, 0); gpio_mode(p, pin, INPUT); - gpio_pupd(p, pin, PULLDOWN); + //gpio_pupd(p, pin, PULLDOWN); } } diff --git a/src/main.c b/src/main.c index abcb8e6..74ae6b7 100644 --- a/src/main.c +++ b/src/main.c @@ -23,6 +23,8 @@ void task_interpreter(void); int main(void) { asm("cpsid i"); + // disable cached writes for precise debug info + //*((uint32_t *)0xE000E008) |= 2; // prepare flash latency for 80MHz operation FLASH->ACR &= ~(FLASH_ACR_LATENCY); @@ -59,6 +61,7 @@ void kmain(void) while (1) { gpio_dout(GPIOA, 5, (keypad_isdown(K0))); + delay(10); /*gpio_dout(GPIOA, 5, 1); delay(250); gpio_dout(GPIOA, 5, 0); diff --git a/xinitrd/init b/xinitrd/init new file mode 100644 index 0000000..4fd74dd --- /dev/null +++ b/xinitrd/init @@ -0,0 +1,33 @@ +print "Hello." + +set fg 32767 + +# draw bg, lines +rect 50 50 380 220 6375 +line 50 160 430 160 fg +line 240 50 240 270 fg + +set x 50 +do + line x 170 x 150 fg + set x (x + 20) +while (x < 431) + +set y 50 +do + line 230 y 250 y fg + set y (y + 20) +while (y < 271) + +do + rand 379 > x + rand 219 > y + rand 379 > i + rand 219 > j + set x (x + 50) + set y (y + 50) + set i (i + 50) + set j (j + 50) + + line x y i j 511 +while (1) diff --git a/xinitrd/init2 b/xinitrd/init2 new file mode 100644 index 0000000..47dbae1 --- /dev/null +++ b/xinitrd/init2 @@ -0,0 +1,21 @@ +do + getkey > input + print input + delay 1000 +while (1) + +#do +# getkey > input +# if (input & 4) +# rand 479 > x +# rand 319 > y +# rand 479 > i +# rand 319 > j +# rand 32767 > purple +# +# line x y i j purple +# end +#while (1) +# +#print "done" +