diff options
| author | root <root@artemis.panaceas.org> | 2013-10-14 19:56:36 +0100 | 
|---|---|---|
| committer | root <root@artemis.panaceas.org> | 2013-10-14 19:56:36 +0100 | 
| commit | 9ddb6a83a8e0f29876c427be70b5ef3eff665ba9 (patch) | |
| tree | 8aee920eac9b9658fffc3025ab712f87487809e0 /src | |
| download | sdram_test-9ddb6a83a8e0f29876c427be70b5ef3eff665ba9.tar.gz sdram_test-9ddb6a83a8e0f29876c427be70b5ef3eff665ba9.tar.bz2 sdram_test-9ddb6a83a8e0f29876c427be70b5ef3eff665ba9.zip  | |
fish
Diffstat (limited to 'src')
| -rw-r--r-- | src/sdram_test.c | 56 | 
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); +  } + } +	 +}  | 
