summaryrefslogtreecommitdiffstats
path: root/src/sdram_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdram_test.c')
-rw-r--r--src/sdram_test.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/sdram_test.c b/src/sdram_test.c
new file mode 100644
index 0000000..ba1be8d
--- /dev/null
+++ b/src/sdram_test.c
@@ -0,0 +1,56 @@
+#include <io.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include "system.h"
+
+
+#define msleep(msec) usleep(1000*msec);
+
+pio_write (unsigned int data)
+{
+ IOWR (PIO_0_BASE, 0, data);
+}
+
+static void
+show (int v)
+{
+ // int to seven segment lookup: MSB dp g f e d c b a LSB
+ const uint8_t lookup[10] =
+ { 0x3F, 0x6, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x7, 0x7F, 0x6F };
+
+ uint8_t pio = 0;
+
+ // show negative with DP
+ if (v < 0)
+ {
+ pio |= 0x80;
+ v = -v;
+ }
+
+ if (v > 9)
+ v = 9;
+
+ pio |= lookup[v];
+
+ pio_write (pio);
+}
+
+
+
+int
+main (void)
+{
+ int i;
+ printf ("Working...\n");
+ for (;;) {
+ for (i=-9;i<10;++i) {
+ printf("Showing %d\n",i);
+ show(i);
+ msleep(1000);
+ }
+ }
+
+}