1
0
mirror of https://github.com/rfivet/stm32bringup.git synced 2024-12-18 14:56:22 -05:00
stm32bringup/uptime.1.c

34 lines
653 B
C

/* uptime.1.c -- tells how long the system has been running
** 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 */