forked from tangrs/Nspire-Movie-Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.c
41 lines (37 loc) · 1.27 KB
/
timer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <os.h>
#include "inc.h"
static unsigned timer_load, timer_saved_control, timer_saved_load;
void setup_timer(int fps) {
/*volatile unsigned *control = (unsigned*)0x900D0008;
volatile unsigned *load = (unsigned*)0x900D0000;
volatile unsigned *value = (unsigned*)0x900D0004;
if (is_cx) {
timer_saved_control = *control;
timer_saved_load = *load;
*control = 0; // disable timer
*control = 0b01100011; // disabled, TimerMode N/A, int, no prescale, 32-bit, One Shot (for the *value > 0 test) -> 32khz
*control = 0b11100011; // enable timer
timer_load = 32000/fps;
}*/
}
void restore_timer() {
/*volatile unsigned *control = (unsigned*)0x900D0008;
volatile unsigned *load = (unsigned*)0x900D0000;
volatile unsigned *value = (unsigned*)0x900D0004;
if (is_cx) {
*control = 0; // disable timer
*control = timer_saved_control & 0b01111111; // timer still disabled
*load = timer_saved_load;
*control = timer_saved_control; // enable timer
}*/
}
void tick_timer() {
/*volatile unsigned *control = (unsigned*)0x900D0008;
volatile unsigned *load = (unsigned*)0x900D0000;
volatile unsigned *value = (unsigned*)0x900D0004;
if (is_cx) {
*load = timer_load;
}
while (*value > 0)
idle();*/
}