打印
[STM32F7]

请问:用mbed平台编程,这个例程RTC时间是如何计算的?

[复制链接]
901|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
caoqing|  楼主 | 2017-8-3 13:41 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 caoqing 于 2017-8-3 13:43 编辑

#include "mbed.h"

DigitalOut myled(LED1);

int main() {

    printf("RTC example\n");
    set_time(1387188323); // Set RTC time to 16 December 2013 10:05:23 UTC
    printf("Date and time are set.\n");

    while(1) {

        time_t seconds = time(NULL);

        //printf("Time as seconds since January 1, 1970 = %d\n", seconds);

        printf("Time as a basic string = %s", ctime(&seconds));

        //char buffer[32];
        //strftime(buffer, 32, "%I:%M:%S %p\n", localtime(&seconds));
        //printf("Time as a custom formatted string = %s", buffer);

        myled = !myled;      
        wait(1);
    }
}

为什么  1387188323 =  2013 10:05:23


沙发
caoqing|  楼主 | 2017-8-27 11:40 | 只看该作者
顶一下

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

74

主题

474

帖子

6

粉丝