MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_rtc_control

Function rt_rtc_control

bsp/efm32/drv_rtc.c:81–104  ·  view source on GitHub ↗

/ * @brief * Configure RTC device * * @details * * @note * * @param[in] dev * Pointer to device descriptor * * @param[in] cmd * RTC control command * * @param[in] args * Arguments * * @return * Error code ******************************************************************************/

Source from the content-addressed store, hash-verified

79 * Error code
80 ******************************************************************************/
81static rt_err_t rt_rtc_control(rt_device_t dev, int cmd, void *args)
82{
83 RT_ASSERT(dev != RT_NULL);
84
85 switch (cmd)
86 {
87 case RT_DEVICE_CTRL_RTC_GET_TIME:
88 *(time_t *)args = rtc_time + RTC_CounterGet();
89 rtc_debug("RTC: get rtc_time %x + %x\n", rtc_time, RTC_CounterGet());
90 break;
91
92 case RT_DEVICE_CTRL_RTC_SET_TIME:
93 {
94 rtc_time = *(time_t *)args;
95 rtc_debug("RTC: set rtc_time %x\n", rtc_time);
96
97 /* Reset counter */
98 RTC_CounterReset();
99 }
100 break;
101 }
102
103 return RT_EOK;
104}
105
106/***************************************************************************//**
107 * @brief

Callers

nothing calls this directly

Calls 2

RTC_CounterGetFunction · 0.85
RTC_CounterResetFunction · 0.85

Tested by

no test coverage detected