fix am.h, _up_time() return unsigned long

This commit is contained in:
141220007 2017-07-23 20:53:38 +08:00
parent 9fe9d51a36
commit 1668c06e1d
3 changed files with 5 additions and 18 deletions

View File

@ -82,7 +82,7 @@ extern _Area _heap;
// =======================================================================
void _ioe_init();
long _uptime();
unsigned long _uptime();
int _read_key();
void _draw_rect(const uint32_t *pixels, int x, int y, int w, int h);
void _draw_sync();

View File

@ -17,17 +17,4 @@ struct _RegSet {
#define REG3(regs) ((regs)->a2)
#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

View File

@ -7,17 +7,17 @@ void _ioe_init() {
// -------------------- cycles and uptime --------------------
static uintptr_t npc_time = 0;
static unsigned long npc_time = 0;
static unsigned long npc_cycles = 0;
uintptr_t _uptime(){
unsigned long _uptime(){
//1. Read the upper 32-bit timer/counter register (TCR1).
//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
//the 32-bit upper value read previously, go back to previous step (reading TCR0).
//Otherwise 64-bit timer counter value is correct.
uintptr_t counter_reg1 = real_timer_get_counter_reg(1);
uintptr_t counter_reg0 = 0;
unsigned long counter_reg1 = real_timer_get_counter_reg(1);
unsigned long counter_reg0 = 0;
do {
counter_reg0 = real_timer_get_counter_reg(0);
}while(counter_reg1 != real_timer_get_counter_reg(1));