From abb7029fae182f1ef86f64af458267a996748e2b Mon Sep 17 00:00:00 2001 From: James Date: Sun, 13 Oct 2013 13:12:09 +0100 Subject: fish --- src/sdram.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/sdram.c (limited to 'src') 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 +#include +#include +#include +#include +#include +#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); + } + } +} -- cgit v1.2.3