sys_time_usleep(uint32_t us) & InitSysTimePeriodic() added

This commit is contained in:
Pascal Brisset
2007-10-05 09:54:11 +00:00
parent 350e96aea7
commit 4add6c17a0
2 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -1,8 +1,8 @@
#include "armVIC.h"
#include "sys_time.h"
uint32_t cpu_time_ticks;
uint32_t last_periodic_event;
#if defined ACTUATORS
#include ACTUATORS
+11 -2
View File
@@ -36,7 +36,7 @@
#include "led.h"
extern uint32_t cpu_time_ticks;
static uint32_t last_periodic_event;
extern uint32_t last_periodic_event;
void TIMER0_ISR ( void ) __attribute__((naked));
@@ -91,6 +91,8 @@ static inline void sys_time_init( void ) {
#define TIME_TICKS_PER_SEC SYS_TICS_OF_SEC(1)
#define InitSysTimePeriodic() last_periodic_event = T0TC;
static inline bool_t sys_time_periodic( void ) {
uint32_t now = T0TC;
uint32_t dif = now - last_periodic_event;
@@ -103,10 +105,17 @@ static inline bool_t sys_time_periodic( void ) {
#ifdef TIME_LED
LED_TOGGLE(TIME_LED)
#endif
}
}
return TRUE;
}
return FALSE;
}
/** Busy wait, in microseconds */
static inline void sys_time_usleep(uint32_t us) {
uint32_t start = T0TC;
uint32_t ticks = SYS_TICS_OF_USEC(us);
while ((uint32_t)(T0TC-start) < ticks);
}
#endif /* SYS_TIME_HW_H */