-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include/drivers: Add RTC support #52618
Changes from 1 commit
c4f0349
ae7bda8
4e3a8ed
db2e4fb
221558c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Copyright (c) 2022 Bjarki Arge Andreasen | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
zephyr_library() | ||
|
||
zephyr_library_sources_ifdef(CONFIG_USERSPACE rtc_handlers.c) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright (c) 2022 Bjarki Arge Andreasen | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
menuconfig RTC | ||
bool "RTC driver support" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would put "real time clock" in a help field here, just so that it is obvious to someone browsing Kconfig options without having to dive into the documentation |
||
|
||
if RTC | ||
|
||
config RTC_ALARM | ||
bool "RTC driver alarm support" | ||
help | ||
This is an option which enables driver support for RTC alarms. | ||
|
||
config RTC_UPDATE | ||
bool "RTC driver update event callback support" | ||
help | ||
This is an option which enables driver support for the RTC | ||
update event callback. | ||
|
||
config RTC_CALIBRATION | ||
bool "RTC driver clock calibration support" | ||
help | ||
This is an option which enables driver support for RTC clock | ||
calibration. | ||
Comment on lines
+9
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these really necessary? At some point, configuration options get too fine-grained. |
||
|
||
endif # RTC |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (c) 2022 Bjarki Arge Andreasen | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/drivers/rtc.h> | ||
#include <zephyr/syscall_handler.h> | ||
|
||
static inline int z_vrfy_rtc_set_time(const struct device *dev, const struct rtc_time *timeptr) | ||
{ | ||
Z_OOPS(Z_SYSCALL_DRIVER_RTC(dev, set_time)); | ||
Z_OOPS(Z_SYSCALL_MEMORY_READ(timeptr, sizeof(struct rtc_time))); | ||
return z_impl_rtc_set_time(dev, timeptr); | ||
} | ||
#include <syscalls/rtc_set_time_mrsh.c> | ||
|
||
static inline int z_vrfy_rtc_get_time(const struct device *dev, struct rtc_time *timeptr) | ||
{ | ||
Z_OOPS(Z_SYSCALL_DRIVER_RTC(dev, get_time)); | ||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(timeptr, sizeof(struct rtc_time))); | ||
return z_impl_rtc_get_time(dev, timeptr); | ||
} | ||
#include <syscalls/rtc_get_time_mrsh.c> | ||
|
||
#ifdef CONFIG_RTC_ALARM | ||
static inline int z_vrfy_rtc_alarm_get_supported_fields(const struct device *dev, uint16_t id, | ||
uint16_t *mask) | ||
{ | ||
Z_OOPS(Z_SYSCALL_DRIVER_RTC(dev, alarm_get_supported_fields)); | ||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(mask, sizeof(uint16_t))); | ||
return z_impl_rtc_alarm_get_supported_fields(dev, id, mask); | ||
} | ||
#include <syscalls/rtc_alarm_get_supported_fields_mrsh.c> | ||
|
||
static inline int z_vrfy_rtc_alarm_set_time(const struct device *dev, uint16_t id, uint16_t mask, | ||
const struct rtc_time *timeptr) | ||
{ | ||
Z_OOPS(Z_SYSCALL_DRIVER_RTC(dev, alarm_set_time)); | ||
Z_OOPS(Z_SYSCALL_MEMORY_READ(timeptr, sizeof(struct rtc_time))); | ||
return z_impl_rtc_alarm_set_time(dev, id, mask, timeptr); | ||
nordicjm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
#include <syscalls/rtc_alarm_set_time_mrsh.c> | ||
|
||
static inline int z_vrfy_rtc_alarm_get_time(const struct device *dev, uint16_t id, uint16_t *mask, | ||
struct rtc_time *timeptr) | ||
{ | ||
Z_OOPS(Z_SYSCALL_DRIVER_RTC(dev, alarm_get_time)); | ||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(mask, sizeof(uint16_t))); | ||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(timeptr, sizeof(struct rtc_time))); | ||
return z_impl_rtc_alarm_get_time(dev, id, mask, timeptr); | ||
} | ||
#include <syscalls/rtc_alarm_get_time_mrsh.c> | ||
|
||
static inline int z_vrfy_rtc_alarm_is_pending(const struct device *dev, uint16_t id) | ||
{ | ||
Z_OOPS(Z_SYSCALL_DRIVER_RTC(dev, alarm_is_pending)); | ||
return z_impl_rtc_alarm_is_pending(dev, id); | ||
} | ||
#include <syscalls/rtc_alarm_is_pending_mrsh.c> | ||
#endif /* CONFIG_RTC_ALARM */ | ||
|
||
#ifdef CONFIG_RTC_CALIBRATION | ||
static inline int z_vrfy_rtc_set_calibration(const struct device *dev, int32_t calibration) | ||
bjarki-andreasen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
Z_OOPS(Z_SYSCALL_DRIVER_RTC(dev, set_calibration)); | ||
return z_impl_rtc_set_calibration(dev, calibration); | ||
} | ||
|
||
#include <syscalls/rtc_set_calibration_mrsh.c> | ||
|
||
static inline int z_vrfy_rtc_get_calibration(const struct device *dev, int32_t *calibration) | ||
{ | ||
Z_OOPS(Z_SYSCALL_DRIVER_RTC(dev, get_calibration)); | ||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(calibration, sizeof(int32_t))); | ||
return z_impl_rtc_get_calibration(dev, calibration); | ||
} | ||
#include <syscalls/rtc_get_calibration_mrsh.c> | ||
#endif /* CONFIG_RTC_CALIBRATION */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.