1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/native/rtc/posix-rtc.c

60 lines
1.1 KiB
C
Raw Normal View History

2013-03-06 01:08:15 +01:00
#include <time.h>
#include "debug.h"
#include <rtc.h>
static int native_rtc_enabled;
/**
* @brief Initializes the RTC for calendar mode
*/
void rtc_init(void)
{
native_rtc_enabled = 0;
printf("native rtc initialized\n");
}
/**
* @brief Starts the RTC
*/
void rtc_enable(void)
{
DEBUG("rtc_enable\n");
native_rtc_enabled = 1;
}
/**
* @brief Stops the RTC
*/
void rtc_disable(void)
{
DEBUG("rtc_disable()\n");
native_rtc_enabled = 0;
}
/**
* @brief Sets the current time in broken down format directly from to RTC
* @param[in] localt Pointer to structure with time to set
*/
void rtc_set_localtime(struct tm* localt)
{
DEBUG("rtc_set_localtime()\n");
printf("setting time not supported.");
}
/**
* @brief Returns the current time in broken down format directly from the RTC
* @param[out] localt Pointer to structure to receive time
*/
void rtc_get_localtime(struct tm* localt)
{
time_t t;
if(native_rtc_enabled == 1) {
t = time(NULL);
if (localtime_r(&t, localt) == NULL) {
err(1, "rtc_get_localtime: localtime_r");
}
}
}