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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [testbench/] [kbdtest.c] - Diff between revs 664 and 970

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

Rev 664 Rev 970
Line 1... Line 1...
/* Simple keyboard test. Outputs scan codes. */
/* Simple keyboard test. Outputs scan codes. */
#include "support.h"
#include "support.h"
#include "spr_defs.h"
#include "spr_defs.h"
#include "support.h"
#include "board.h"
 
 
/* Whether this test should be run in interactive mode; scan codes are not check against real ones */
/* Whether this test should be run in interactive mode; scan codes are not check against real ones */
#define INTERACTIVE 0
#define INTERACTIVE 0
 
 
#define BASEADDR  0xb1000000
 
 
 
#define KBD_INT_LINE 21 /* To which interrupt is uart connected */
 
 
 
/* 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__)
Line 58... Line 54...
void interrupt_handler ()
void interrupt_handler ()
{
{
  unsigned x;
  unsigned x;
  printf ("Int\n");
  printf ("Int\n");
  do {
  do {
    x = getreg (BASEADDR);
    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]);
Line 83... Line 79...
  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_INT_LINE));
  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;
}
}

powered by: WebSVN 2.1.0

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