forked from timvideos/HDMI2USB-litex-firmware
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Moved uptime from pattern into own service. * Made pattern use uptime service. * Add uptime to ci.
- Loading branch information
Showing
6 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ OBJECTS=\ | |
tofe_eeprom.o \ | ||
version.o \ | ||
version_data.o \ | ||
uptime.o \ | ||
|
||
|
||
CFLAGS += \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <time.h> | ||
|
||
#include <generated/csr.h> | ||
|
||
#include "uptime.h" | ||
|
||
static int uptime_seconds = 0; | ||
void uptime_service(void) | ||
{ | ||
static int last_event; | ||
|
||
if(elapsed(&last_event, SYSTEM_CLOCK_FREQUENCY)) { | ||
uptime_seconds++; | ||
} | ||
} | ||
|
||
int uptime(void) | ||
{ | ||
return uptime_seconds; | ||
} | ||
|
||
void uptime_print(void) | ||
{ | ||
printf(uptime_str()); | ||
printf("\n\r"); | ||
} | ||
|
||
const char* uptime_str(void) | ||
{ | ||
static char buffer[16]; | ||
sprintf(buffer, "uptime %02d:%02d:%02d", | ||
(uptime_seconds/3600)%24, | ||
(uptime_seconds/60)%60, | ||
uptime_seconds%60); | ||
return buffer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef __UPTIME_H | ||
#define __UPTIME_H | ||
|
||
void uptime_service(void); | ||
int uptime(void); | ||
|
||
void uptime_print(void); | ||
const char* uptime_str(void); | ||
|
||
#endif /* __CONFIG_H */ |