예제 #1
0
u8  Device_RTC_set(TDateTime now)
{
    rt_device_t device;

    RTC_DateStructure.RTC_Year = now.year;
    RTC_DateStructure.RTC_Month =now.month;  
    RTC_DateStructure.RTC_Date = now.day;   
    RTC_DateStructure.RTC_WeekDay=now.week;  
	

    	
    RTC_TimeStructure.RTC_Hours = now.hour;
    RTC_TimeStructure.RTC_Minutes = now.min;
    RTC_TimeStructure.RTC_Seconds 	= now.sec; 
  
    device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_DATE, &RTC_DateStructure);   
	 	
	    rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &RTC_TimeStructure);   	

		return 1;   
		
    }
		
		return 0;
}
예제 #2
0
파일: rtc.c 프로젝트: nodeboy/nodeboyRepo
void SetCurrentDateTime(CLOCK *clock)
{
    time_t now;
    struct tm* ti;
    rt_device_t device;

    ti = RT_NULL;

    /* get current time */
    time(&now);

    ti = localtime(&now);
    if (ti != RT_NULL)
    {
		ti->tm_year =   BCD2Char(clock->year) +100;
		ti->tm_mon 	= BCD2Char(clock->month )- 1; /* ti->tm_mon 	= month; 0~11 */
		ti->tm_mday = BCD2Char(clock->day);
		ti->tm_hour = BCD2Char(clock->hour);
		ti->tm_min 	= BCD2Char(clock->minute);
		ti->tm_sec 	= BCD2Char(clock->second);
    }

    now = mktime(ti);
    device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now);
    }
}
예제 #3
0
파일: rtc.c 프로젝트: nodeboy/nodeboyRepo
void set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day)
{
    time_t now;
    struct tm* ti;
    rt_device_t device;

    ti = RT_NULL;
    /* get current time */
    time(&now);

    ti = localtime(&now);
    if (ti != RT_NULL)
    {
        ti->tm_year = year - 1900;
        ti->tm_mon 	= month - 1; /* ti->tm_mon 	= month; 0~11 */
        ti->tm_mday = day;
    }

    now = mktime(ti);

    device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now);
    }
}
예제 #4
0
void set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second)
{
    time_t now;
    struct tm* ti;
    rt_device_t device;

    ti = RT_NULL;
    /* get current time */
    time(&now);

    ti = localtime(&now);
    if (ti != RT_NULL)
    {
        ti->tm_hour = hour;
        ti->tm_min 	= minute;
        ti->tm_sec 	= second;
    }

    now = mktime(ti);
    device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &now);
    }
}
예제 #5
0
void set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second)
{
	 rt_device_t device;

    RTC_TimeStructure.RTC_Hours = hour;
    RTC_TimeStructure.RTC_Minutes 	= minute;
    RTC_TimeStructure.RTC_Seconds 	= second;
    
  
    device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, &RTC_TimeStructure);
    }
}
예제 #6
0
파일: rtc.c 프로젝트: QiuGong/Terminal
static void per_get_time(void* parameter)
{
	rt_device_t device;
	
	memset(time_buf, 0x00, 6);
	device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, time_buf);
    }
	else
	{
		rt_kprintf("list date error\n");
	}
}
예제 #7
0
파일: rtc.c 프로젝트: QiuGong/Terminal
void list_date(void)
{
	rt_device_t device;
	rt_uint8_t buf[6];
	
	device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, buf);
		rt_kprintf("time:%02X %02X %02X %02X %02X %02X\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);
    }
	else
	{
		rt_kprintf("list date error\n");
	}   
}
예제 #8
0
void set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t date)
{
	 
	  rt_device_t device;

    RTC_DateStructure.RTC_Year = year;
    RTC_DateStructure.RTC_Month 	= month;
    RTC_DateStructure.RTC_Date 	= date;
    
  
    device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_DATE, &RTC_TimeStructure);  
    }
	
}
예제 #9
0
파일: rtc.c 프로젝트: QiuGong/Terminal
void set_rtc(rt_uint8_t year, rt_uint8_t mon, rt_uint8_t day, rt_uint8_t hour, rt_uint8_t min, rt_uint8_t sec)
{
   	rt_device_t device;
	rt_uint8_t buf[6];


	buf[0] = hex8_to_bcd8(year);buf[1] = hex8_to_bcd8(mon);buf[2] = hex8_to_bcd8(day);
	buf[3] = hex8_to_bcd8(hour);buf[4] = hex8_to_bcd8(min);buf[5] = hex8_to_bcd8(sec);

    device = rt_device_find("rtc");
    if (device != RT_NULL)
    {
        rt_rtc_control(device, RT_DEVICE_CTRL_RTC_SET_TIME, buf);
    }
	else
	{
		rt_kprintf("set date error\n");
	}
}