2020-12-04 19:13:29 -05:00
|
|
|
/* uptime.1.c -- tells how long the system has been running
|
2020-12-02 22:15:47 -05:00
|
|
|
** Copyright (c) 2020 Renaud Fivet
|
|
|
|
**
|
|
|
|
** v1 displays the number of seconds elapsed since boot
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
extern volatile unsigned uptime ;
|
|
|
|
extern void kputc( unsigned char c) ;
|
|
|
|
|
|
|
|
void kputu( unsigned u) {
|
|
|
|
unsigned r = u % 10 ;
|
|
|
|
u /= 10 ;
|
|
|
|
if( u)
|
|
|
|
kputu( u) ;
|
|
|
|
|
|
|
|
kputc( '0' + r) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main( void) {
|
|
|
|
static unsigned last ;
|
|
|
|
|
|
|
|
for( ;;)
|
|
|
|
if( last != uptime) {
|
|
|
|
last = uptime ;
|
|
|
|
kputu( last) ;
|
|
|
|
puts( " sec") ;
|
|
|
|
} else
|
|
|
|
__asm( "WFI") ; /* Wait for System Tick Interrupt */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* end of uptime.1.c */
|