Hardware Abstraction Layer for FreeRTOS
rtc_prv.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Author: Andreas Werner <kernel@andy89.org>
4  * Date: 2016
5  */
6 #ifndef RTC_PRV_
7 #define RTC_PRV_
8 #ifndef RTC_PRV
9 # error "Never include this file out of a RTC driver"
10 #endif
11 #include <FreeRTOS.h>
12 #include <semphr.h>
13 #include <stdint.h>
14 #include <stdbool.h>
15 #include <hal.h>
16 #define RTC_ALREDY_INITED 1
17 int32_t rtc_genericInit(struct rtc *rtc);
18 #ifdef CONFIG_RTC_THREAD_SAVE
19 # define rtc_lock(u, w, e) HAL_LOCK(u, w, e)
20 # define rtc_unlock(u, e) HAL_UNLOCK(u, e)
21 #else
22 # define rtc_lock(u, w, e)
23 # define rtc_unlock(u, e)
24 #endif
25 #define RTC_ADDDEV(ns, p) HAL_ADDDEV(rtc, ns, p)
27 #define RTC_GET_DEV(index) HAL_GET_DEV(rtc, index)
28 #ifndef CONFIG_RTC_MULTI
29 # define RTC_OPS(ns)
30 # define RTC_INIT_DEV(ns)
31 
32 # define RTC_INIT(ns, index) struct rtc *rtc_init(uint32_t index)
33 # define RTC_DEINIT(ns, p) int32_t rtc_deinit(struct rtc *p)
34 # define RTC_ADJUST(ns, p, offset, waitime) int32_t rtc_adjust(struct rtc *p, struct timespec *offset, TickType_t waittime)
35 # define RTC_GET_TIME(ns, p, time, waittime) int32_t rtc_getTime(struct rtc *p, struct timespec *time, TickType_t waittime)
36 # define RTC_SET_TIME(ns, p, time, waittime) int32_t rtc_setTime(struct rtc *p, struct timespec *time, TickType_t waittime)
37 # define RTC_ADJUST_ISR(ns, p, offset) int32_t rtc_adjustISR(struct rtc *p, struct timespec *offset)
38 # define RTC_GET_TIME_ISR(ns, p, time) int32_t rtc_getTimeISR(struct rtc *p, struct timespec *time)
39 # define RTC_SET_TIME_ISR(ns, p, time) int32_t rtc_setTimeISR(struct rtc *p, struct timespec *time)
40 #else
41 # define RTC_OPS(ns) const struct rtc_ops ns##_rtc_ops = { \
42  .rtc_init = &ns##_rtc_init, \
43  .rtc_deinit = &ns##_rtc_deinit, \
44  .rtc_adjust = &ns##_rtc_adjust, \
45  .rtc_getTime = &ns##_rtc_getTime, \
46  .rtc_setTime = &ns##_rtc_setTime, \
47  .rtc_adjustISR = &ns##_rtc_adjustISR, \
48  .rtc_getTimeISR = &ns##_rtc_getTimeISR, \
49  .rtc_setTimeISR = &ns##_rtc_setTimeISR, \
50 }
51 # define RTC_INIT_DEV(ns) .gen.ops = &ns##_rtc_ops,
52 # define RTC_INIT(ns, index) static struct rtc *ns##_rtc_init(uint32_t index)
53 # define RTC_DEINIT(ns, p) static int32_t ns##_rtc_deinit(struct rtc *p)
54 # define RTC_ADJUST(ns, p, offset, waitime) static int32_t ns##_rtc_adjust(struct rtc *p, struct timespec *offset, TickType_t waittime)
55 # define RTC_GET_TIME(ns, p, time, waittime) static int32_t ns##_rtc_getTime(struct rtc *p, struct timespec *time, TickType_t waittime)
56 # define RTC_SET_TIME(ns, p, time, waittime) static int32_t ns##_rtc_setTime(struct rtc *p, struct timespec *time, TickType_t waittime)
57 # define RTC_ADJUST_ISR(ns, p, offset) static int32_t ns##_rtc_adjustISR(struct rtc *p, struct timespec *offset)
58 # define RTC_GET_TIME_ISR(ns, p, time) static int32_t ns##_rtc_getTimeISR(struct rtc *p, struct timespec *time)
59 # define RTC_SET_TIME_ISR(ns, p, time) static int32_t ns##_rtc_setTimeISR(struct rtc *p, struct timespec *time)
60 #endif
61 #endif
62 
rtc_genericInit
int32_t rtc_genericInit(struct rtc *rtc)
hal.h
HAL_DEFINE_GLOBAL_ARRAY
HAL_DEFINE_GLOBAL_ARRAY(rtc)