1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/openLuat-luatos-soc-air101

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
luat_rtc_air101.c 1.5 КБ
Копировать Редактировать Исходные данные Просмотреть построчно История
Wendal Chen Отправлено 2 лет назад d4f2f6b
#include "luat_rtc.h"
#include "luat_msgbus.h"
#include "wm_rtc.h"
#include "time.h"
#define LUAT_LOG_TAG "rtc"
#include "luat_log.h"
static int luat_rtc_handler(lua_State *L, void* ptr) {
lua_getglobal(L, "sys_pub");
if (lua_isfunction(L, -1)) {
lua_pushstring(L, "RTC_IRQ");
lua_call(L, 1, 0);
}
return 0;
}
static void luat_rtc_cb(void *arg) {
//LLOGI("rtc irq");
rtos_msg_t msg;
msg.handler = luat_rtc_handler;
luat_msgbus_put(&msg, 0);
}
int luat_rtc_set(struct tm *tblock) {
if (tblock == NULL)
return -1;
tblock->tm_mon ++;
tls_set_rtc(tblock);
return 0;
}
int luat_rtc_get(struct tm *tblock) {
if (tblock == NULL)
return -1;
tls_get_rtc(tblock);
tblock->tm_mon --;
return 0;
}
int luat_rtc_timer_start(int id, struct tm *tblock) {
if (id || tblock == NULL)
return -1;
tls_rtc_isr_register(luat_rtc_cb, NULL);
tls_rtc_timer_start(tblock);
return 0;
}
int luat_rtc_timer_stop(int id) {
if (id)
return -1;
tls_rtc_timer_stop();
return 0;
}
int luat_rtc_timezone(int* timezone) {
return 32; // 暂不支持
}
void luat_rtc_set_tamp32(uint32_t tamp) {
time_t t;
t = tamp + (8*3600); // 固定东八区
struct tm *tblock = gmtime(&t);
luat_rtc_set(tblock);
}
time_t time(time_t* _tm)
{
struct tm tmt = {0};
tls_get_rtc(&tmt);
tmt.tm_mon --;
time_t t = mktime(&tmt);
if (_tm != NULL)
memcpy(_tm, &t, sizeof(time_t));
return t;
}
clock_t clock(void)
{
return (clock_t)time(NULL);
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://gitlife.ru/oschina-mirror/openLuat-luatos-soc-air101.git
git@gitlife.ru:oschina-mirror/openLuat-luatos-soc-air101.git
oschina-mirror
openLuat-luatos-soc-air101
openLuat-luatos-soc-air101
v0007.air103.v0016