fix am.h, _up_time() return unsigned long
This commit is contained in:
parent
9fe9d51a36
commit
1668c06e1d
2
am/am.h
2
am/am.h
|
@ -82,7 +82,7 @@ extern _Area _heap;
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
|
||||||
void _ioe_init();
|
void _ioe_init();
|
||||||
long _uptime();
|
unsigned long _uptime();
|
||||||
int _read_key();
|
int _read_key();
|
||||||
void _draw_rect(const uint32_t *pixels, int x, int y, int w, int h);
|
void _draw_rect(const uint32_t *pixels, int x, int y, int w, int h);
|
||||||
void _draw_sync();
|
void _draw_sync();
|
||||||
|
|
|
@ -17,17 +17,4 @@ struct _RegSet {
|
||||||
#define REG3(regs) ((regs)->a2)
|
#define REG3(regs) ((regs)->a2)
|
||||||
#define REG4(regs) ((regs)->a3)
|
#define REG4(regs) ((regs)->a3)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void _ioe_init();
|
|
||||||
unsigned long _uptime();
|
|
||||||
void _draw_rect(const uint32_t *pixels, int x, int y, int w, int h);
|
|
||||||
void _draw_sync();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,17 +7,17 @@ void _ioe_init() {
|
||||||
|
|
||||||
// -------------------- cycles and uptime --------------------
|
// -------------------- cycles and uptime --------------------
|
||||||
|
|
||||||
static uintptr_t npc_time = 0;
|
static unsigned long npc_time = 0;
|
||||||
static unsigned long npc_cycles = 0;
|
static unsigned long npc_cycles = 0;
|
||||||
|
|
||||||
uintptr_t _uptime(){
|
unsigned long _uptime(){
|
||||||
//1. Read the upper 32-bit timer/counter register (TCR1).
|
//1. Read the upper 32-bit timer/counter register (TCR1).
|
||||||
//2. Read the lower 32-bit timer/counter register (TCR0).
|
//2. Read the lower 32-bit timer/counter register (TCR0).
|
||||||
//3. Read the upper 32-bit timer/counter register (TCR1) again. If the value is different from
|
//3. Read the upper 32-bit timer/counter register (TCR1) again. If the value is different from
|
||||||
//the 32-bit upper value read previously, go back to previous step (reading TCR0).
|
//the 32-bit upper value read previously, go back to previous step (reading TCR0).
|
||||||
//Otherwise 64-bit timer counter value is correct.
|
//Otherwise 64-bit timer counter value is correct.
|
||||||
uintptr_t counter_reg1 = real_timer_get_counter_reg(1);
|
unsigned long counter_reg1 = real_timer_get_counter_reg(1);
|
||||||
uintptr_t counter_reg0 = 0;
|
unsigned long counter_reg0 = 0;
|
||||||
do {
|
do {
|
||||||
counter_reg0 = real_timer_get_counter_reg(0);
|
counter_reg0 = real_timer_get_counter_reg(0);
|
||||||
}while(counter_reg1 != real_timer_get_counter_reg(1));
|
}while(counter_reg1 != real_timer_get_counter_reg(1));
|
||||||
|
|
Loading…
Reference in New Issue