本文整理汇总了C++中RTC_GetTime函数的典型用法代码示例。如果您正苦于以下问题:C++ RTC_GetTime函数的具体用法?C++ RTC_GetTime怎么用?C++ RTC_GetTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTC_GetTime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: UB_RTC_GetClock
//--------------------------------------------------------------
// RTC auslesen
// nach dem Aufruf steht die aktuelle Uhrzeit
// und das Datum in der Struktur "UB_RTC"
// format : [RTC_DEC, RTC_HEX]
//--------------------------------------------------------------
void UB_RTC_GetClock(RTC_FORMAT_t format)
{
// Zeit auslesen
if(format==RTC_DEC) {
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
}
else {
RTC_GetTime(RTC_Format_BCD, &RTC_TimeStructure);
}
UB_RTC.std = RTC_TimeStructure.RTC_Hours;
UB_RTC.min = RTC_TimeStructure.RTC_Minutes;
UB_RTC.sek = RTC_TimeStructure.RTC_Seconds;
// Datum auslesen
if(format==RTC_DEC) {
RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);
}
else {
RTC_GetDate(RTC_Format_BCD, &RTC_DateStructure);
}
UB_RTC.tag = RTC_DateStructure.RTC_Date;
UB_RTC.monat = RTC_DateStructure.RTC_Month;
UB_RTC.jahr = RTC_DateStructure.RTC_Year;
UB_RTC.wotag = RTC_DateStructure.RTC_WeekDay;
}
开发者ID:hosentraeger,项目名称:STM32F4D-Coocox-Lightboxx,代码行数:32,代码来源:stm32_ub_rtc.c
示例2: UB_RTC_GetClock
//--------------------------------------------------------------
// RTC auslesen
// nach dem Aufruf steht die aktuelle Uhrzeit
// und das Datum in der Struktur "UB_RTC"
// format : [RTC_DEC, RTC_HEX]
//--------------------------------------------------------------
RTC_t UB_RTC_GetClock(RTC_FORMAT_t format)
{
RTC_t time;
// Zeit auslesen
if(format==RTC_DEC) {
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
}
else {
RTC_GetTime(RTC_Format_BCD, &RTC_TimeStructure);
}
time.std = RTC_TimeStructure.RTC_Hours;
time.min = RTC_TimeStructure.RTC_Minutes;
time.sek = RTC_TimeStructure.RTC_Seconds;
// Datum auslesen
if(format==RTC_DEC) {
RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);
}
else {
RTC_GetDate(RTC_Format_BCD, &RTC_DateStructure);
}
time.tag = RTC_DateStructure.RTC_Date;
time.monat = RTC_DateStructure.RTC_Month;
time.jahr = RTC_DateStructure.RTC_Year;
time.wotag = RTC_DateStructure.RTC_WeekDay;
return time;
}
开发者ID:Jinzuu,项目名称:wc_ws,代码行数:34,代码来源:stm32_ub_rtc.c
示例3: TM_RTC_GetDateTime
void TM_RTC_GetDateTime(TM_RTC_Time_t* data, TM_RTC_Format_t format) {
uint32_t unix;
/* Get time */
if (format == TM_RTC_Format_BIN) {
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
} else {
RTC_GetTime(RTC_Format_BCD, &RTC_TimeStruct);
}
data->hours = RTC_TimeStruct.RTC_Hours;
data->minutes = RTC_TimeStruct.RTC_Minutes;
data->seconds = RTC_TimeStruct.RTC_Seconds;
/* Get date */
if (format == TM_RTC_Format_BIN) {
RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct);
} else {
RTC_GetDate(RTC_Format_BCD, &RTC_DateStruct);
}
data->year = RTC_DateStruct.RTC_Year;
data->month = RTC_DateStruct.RTC_Month;
data->date = RTC_DateStruct.RTC_Date;
data->day = RTC_DateStruct.RTC_WeekDay;
/* Calculate unix offset */
unix = TM_RTC_GetUnixTimeStamp(data);
data->unix = unix;
}
开发者ID:Mars55,项目名称:stm32f429,代码行数:30,代码来源:tm_stm32f4_rtc.c
示例4: RTC_time_GetUnixtime
uint32_t RTC_time_GetUnixtime(void) {
uint32_t t;
uint16_t days = days_from_2000(RTC_GetTime (LPC_RTC, RTC_TIMETYPE_YEAR), RTC_GetTime (LPC_RTC, RTC_TIMETYPE_MONTH), RTC_GetTime (LPC_RTC, RTC_TIMETYPE_DAYOFMONTH));
t = time2long(days, RTC_GetTime (LPC_RTC, RTC_TIMETYPE_HOUR), RTC_GetTime (LPC_RTC, RTC_TIMETYPE_MINUTE), RTC_GetTime (LPC_RTC, RTC_TIMETYPE_SECOND));
t += SECONDS_FROM_1970_TO_2000; // seconds from 1970 to 2000
return t;
}
开发者ID:webgou,项目名称:Equinox-Clock,代码行数:7,代码来源:rtc.cpp
示例5: rtcTimeNow
static long rtcTimeNow()
{
RTC_TimeTypeDef time;
RTC_DateTypeDef date;
RTC_TimeTypeDef time2;
RTC_DateTypeDef date2;
uint32_t ss;
uint32_t ss2;
struct tm t;
// RTC is in BYPSHAD mode. Read the registers twice.
RTC_GetTime(RTC_Format_BIN, &time);
RTC_GetDate(RTC_Format_BIN, &date);
ss = RTC_GetSubSecond();
RTC_GetTime(RTC_Format_BIN, &time2);
RTC_GetDate(RTC_Format_BIN, &date2);
ss2 = RTC_GetSubSecond();
// Check read values. If they match, read was ok. Otherwise read third time.
if (ss != ss2 ||
time.RTC_Seconds != time2.RTC_Seconds ||
time.RTC_Minutes != time2.RTC_Minutes ||
time.RTC_Hours != time2.RTC_Hours ||
date.RTC_Date != date2.RTC_Date ||
date.RTC_Month != date2.RTC_Month ||
date.RTC_Year != date2.RTC_Year) {
RTC_GetTime(RTC_Format_BIN, &time);
RTC_GetDate(RTC_Format_BIN, &date);
ss = RTC_GetSubSecond();
}
memset(&t, '\0', sizeof(t));
t.tm_sec = time.RTC_Seconds;
t.tm_min = time.RTC_Minutes;
t.tm_hour = time.RTC_Hours;
t.tm_mday = date.RTC_Date;
t.tm_mon = date.RTC_Month - 1;
t.tm_year = date.RTC_Year + 2000 - 1900;
time_t secs;
long msecs;
secs = mktime(&t);
msecs = 1000 - (ss * 1000 / 1024);
return 1000 * secs + msecs;
}
开发者ID:AriZuu,项目名称:picoos,代码行数:50,代码来源:tick_rtc.c
示例6: rtc_callback
/***************************************************************************//*!
* @brief RTC Callback function (second interrupt, alarm interrupt).
******************************************************************************/
void rtc_callback (RTC_CALLBACK_TYPE type)
{
if (type == TAF_CALLBACK)
{
RTC_SetAlarm (RTC_GetTime()+alarm_interval);
GPIO_Tgl (GPIOE, PIN_31);
}
if (type == TSF_CALLBACK)
{
RTC_GmTime (RTC_GetTime(),&time);
lcd_settime(&time);
GPIO_Tgl (GPIOD, PIN_5);
}
}
开发者ID:Capstone46,项目名称:Freescale,代码行数:17,代码来源:frdm_rtc_watch_test.c
示例7: RTC_TimeShow
/**
* @brief Display the current time on the Hyperterminal.
* @param None
* @retval None
*/
void RTC_TimeShow(void)
{
RTC_TimeStructInit(&RTC_TimeStructure);
/* Get the current Time */
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
printf("\n\r The current time is : %0.2d:%0.2d:%0.2d \n\r", RTC_TimeStructure.RTC_Hours, RTC_TimeStructure.RTC_Minutes, RTC_TimeStructure.RTC_Seconds);
}
开发者ID:clarenceliu,项目名称:Mplib,代码行数:12,代码来源:RTC_Calendar_Example.c
示例8: main
/* start the main program */
void main()
{
unsigned char sec,min,hour,day,month,year;
/* Initialize the lcd before displaying any thing on the lcd */
LCD_Init(8,2,16);
/* Initialize the RTC(ds1307) before reading or writing time/date */
RTC_Init();
/*##### Set the time and Date only once. Once the Time and Date is set, comment these lines
and reflash the code. Else the time will be set every time the controller is reset*/
RTC_SetTime(0x10,0x40,0x00); // 10:40:20 am
RTC_SetDate(0x01,0x01,0x15); // 1st Jan 2015
/* Display the Time and Date continuously */
while(1)
{
LCD_GoToLine(1);
/* Read the Time from RTC(ds1307) */
RTC_GetTime(&hour,&min,&sec);
/* Read the Date from RTC(ds1307) */
RTC_GetDate(&day,&month,&year);
LCD_Printf("\n\rtime:%2x:%2x:%2x \nDate:%2x/%2x/%2x",(uint16_t)hour,(uint16_t)min,(uint16_t)sec,(uint16_t)day,(uint16_t)month,(uint16_t)year);
}
}
开发者ID:Amritach,项目名称:Code-Libraries,代码行数:34,代码来源:main.c
示例9: EnterSTANDBYMode
/**
* @brief Enters STANDBY mode, RTC Alarm within 3 second or an external RESET
* will wake-up the system from STANDBY
* @param None
* @retval None
*/
static void EnterSTANDBYMode(void)
{
RTC_AlarmTypeDef RTC_AlarmStructure;
RTC_TimeTypeDef RTC_TimeStructure;
/* Disable the Alarm A */
RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
/* Get the current time */
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
/* Set the alarm to current time + 3s */
RTC_AlarmStructure.RTC_AlarmTime.RTC_H12 = RTC_TimeStructure.RTC_H12;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours = RTC_TimeStructure.RTC_Hours;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = RTC_TimeStructure.RTC_Minutes;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = (RTC_TimeStructure.RTC_Seconds + 0x3) % 60;
RTC_AlarmStructure.RTC_AlarmDateWeekDay = 31;
RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay | RTC_AlarmMask_Hours | RTC_AlarmMask_Minutes;
RTC_SetAlarm(RTC_Format_BIN, RTC_Alarm_A, &RTC_AlarmStructure);
/* Enable RTC Alarm A Interrupt: this Interrupt will wake-up the system from
STANDBY mode (RTC Alarm IT not enabled in NVIC) */
RTC_ITConfig(RTC_IT_ALRA, ENABLE);
/* Enable the Alarm A */
RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
/* Clear RTC Alarm Flag */
RTC_ClearFlag(RTC_FLAG_ALRAF);
/* Request to enter STANDBY mode (Wake Up flag is cleared in PWR_EnterSTANDBYMode function) */
PWR_EnterSTANDBYMode();
}
开发者ID:yogiyi,项目名称:BP_STM32F030,代码行数:40,代码来源:main.c
示例10: Time_Show
void Time_Show(uint8_t Line, uint8_t pos)
{
/* Wait until the calendar is synchronized */
while (RTC_WaitForSynchro() != SUCCESS);
/* Get the current subsecond Time*/
Subsecondvalue = RTC_GetSubSecond();
/* Wait until the calendar is synchronized */
while (RTC_WaitForSynchro() != SUCCESS);
/* Get the current Time*/
RTC_GetTime(RTC_Format_BCD, &RTC_TimeStr);
Mstime = 999 - ((uint32_t)((uint32_t)Subsecondvalue * 1000) / (uint32_t)RTC_InitStr.RTC_SynchPrediv);
Ms100 = (uint8_t)(Mstime / 100);
Ms10 = (uint8_t)((Mstime % 100 ) / 10);
Ms1 = (uint8_t)(Mstime % 10);
/* Fill the LCDString fields with the current Time : second and milliseconds*/
LCDStringTime[pos] = (uint8_t)(((uint8_t)(RTC_TimeStr.RTC_Seconds & 0xF0) >> 4) + ASCII_NUM_0);
LCDStringTime[pos+1] = (uint8_t)(((uint8_t)(RTC_TimeStr.RTC_Seconds & 0x0F)) + ASCII_NUM_0);
LCDStringTime[pos+3] = (uint8_t)((uint8_t)(Ms100 + ASCII_NUM_0));
LCDStringTime[pos+4] = (uint8_t)((uint8_t)(Ms10 + ASCII_NUM_0));
LCDStringTime[pos+5] = (uint8_t)((uint8_t)(Ms1 + ASCII_NUM_0));
/* Print the Time Calendar on the LCD*/
LCD_SetCursorPos(Line, 0);
LCD_Print((uint8_t*)LCDStringTime);
}
开发者ID:avr-master,项目名称:Healty_Beck,代码行数:33,代码来源:main.c
示例11: _gettimeofday
int _gettimeofday(struct timeval *ptimeval, void *ptimezone)
{
RTC_DATE date;
RTC_TIME time;
struct tm tm;
time_t now;
// Read current date and time from the RTC
RTC_GetDate(BINARY, &date);
RTC_GetTime(BINARY, &time);
// Get the date again if the current time is 00:00:00 (Midnight)
if ((time.hours == 0) && (time.minutes == 0) && (time.seconds == 0))
RTC_GetDate(BINARY, &date);
// Convert current date and time to time_t
memset(&tm, 0, sizeof(struct tm));
tm.tm_sec = time.seconds;
tm.tm_min = time.minutes;
tm.tm_hour = time.hours;
tm.tm_mday = date.day;
tm.tm_mon = date.month - 1;
tm.tm_year = date.century*100 + date.year - 1900;
now = rep_timegm(&tm);
// Convert current date and time to struct timeval
memset(ptimeval, 0, sizeof(struct timeval));
ptimeval->tv_sec = now;
return 0;
}
开发者ID:zgramana,项目名称:arm-mcu,代码行数:35,代码来源:time.c
示例12: main
/* start the main program */
void main()
{
unsigned char sec,min,hour,day,month,year;
/* Initilize the Uart before Transmiting/Reaceiving any data */
UART_Init(9600);
/* Initilize the RTC(ds1307) before reading or writing time/date */
RTC_Init();
UART_TxString(" Testing RTC ");
/*##### Set the time and Date only once. Once the Time and Date is set, comment these lines
and reflash the code. Else the time will be set every time the controller is reset*/
RTC_SetTime(0x10,0x40,0x00); // 10:40:20 am
RTC_SetDate(0x01,0x01,0x15); // 1st Jan 2015
/* Display the Time and Date continuously */
while(1)
{
/* Read the Time from RTC(ds1307) */
RTC_GetTime(&hour,&min,&sec);
/* Read the Date from RTC(ds1307) */
RTC_GetDate(&day,&month,&year);
UART_Printf("\n\r the time is :%2x:%2x:%2x \nDate:%2x/%2x/%2x",(uint16_t)hour,(uint16_t)min,(uint16_t)sec,(uint16_t)day,(uint16_t)month,(uint16_t)year);
}
}
开发者ID:Rajusr70,项目名称:AT89S52_Ultra_Development_Kit,代码行数:32,代码来源:main.c
示例13: get_sensors_state
void get_sensors_state(){
if(PIN_STATE(WATER_LEVER_SENSOR)) {
if(regim == DISPLAY_REGIM_DEFAULT)
{regim = DISPLAY_REGIM_NO_WATER;}
PIN_ON(NO_WATER_LED);
PIN_OFF(WATERING_RELAY);
}else{
if(PIN_STATE(NO_WATER_LED)) {PIN_OFF(NO_WATER_LED);}
}
if(PIN_STATE(LIGHT_SENSOR)) {
//датчик естественного света - выключаем досветку
if(PIN_STATE(LIGHT_RELAY)) {PIN_OFF(LIGHT_RELAY);}
}else{
//текущее врем¤ в разрешенном диапазоне использовани¤ досветки
RTCTIME rtc_clock;
RTC_GetTime(&rtc_clock);
u16 now_time = set_low_n_height(rtc_clock.hour, rtc_clock.min); //текущее врем¤ (часы+минуты)
//но в заданный промежуток времени
if (BKP_ReadBackupRegister(tMORNING_LIGHT_TIME_BKP) < now_time &&
now_time < BKP_ReadBackupRegister(tEVENING_LIGHT_TIME_BKP)) //с утра до вечера
{
PIN_ON(LIGHT_RELAY);
}
}
}
开发者ID:drovosekov,项目名称:AutoWatering,代码行数:28,代码来源:getRegim.c
示例14: CreateNewJob
u8 CreateNewJob(void)
{
// ÇöÀç ³¯Â¥, ½Ã°£
RTC_DateTypeDef RTC_DateStruct;
RTC_TimeTypeDef RTC_TimeStruct;
RTC_GetDate(RTC_Format_BIN, &RTC_DateStruct);
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStruct);
// JOB ä¿ì±â
JOB_INFO info = { "NEW JOB",
gxFileCount + 1, 0, 0,
RTC_DateStruct.RTC_Year,
RTC_DateStruct.RTC_Month,
RTC_DateStruct.RTC_Date,
RTC_TimeStruct.RTC_Hours,
RTC_TimeStruct.RTC_Minutes,
RTC_TimeStruct.RTC_Seconds,
};
// "NEW JOB", NULL};
// ÆÄÀÏ »ý¼º
SaveJobData(info, NULL, gxFileCount);
u32 selValue = ++gxFileCount % PAGE_JOB_COUNT;
gJobPageNo = (gxFileCount / PAGE_JOB_COUNT) + (selValue != 0 ? 1 : 0);
gPreJobMgrMenu = (TSA_JOB_MGR_MENU)((u16)(JM_SEL1 - 1) + (selValue != 0 ? selValue : PAGE_JOB_COUNT));
if(gJobMgrMenu >= JM_SEL1 && gJobMgrMenu <= JM_SEL12) gIsJobNotPlaySound = TRUE;
return TRUE;
}
开发者ID:eloiz07,项目名称:DPC_Touch,代码行数:31,代码来源:sJobMgr.c
示例15: DispTime
static void DispTime(void)
{
RTC_TIME Time;
char TimeMsg[64];
GUI_REGION DrawRegion;
if(Gui_GetBgLightVal()==0) return;//背光没亮,无需更新
RTC_GetTime(&Time);
sprintf(TimeMsg,"%02d月%02d日 周%s",Time.mon,Time.day,Week[Time.week]);
DrawRegion.x=0;
DrawRegion.y=0;
DrawRegion.w=240;
DrawRegion.h=18;
DrawRegion.Color=FatColor(NO_TRANS);
Gui_Draw24Bmp("Theme/F/MainPage/Bg/A01.Bmp",&DrawRegion);
DrawRegion.x=4;
DrawRegion.y=4;
DrawRegion.w=120;
DrawRegion.h=16;
DrawRegion.Space=0x11;
DrawRegion.Color=FatColor(0xf2f2f2);
Gui_DrawFont(GBK12_FONT,(void *)TimeMsg,&DrawRegion);
DrawRegion.x=200;
DrawRegion.Space=0x00;
sprintf(TimeMsg,"%02d:%02d",Time.hour,Time.min);
Gui_DrawFont(GBK12_FONT,(void *)TimeMsg,&DrawRegion);
}
开发者ID:beartan,项目名称:q-sys,代码行数:31,代码来源:MainPage.c
示例16: MicoRtcGetTime
/**
* This function will return the value of time read from the on board CPU real time clock. Time value must be given in the format of
* the structure wiced_rtc_time_t
*
* @return WICED_SUCCESS : on success.
* @return WICED_ERROR : if an error occurred with any step
*/
OSStatus MicoRtcGetTime(mico_rtc_time_t* time)
{
#ifdef MICO_ENABLE_MCU_RTC
RTC_TimeTypeDef rtc_read_time;
RTC_DateTypeDef rtc_read_date;
if( time == 0 )
{
return kParamErr;
}
/* save current rtc time */
RTC_GetTime( RTC_Format_BIN, &rtc_read_time );
RTC_GetDate( RTC_Format_BIN, &rtc_read_date );
/* fill structure */
time->sec = rtc_read_time.RTC_Seconds;
time->min = rtc_read_time.RTC_Minutes;
time->hr = rtc_read_time.RTC_Hours;
time->weekday = rtc_read_date.RTC_WeekDay;
time->date = rtc_read_date.RTC_Date;
time->month= rtc_read_date.RTC_Month;
time->year = rtc_read_date.RTC_Year;
return kNoErr;
#else /* #ifdef WICED_ENABLE_MCU_RTC */
UNUSED_PARAMETER(time);
return kUnsupportedErr;
#endif /* #ifdef WICED_ENABLE_MCU_RTC */
}
开发者ID:yantrabuddhi,项目名称:bootlaoder_EMW3165,代码行数:37,代码来源:MicoDriverRtc.c
示例17: RTC_IRQHandler
// Rutina de interrupción del RTC
void RTC_IRQHandler(void) {
static signed portBASE_TYPE param;
uint32_t sec;
// Verifica que haya una interrupción pendiente por incremento en el RTC
if (RTC_GetIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE)) {
// Limpia la interrupción pendiente
RTC_ClearIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE);
sec = RTC_GetTime(LPC_RTC, RTC_TIMETYPE_SECOND);
sumarSegundo();
//if (!(sec % INTERVALO_SEG)) { // PARA HACER CADA INTERVALOS DE MENOS DE UN MIN - REVISAR BIEN CÓDIGO
if (sec == 40) {
deshabilitar_int_rotativo();
} else if (sec == 50) {
param = pdFALSE;
xSemaphoreGiveFromISR(sem_calcula_temp, ¶m);// Libera semáforo
// En param se guardará pdTRUE si la liberación del semáforo desbloqueó una tarea
// y si esta tarea es de mayor prioridad a la tarea running actual.
portYIELD_FROM_ISR(param);// Si param=pdTRUE, se fuerza a un cambio de contexto
//printf("Cant: %d \n",timer0_cant);
//timer0_cant=0;
} else if (sec == 59) {
habilitar_int_rotativo();
}
}
}
开发者ID:matiasmascioto,项目名称:proyecto_temperatura_web,代码行数:34,代码来源:tp_rtc.c
示例18: Clock_GetTime
void Clock_GetTime(int* h, int* m, int* s)
{
RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);
*h = RTC_TimeStructure.RTC_Hours;
*m = RTC_TimeStructure.RTC_Minutes;
*s = RTC_TimeStructure.RTC_Seconds;
}
开发者ID:contemplator1998,项目名称:ADOS,代码行数:7,代码来源:RTC_Time.c
示例19: rtc_get
// Read the time from the RTC.
static int rtc_get( lua_State *L ) {
XMC_RTC_TIME_t t;
// Get the time.
RTC_GetTime( &t );
// Construct the table to return the result
lua_createtable( L, 0, 6 );
lua_pushstring( L, "sec" );
lua_pushinteger( L, t.seconds );
lua_rawset( L, -3 );
lua_pushstring( L, "min" );
lua_pushinteger( L, t.minutes );
lua_rawset( L, -3 );
lua_pushstring( L, "hour" );
lua_pushinteger( L, t.hours );
lua_rawset( L, -3 );
lua_pushstring( L, "day" );
lua_pushinteger( L, t.days );
lua_rawset( L, -3 );
lua_pushstring( L, "month" );
lua_pushinteger( L, t.month );
lua_rawset( L, -3 );
lua_pushstring( L, "year" );
lua_pushinteger( L, t.year );
lua_rawset( L, -3 );
return 1;
}
开发者ID:Lasitha78,项目名称:elua,代码行数:36,代码来源:rtc.c
示例20: time_main
void time_main(void *args)
{
char * datetime ;
RTC_TimeTypeDef RTC_Time ;
RTC_DateTypeDef RTC_Date ;
int year ;
if( args == NULL || ((func_args *)args)->argc == 1) {
RTC_GetTime(RTC_Format_BIN, &RTC_Time) ;
RTC_GetDate(RTC_Format_BIN, &RTC_Date) ;
printf("Date: %d/%d/%d, Time: %02d:%02d:%02d\n",
RTC_Date.RTC_Month, RTC_Date.RTC_Date, RTC_Date.RTC_Year+2000,
RTC_Time.RTC_Hours, RTC_Time.RTC_Minutes, RTC_Time.RTC_Seconds) ;
} else if(((func_args *)args)->argc == 3 &&
((func_args *)args)->argv[1][0] == '-' &&
((func_args *)args)->argv[1][1] == 'd' ) {
datetime = ((func_args *)args)->argv[2];
sscanf(datetime, "%d/%d/%d",
(int *)&RTC_Date.RTC_Month, (int *)&RTC_Date.RTC_Date, &year) ;
RTC_Date.RTC_Year = year - 2000 ;
RTC_Date.RTC_WeekDay = 0 ;
RTC_SetDate(RTC_Format_BIN, &RTC_Date) ;
} else if(((func_args *)args)->argc == 3 &&
((func_args *)args)->argv[1][0] == '-' &&
((func_args *)args)->argv[1][1] == 't' ) {
datetime = ((func_args *)args)->argv[2];
sscanf(datetime, "%d:%d:%d",
(int *)&RTC_Time.RTC_Hours,
(int *)&RTC_Time.RTC_Minutes,
(int *)&RTC_Time.RTC_Seconds
) ;
RTC_SetTime(RTC_Format_BIN, &RTC_Time) ;
} else printf("Invalid argument\n") ;
}
开发者ID:EvertYing,项目名称:cyassl,代码行数:33,代码来源:time-STM32F2xx.c
注:本文中的RTC_GetTime函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论