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
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
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
card10
firmware
Merge requests
!61
Implement RTC Alarm
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Implement RTC Alarm
rahix/rtc
into
master
Overview
6
Commits
5
Pipelines
6
Changes
6
All threads resolved!
Show all comments
Merged
rahix
requested to merge
rahix/rtc
into
master
5 years ago
Overview
6
Commits
5
Pipelines
6
Changes
6
All threads resolved!
Show all comments
Expand
0
0
Merge request reports
Compare
master
version 5
ec000128
5 years ago
version 4
2c31a537
5 years ago
version 3
071a84e2
5 years ago
version 2
91f49d52
5 years ago
version 1
c5ca05df
5 years ago
master (base)
and
version 4
latest version
0d8be9c3
5 commits,
5 years ago
version 5
ec000128
5 commits,
5 years ago
version 4
2c31a537
3 commits,
5 years ago
version 3
071a84e2
3 commits,
5 years ago
version 2
91f49d52
2 commits,
5 years ago
version 1
c5ca05df
2 commits,
5 years ago
6 files
+
118
−
9
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
epicardium/modules/rtc.c
+
50
−
1
Options
#include
"epicardium.h"
#include
"modules/log.h"
#include
"api/interrupt-sender.h"
#include
"FreeRTOS.h"
#include
"task.h"
#include
"rtc.h"
#include
<stdint.h>
uint32_t
epic_rtc_get_seconds
(
void
)
{
return
RTC_GetSecond
();
uint32_t
sec
,
subsec
;
/*
* TODO: Find out what causes the weird behavior of this function. The
* time needed for this call seems to depend on the frequency at
* which it is called.
*/
while
(
RTC_GetTime
(
&
sec
,
&
subsec
)
==
E_BUSY
)
{
vTaskDelay
(
pdMS_TO_TICKS
(
4
));
}
return
sec
;
}
void
RTC_IRQHandler
(
void
)
{
int
flags
=
RTC_GetFlags
();
if
(
flags
&
MXC_F_RTC_CTRL_ALDF
)
{
RTC_ClearFlags
(
MXC_F_RTC_CTRL_ALDF
);
/* TODO: Fix interrupt triggering slightly early */
api_interrupt_trigger
(
EPIC_INT_RTC_ALARM
);
}
else
{
LOG_WARN
(
"rtc"
,
"Unknown IRQ catched!"
);
/* Disable IRQ so it does not retrigger */
NVIC_DisableIRQ
(
RTC_IRQn
);
}
}
int
epic_rtc_schedule_alarm
(
uint32_t
timestamp
)
{
int
res
;
NVIC_EnableIRQ
(
RTC_IRQn
);
while
((
res
=
RTC_SetTimeofdayAlarm
(
MXC_RTC
,
timestamp
))
==
E_BUSY
)
;
if
(
res
!=
E_SUCCESS
)
{
return
-
EINVAL
;
}
return
0
;
}
Loading