summaryrefslogtreecommitdiffstats
path: root/src/sdram.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdram.c')
-rw-r--r--src/sdram.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/sdram.c b/src/sdram.c
new file mode 100644
index 0000000..60b9459
--- /dev/null
+++ b/src/sdram.c
@@ -0,0 +1,54 @@
+#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_score (int score)
+{
+ // 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 ss = 0;
+
+ // show negative with DP
+ if (score < 0)
+ {
+ ss |= 0x80;
+ score = -score;
+ }
+
+ if (score > 9)
+ score = 9;
+
+ ss |= lookup[score];
+
+ pio_write (ss);
+}
+int
+main (void)
+{
+ int i;
+ printf ("Working...\n");
+ for (;;) {
+ for (i=-9;i<10;++i)
+ {
+ printf("%d\n",i);
+ show_score(i);
+ msleep(200);
+ }
+ }
+}