diff options
author | James <james.mckenzie@citrix.com> | 2013-10-13 13:12:09 +0100 |
---|---|---|
committer | James <james.mckenzie@citrix.com> | 2013-10-13 13:12:09 +0100 |
commit | abb7029fae182f1ef86f64af458267a996748e2b (patch) | |
tree | ac8f0241ea06d16cd1a70be493076210978c02be /src/sdram.c | |
parent | 7fbec04d3aaca8909f89b325e125e46fe218e3be (diff) | |
download | sdram-abb7029fae182f1ef86f64af458267a996748e2b.tar.gz sdram-abb7029fae182f1ef86f64af458267a996748e2b.tar.bz2 sdram-abb7029fae182f1ef86f64af458267a996748e2b.zip |
fish
Diffstat (limited to 'src/sdram.c')
-rw-r--r-- | src/sdram.c | 54 |
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); + } + } +} |