Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Niklas Roy
firmware
Commits
e94f7bf9
Commit
e94f7bf9
authored
5 years ago
by
Ferdinand Bachmann
Browse files
Options
Downloads
Patches
Plain Diff
epicardium/rtc: add monotonic time
parent
612772fa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
epicardium/epicardium.h
+20
-0
20 additions, 0 deletions
epicardium/epicardium.h
epicardium/modules/rtc.c
+20
-0
20 additions, 0 deletions
epicardium/modules/rtc.c
with
40 additions
and
0 deletions
epicardium/epicardium.h
+
20
−
0
View file @
e94f7bf9
...
@@ -81,6 +81,8 @@ typedef _Bool bool;
...
@@ -81,6 +81,8 @@ typedef _Bool bool;
#define API_RTC_SCHEDULE_ALARM 0x51
#define API_RTC_SCHEDULE_ALARM 0x51
#define API_RTC_SET_MILLISECONDS 0x52
#define API_RTC_SET_MILLISECONDS 0x52
#define API_RTC_GET_MILLISECONDS 0x53
#define API_RTC_GET_MILLISECONDS 0x53
#define API_RTC_GET_MONOTONIC_SECONDS 0x54
#define API_RTC_GET_MONOTONIC_MILLISECONDS 0x55
#define API_LEDS_SET 0x60
#define API_LEDS_SET 0x60
#define API_LEDS_SET_HSV 0x61
#define API_LEDS_SET_HSV 0x61
...
@@ -1693,6 +1695,24 @@ API(API_FILE_MKDIR, int epic_file_mkdir(const char *dirname));
...
@@ -1693,6 +1695,24 @@ API(API_FILE_MKDIR, int epic_file_mkdir(const char *dirname));
* ===
* ===
*/
*/
/**
* Get the monotonic time in seconds.
*
* :return: monotonic time in seconds
*/
API
(
API_RTC_GET_MONOTONIC_SECONDS
,
uint32_t
epic_rtc_get_monotonic_seconds
(
void
)
);
/**
* Get the monotonic time in ms.
*
* :return: monotonic time in milliseconds
*/
API
(
API_RTC_GET_MONOTONIC_MILLISECONDS
,
uint64_t
epic_rtc_get_monotonic_milliseconds
(
void
)
);
/**
/**
* Read the current RTC value.
* Read the current RTC value.
*
*
...
...
This diff is collapsed.
Click to expand it.
epicardium/modules/rtc.c
+
20
−
0
View file @
e94f7bf9
...
@@ -9,6 +9,18 @@
...
@@ -9,6 +9,18 @@
#include
<stdint.h>
#include
<stdint.h>
uint64_t
monotonic_offset
=
0
;
uint32_t
epic_rtc_get_monotonic_seconds
(
void
)
{
return
epic_rtc_get_seconds
()
+
monotonic_offset
/
1000ULL
;
}
uint64_t
epic_rtc_get_monotonic_milliseconds
(
void
)
{
return
epic_rtc_get_milliseconds
()
+
monotonic_offset
;
}
uint32_t
epic_rtc_get_seconds
(
void
)
uint32_t
epic_rtc_get_seconds
(
void
)
{
{
uint32_t
sec
,
subsec
;
uint32_t
sec
,
subsec
;
...
@@ -38,6 +50,9 @@ uint64_t epic_rtc_get_milliseconds(void)
...
@@ -38,6 +50,9 @@ uint64_t epic_rtc_get_milliseconds(void)
void
epic_rtc_set_milliseconds
(
uint64_t
milliseconds
)
void
epic_rtc_set_milliseconds
(
uint64_t
milliseconds
)
{
{
uint32_t
sec
,
subsec
;
uint32_t
sec
,
subsec
;
uint64_t
old_milliseconds
,
new_milliseconds
,
diff
;
old_milliseconds
=
epic_rtc_get_milliseconds
();
sec
=
milliseconds
/
1000
;
sec
=
milliseconds
/
1000
;
subsec
=
(
milliseconds
%
1000
);
subsec
=
(
milliseconds
%
1000
);
...
@@ -48,6 +63,11 @@ void epic_rtc_set_milliseconds(uint64_t milliseconds)
...
@@ -48,6 +63,11 @@ void epic_rtc_set_milliseconds(uint64_t milliseconds)
;
;
while
(
RTC_EnableRTCE
(
MXC_RTC
)
==
E_BUSY
)
while
(
RTC_EnableRTCE
(
MXC_RTC
)
==
E_BUSY
)
;
;
new_milliseconds
=
epic_rtc_get_milliseconds
();
diff
=
old_milliseconds
-
new_milliseconds
;
monotonic_offset
+=
diff
;
}
}
void
RTC_IRQHandler
(
void
)
void
RTC_IRQHandler
(
void
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment