OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [testbench/] [kbdtest.c] - Diff between revs 997 and 1024

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 997 Rev 1024
Line 8... Line 8...
 
 
/* fails if x is false */
/* fails if x is false */
#define ASSERT(x) ((x)?1: fail (__FUNCTION__, __LINE__))
#define ASSERT(x) ((x)?1: fail (__FUNCTION__, __LINE__))
/* Waits a few cycles that uart can prepare its data */
/* Waits a few cycles that uart can prepare its data */
#define WAIT() {asm ("l.nop");asm ("l.nop");asm ("l.nop");asm ("l.nop");}
#define WAIT() {asm ("l.nop");asm ("l.nop");asm ("l.nop");asm ("l.nop");}
#define MARK() PRINTF ("Passed line %i\n", __LINE__)
#define MARK() printf ("Passed line %i\n", __LINE__)
 
 
#ifndef __LINE__
#ifndef __LINE__
#define __LINE__  0
#define __LINE__  0
#endif
#endif
 
 
Line 34... Line 34...
void fail (char *func, int line)
void fail (char *func, int line)
{
{
#ifndef __FUNCTION__
#ifndef __FUNCTION__
#define __FUNCTION__ "?"
#define __FUNCTION__ "?"
#endif
#endif
  PRINTF ("Test failed in %s:%i\n", func, line);
  printf ("Test failed in %s:%i\n", func, line);
  report(0xeeeeeeee);
  report(0xeeeeeeee);
  exit (1);
  exit (1);
}
}
 
 
inline void setreg (unsigned long addr, unsigned char value)
inline void setreg (unsigned long addr, unsigned char value)
Line 52... Line 52...
}
}
 
 
void interrupt_handler ()
void interrupt_handler ()
{
{
  unsigned x;
  unsigned x;
  PRINTF ("Int\n");
  printf ("Int\n");
  do {
  do {
    x = getreg (KBD_BASE_ADD);
    x = getreg (KBD_BASE_ADD);
    if (x) PRINTF ("0x%02x, ", x);
    if (x) printf ("0x%02x, ", x);
    report(x);
    report(x);
    if (x == 1) done = 1;
    if (x == 1) done = 1;
#if !INTERACTIVE
#if !INTERACTIVE
    PRINTF ("expecting (0x%02x), ", incoming_scan[current_scan]);
    printf ("expecting (0x%02x), ", incoming_scan[current_scan]);
    if (x) {
    if (x) {
      ASSERT (incoming_scan[current_scan++] == x);
      ASSERT (incoming_scan[current_scan++] == x);
    }
    }
    if ((current_scan + 1) >= sizeof (incoming_scan) / sizeof (char)) done = 1;
    if ((current_scan + 1) >= sizeof (incoming_scan) / sizeof (char)) done = 1;
#endif
#endif
  } while (x);
  } while (x);
  PRINTF ("%i", done);
  printf ("%i", done);
  mtspr(SPR_PICSR, 0);
  mtspr(SPR_PICSR, 0);
}
}
 
 
int main ()
int main ()
{
{
  /* Use our low priority interrupt handler */
  /* Use our low priority interrupt handler */
  excpt_int = (unsigned long)interrupt_handler;
  excpt_int = (unsigned long)interrupt_handler;
 
 
  PRINTF ("Reading from keyboard.\n");
  printf ("Reading from keyboard.\n");
  PRINTF ("Enabling interrupts.\n");
  printf ("Enabling interrupts.\n");
  done = 0;
  done = 0;
 
 
  /* Enable interrupts */
  /* Enable interrupts */
  mtspr (SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
  mtspr (SPR_SR, mfspr(SPR_SR) | SPR_SR_IEE);
  mtspr (SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << KBD_IRQ));
  mtspr (SPR_PICMR, mfspr(SPR_PICMR) | (0x00000001L << KBD_IRQ));
 
 
  while (!done) PRINTF ("[%i]", done);
  while (!done) printf ("[%i]", done);
  report (0xdeaddead);
  report (0xdeaddead);
  return 0;
  return 0;
}
}
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.