]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_FreedomStudio/freedom-metal/src/rtc.c
Update RISCC-V-RV32-SiFive_HiFive1_FreedomStudio project to latest tools and metal...
[freertos] / FreeRTOS / Demo / RISC-V_RV32_SiFive_HiFive1_FreedomStudio / freedom-metal / src / rtc.c
1 /* Copyright 2019 SiFive, Inc. */
2 /* SPDX-License-Identifier: Apache-2.0 */
3
4 #include <metal/machine.h>
5 #include <metal/rtc.h>
6
7 #include <stddef.h>
8
9 extern inline uint64_t metal_rtc_get_rate(const struct metal_rtc *const rtc);
10 extern inline uint64_t metal_rtc_set_rate(const struct metal_rtc *const rtc, const uint64_t rate);
11 extern inline uint64_t metal_rtc_get_compare(const struct metal_rtc *const rtc);
12 extern inline uint64_t metal_rtc_set_compare(const struct metal_rtc *const rtc, const uint64_t compare);
13 extern inline uint64_t metal_rtc_get_count(const struct metal_rtc *const rtc);
14 extern inline uint64_t metal_rtc_set_count(const struct metal_rtc *const rtc, const uint64_t count);
15 extern inline int metal_rtc_run(const struct metal_rtc *const rtc, const enum metal_rtc_run_option option);
16 extern inline struct metal_interrupt *metal_rtc_get_interrupt(const struct metal_rtc *const rtc);
17 extern inline int metal_rtc_get_interrupt_id(const struct metal_rtc *const rtc);
18
19 struct metal_rtc *metal_rtc_get_device(int index) {
20 #ifdef __METAL_DT_MAX_RTCS
21     if (index < __METAL_DT_MAX_RTCS) {
22         return (struct metal_rtc *) __metal_rtc_table[index];
23     }
24 #endif
25     return NULL;
26 }
27