src/timer/nds/SDL_systimer.c
branchgsoc2008_nds
changeset 2696 0b395a60deff
parent 2683 e858ac8868b6
child 2698 e1da92da346c
     1.1 --- a/src/timer/nds/SDL_systimer.c	Sun Aug 17 09:50:28 2008 +0000
     1.2 +++ b/src/timer/nds/SDL_systimer.c	Mon Aug 18 07:29:52 2008 +0000
     1.3 @@ -28,7 +28,10 @@
     1.4  
     1.5  #include "SDL_timer.h"
     1.6  #include "../SDL_timer_c.h"
     1.7 +#include "../SDL_systimer.h"
     1.8  
     1.9 +/* Data to handle a single periodic alarm */
    1.10 +static int timer_alive = 0;
    1.11  static Uint32 timer_ticks;
    1.12  
    1.13  void
    1.14 @@ -57,10 +60,6 @@
    1.15      }
    1.16  }
    1.17  
    1.18 -/* Data to handle a single periodic alarm */
    1.19 -static int timer_alive = 0;
    1.20 -static int timer_ticks = 0;
    1.21 -
    1.22  static int
    1.23  RunTimer(void *unused)
    1.24  {
    1.25 @@ -72,8 +71,8 @@
    1.26      return (0);
    1.27  }
    1.28  
    1.29 -void NDS_TimerInterrupt() {
    1.30 -    printf("timer irq\n");
    1.31 +void NDS_TimerInterrupt(void) {
    1.32 +	timer_ticks++;
    1.33  }
    1.34  
    1.35  /* This is only called if the event thread is not running */
    1.36 @@ -82,9 +81,10 @@
    1.37  {
    1.38      timer_alive = 1;
    1.39      timer_ticks = 0;
    1.40 -    TIMER_CR(0) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
    1.41 -    TIMER_DATA(0) = TIMER_FREQ_1024(1000);
    1.42 -    irqSet(IRQ_TIMER1, NDS_TimerInterrupt);
    1.43 +    TIMER_CR(3) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
    1.44 +    TIMER_DATA(3) = TIMER_FREQ_1024(1000);
    1.45 +    irqSet(IRQ_TIMER3, NDS_TimerInterrupt);
    1.46 +    irqEnable(IRQ_TIMER3);
    1.47      return 0;
    1.48  }
    1.49  
    1.50 @@ -92,22 +92,23 @@
    1.51  SDL_SYS_TimerQuit(void)
    1.52  {
    1.53      if (timer_alive) {
    1.54 -        TIMER_CR(0) = 0;
    1.55 +        TIMER_CR(3) = 0;
    1.56      }
    1.57      timer_alive = 0;
    1.58 +    irqDisable(IRQ_TIMER3);
    1.59  }
    1.60  
    1.61  int
    1.62  SDL_SYS_StartTimer(void)
    1.63  {
    1.64 -    TIMER_CR(0) |= TIMER_ENABLE;
    1.65 +    TIMER_CR(3) |= TIMER_ENABLE;
    1.66      return 0;
    1.67  }
    1.68  
    1.69  void
    1.70  SDL_SYS_StopTimer(void)
    1.71  {
    1.72 -    TIMER_CR(0) &= ~TIMER_ENABLE;
    1.73 +    TIMER_CR(3) &= ~TIMER_ENABLE;
    1.74      return;
    1.75  }
    1.76