本文整理汇总了C++中RTC_GetTime函数的典型用法代码示例。如果您正苦于以下问题:C++ RTC_GetTime函数的具体用法?C++ RTC_GetTime怎么用?C++ RTC_GetTime使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTC_GetTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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);
}