From 16af4b953306063c2aed52ab2ecde07e0bc6b5e4 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 14 Oct 2013 19:06:11 +0100 Subject: works! --- src/sdram.c | 65 ++++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/sdram.c b/src/sdram.c index 60b9459..91bdad1 100644 --- a/src/sdram.c +++ b/src/sdram.c @@ -9,46 +9,57 @@ #define msleep(msec) usleep(1000*msec); +#ifdef PIO_0_BASE pio_write (unsigned int data) { IOWR (PIO_0_BASE, 0, data); } +#endif - -static void -show_score (int score) +void +ebb_write (unsigned int addr, uint8_t data) { - // 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; + IOWR (ASYNC_8BIT_BUS_ADAPTER_0_BASE, addr, data); +} - // show negative with DP - if (score < 0) - { - ss |= 0x80; - score = -score; - } +uint8_t +ebb_read (unsigned int addr) +{ + return (uint8_t) IORD (ASYNC_8BIT_BUS_ADAPTER_0_BASE, addr); +} - 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); - } - } + srand (12833213); + for (;;) + { + printf ("W:"); + printf(" xx"); + printf(" xx"); + printf(" xx"); + for (i = 0; i < 32; ++i) + { + uint8_t v; + v = rand () & 0xff; + ebb_write (i, v); + printf (" %02x", v); + } + printf ("\n"); + msleep (1000); + printf ("R:"); + printf (" %02x", ebb_read (0)); + printf (" %02x", ebb_read (0)); + printf (" %02x", ebb_read (0)); + for (i = 0; i < 32; ++i) + { + printf (" %02x", ebb_read (i)); + } + printf ("\n"); + msleep (1000); + } } -- cgit v1.2.3