Beispiel #1
0
// The interrupt service routine
static void Key_InterruptHandler(void* context, alt_u32 id)
{
    pollkey();
    /* Write to the edge capture register to reset it. */
    IOWR_ALTERA_AVALON_PIO_EDGE_CAP(DE2_PIO_KEYS4_BASE, 0);
    /* reset interrupt capability for the Button PIO. */
    IOWR_ALTERA_AVALON_PIO_IRQ_MASK(DE2_PIO_KEYS4_BASE, 0xf);
}
Beispiel #2
0
void
mydelay_half()
     /* sleep until the half-second mark.  also works via polling.
        also close enough for government work. */
{
  static struct timeval curr;
  while (1) {
    gettimeofday(&curr, NULL);
    if (curr.tv_usec >= 500000)
      return;
    pollkey();
  }
}
Beispiel #3
0
void
mydelay()
     /* sleep until second changes.  works via polling.  close enough
        for government work. */
{
  static struct timeval prev;
  static struct timeval curr;
  gettimeofday(&prev, NULL);
  while (1) {
    gettimeofday(&curr, NULL);
    if (curr.tv_sec > prev.tv_sec)
      return;
    pollkey();
    prev = curr;
  }
}