本文整理汇总了C++中rtc_get_time函数的典型用法代码示例。如果您正苦于以下问题:C++ rtc_get_time函数的具体用法?C++ rtc_get_time怎么用?C++ rtc_get_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rtc_get_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ovenctl_execute_control_step
/**
* \brief Execute oven control step.
*
* This function takes information from the user interface, temperature sensor
* and plate (QTouch) sensing and controls the output to the induction elements
* via a frequency signal.
*
* The oven has three states:
* - POWER_OFF where we just wait for input from the user interface to turn
* on.
* - ON_NO_POT where the user has indicated that power should be applied, but
* there is no pot in the plate. A safety timer changes the state back to
* POWER_OFF.
* - ON_ACTUATING where we have a pot on the oven, and actuate the induction
* elements while waiting for user input, and check if there is a pot on
* the oven.
*
* \param time Current system time in milliseconds.
* \param *wattage Pointer to the variable representing the desired effect
* \param *power Pointer to the variable controlling whether the induction
* coils should be actuated.
* \param potstate A variable representing the latest information on whether
* anything is present on the plate (QTouch sensor)
*/
void ovenctl_execute_control_step(uint32_t time, uint8_t *wattage, bool *power,
enum pot_t potstate)
{
/* Current state of the oven */
static enum ovenctl_plate_state plate_control_state = POWER_OFF;
static uint32_t time_pot_off = 0;
switch (plate_control_state) {
case POWER_OFF:
/* If the user has requested that the power be turned on,
* run Class B tests and go to ON_NO_POT
*/
if (*wattage > 0) {
ovenctl_turn_on_plate();
time_pot_off = rtc_get_time();
plate_control_state = ON_NO_POT;
}
break;
case ON_NO_POT:
/* If too long has passed without pot on the plate, turn off
* oven
*/
if ((rtc_get_time() - time_pot_off) > (20 * 1000)) {
ovenctl_turn_off_plate(wattage, power);
plate_control_state = POWER_OFF;
/* If user turned off power, turn off power. */
} else if (*wattage == 0) {
ovenctl_turn_off_plate(wattage, power);
plate_control_state = POWER_OFF;
/* If pot is put back before timeout, go back to active mode */
} else if (potstate == POT_ON) {
*power = true;
plate_control_state = ON_ACTUATING;
}
break;
case ON_ACTUATING:
/* Check if pot is on. If it is not, go to inactive mode. */
if (potstate == POT_OFF) {
*power = false;
time_pot_off = rtc_get_time();
plate_control_state = ON_NO_POT;
/* If user turned off power, turn off power. */
} else if (*wattage == 0) {
ovenctl_turn_off_plate(wattage, power);
plate_control_state = POWER_OFF;
}
break;
}
/* Update the output signal to the induction element according to
* selected power level, and whether power should be applied.
*/
ovenctl_actuate_induction_element(*power ? *wattage : 0);
}
示例2: rtc_show_configuration
/**
* rtc_show_configuration - output configuration to uart
*/
void rtc_show_configuration(void)
{
uart_send_text_sram("Time: ");
uint8_t i;
char time[3][3];
for (i = RTC_SECOND; i < (RTC_SECOND + 3); i++) {
uint8_t time_temp;
rtc_get_time(i, &time_temp);
int_to_string_fixed_length(time[i], 3, time_temp);
}
uart_send_text_buffer(time[2]);
uart_send_text_sram(":");
uart_send_text_buffer(time[1]);
uart_send_text_sram(":");
uart_send_text_buffer(time[0]);
UART_NEWLINE();
uart_send_text_sram("Date: ");
for (i = RTC_DATE; i < (RTC_DATE + 3); i++) {
uint8_t time_temp;
rtc_get_time(i, &time_temp);
int_to_string_fixed_length(time[i - RTC_DATE], 3, time_temp);
}
uart_send_text_sram("20");
uart_send_text_buffer(time[2]);
uart_send_text_sram("-");
uart_send_text_buffer(time[1]);
uart_send_text_sram("-");
uart_send_text_buffer(time[0]);
UART_NEWLINE();
}
示例3: rtc_clear_alarmed
/**
* Initialize the system controller. In particular:
* - Load settings
* - Setup the log interval alarm.
*/
Controller::Controller() {
m_sleeping=false;
m_powerup=false;
//m_log_interval_seconds = 60*30;
m_log_interval_seconds = 0; // default set to zero to save power
rtc_clear_alarmed();
rtc_enable_alarm(RTC);
m_interval_stored = rtc_get_time(RTC);
m_counts_stored = 0;
m_alarm_log = false;
system_controller = this;
m_last_switch_state = true;
m_never_dim = false;
bool sstate = switch_state();
m_last_switch_state = sstate;
m_warning_raised = false;
m_dim_off = false;
m_cpm_cps_switch = false;
m_current_units = 2;
m_cpm_cps_threshold = 1100.0;
m_cps_cpm_threshold = 1000.0;
// Get warning cpm from flash
m_warncpm = 0;
const char *swarncpm = flashstorage_keyval_get("WARNCPM");
if(swarncpm != 0) {
int32_t c;
sscanf(swarncpm, "%"PRIu32"", &c);
m_warncpm = c;
}
// Get never dim from flash
m_warncpm = -1;
const char *sneverdim = flashstorage_keyval_get("NEVERDIM");
if(sneverdim != 0) {
if(strcmp(sneverdim,"true") == 0) m_never_dim=true;
else m_never_dim=false;
} else m_never_dim=false;
if(m_never_dim) tick_item("Never Dim" ,true);
// Get logging interval from flash
const char *sloginter = flashstorage_keyval_get("LOGINTERVAL");
if(sloginter != 0) {
int32_t c;
sscanf(sloginter, "%"PRIu32"", &c);
m_log_interval_seconds = c;
} else {
// m_log_interval_seconds = 30*60;
m_log_interval_seconds = 0; // default set to zero to save power
}
rtc_set_alarm(RTC,rtc_get_time(RTC)+m_log_interval_seconds);
}
示例4: tmu_timer_get_frequency
/*
* Hah! We'll see if this works (switching from usecs to nsecs).
*/
static unsigned long tmu_timer_get_frequency(void)
{
u32 freq;
struct timespec ts1, ts2;
unsigned long diff_nsec;
unsigned long factor;
/* Setup the timer: We don't want to generate interrupts, just
* have it count down at its natural rate.
*/
ctrl_outb(0, TMU_TSTR);
#if !defined(CONFIG_CPU_SUBTYPE_SH7300) && !defined(CONFIG_CPU_SUBTYPE_SH7760)
ctrl_outb(TMU_TOCR_INIT, TMU_TOCR);
#endif
ctrl_outw(TMU0_TCR_CALIB, TMU0_TCR);
ctrl_outl(0xffffffff, TMU0_TCOR);
ctrl_outl(0xffffffff, TMU0_TCNT);
rtc_get_time(&ts2);
do {
rtc_get_time(&ts1);
} while (ts1.tv_nsec == ts2.tv_nsec && ts1.tv_sec == ts2.tv_sec);
/* actually start the timer */
ctrl_outb(TMU_TSTR_INIT, TMU_TSTR);
do {
rtc_get_time(&ts2);
} while (ts1.tv_nsec == ts2.tv_nsec && ts1.tv_sec == ts2.tv_sec);
freq = 0xffffffff - ctrl_inl(TMU0_TCNT);
if (ts2.tv_nsec < ts1.tv_nsec) {
ts2.tv_nsec += 1000000000;
ts2.tv_sec--;
}
diff_nsec = (ts2.tv_sec - ts1.tv_sec) * 1000000000 + (ts2.tv_nsec - ts1.tv_nsec);
/* this should work well if the RTC has a precision of n Hz, where
* n is an integer. I don't think we have to worry about the other
* cases. */
factor = (1000000000 + diff_nsec/2) / diff_nsec;
if (factor * diff_nsec > 1100000000 ||
factor * diff_nsec < 900000000)
panic("weird RTC (diff_nsec %ld)", diff_nsec);
return freq * factor;
}
示例5: rtc_get_time
/**
* Append a new entry to the log if necessary. Checks the
* state of m_alarm_log to determine if we should append a log
* entry.
*/
void Controller::do_logging() {
if(rtc_alarmed()) {
m_alarm_log = true;
m_last_alarm_time = rtc_get_time(RTC);
#ifndef DISABLE_ACCEL
accel_read_state(&m_accel_x_stored,&m_accel_y_stored,&m_accel_z_stored);
#endif
//m_magsensor_stored = gpio_read_bit(PIN_MAP[29].gpio_device,PIN_MAP[29].gpio_bit);
// set new alarm for log_interval_seconds from now.
rtc_clear_alarmed();
}
if(m_alarm_log == true) {
if(system_geiger->is_cpm30_valid()) {
log_data_t data;
#ifndef DISABLE_ACCEL
accel_read_state(&data.accel_x_end,&data.accel_y_end,&data.accel_z_end);
#endif
//data.magsensor_end = gpio_read_bit(PIN_MAP[29].gpio_device,PIN_MAP[29].gpio_bit);
data.time = rtc_get_time(RTC);
data.cpm = system_geiger->get_cpm30();
data.accel_x_start = m_accel_x_stored;
data.accel_y_start = m_accel_y_stored;
data.accel_z_start = m_accel_z_stored;
//data.magsensor_start = m_magsensor_stored;
data.log_type = UINT_MAX;
flashstorage_log_pushback((uint8_t *) &data,sizeof(log_data_t));
bool full = flashstorage_log_isfull();
if((full == true) && (!m_sleeping)) {
m_gui->show_dialog("Flash Log","is full",0,0,0,43,44,255,255);
}
m_alarm_log = false;
rtc_set_alarm(RTC,m_last_alarm_time+m_log_interval_seconds);
rtc_enable_alarm(RTC);
if(m_sleeping) {
power_standby();
}
}
}
}
示例6: lcd_scroll_disp
void lcd_scroll_disp(unsigned char *scroll_data, unsigned char position)
{
unsigned char i, j, *d;
position += 0x80;
d = scroll_data;
comdr(position);
for(j = 15; j>0 ; j--)
{
position = j + 0x80;
comdr(position);
ms_delay(5);
for(i=0; *d!='\0'; i++)
{
datar(*d);
ms_delay(1);
d++;
}
d = scroll_data++;
rtc_get_time(); //--------------
lcd_line4_disp(&Uc_real_time[0],12); //------------------
ms_delay(9000);
clrscr();
}
}
示例7: app_neb_insert_abs_time
static void app_neb_insert_abs_time(struct nbps_neb_record_send_req *req)
{
#if (RTC_SUPPORT)
struct rtc_time time;
// Get time stamp from RTC
rtc_get_time(&time);
// Format result
req->neb_rec.timestamp.year = time.tm_year;
req->neb_rec.timestamp.month = time.tm_mon;
req->neb_rec.timestamp.day = time.tm_mday;
req->neb_rec.timestamp.hour = time.tm_hour;
req->neb_rec.timestamp.min = time.tm_min;
req->neb_rec.timestamp.sec = time.tm_sec;
#else //(RTC_SUPPORT)
// Default time
req->neb_rec.timestamp.year = 2015;
req->neb_rec.timestamp.month = 10;
req->neb_rec.timestamp.day = 21;
req->neb_rec.timestamp.hour = 16;
req->neb_rec.timestamp.min = 29;
req->neb_rec.timestamp.sec = 0;
#endif //(RTC_SUPPORT)
}
示例8: ZP_CreateLogFile
void ZP_CreateLogFile(void)
{
char file[50];
uint32_t ul_hour, ul_minute, ul_second;
uint32_t ul_year, ul_month, ul_day, ul_week;
rtc_get_time(RTC, &ul_hour, &ul_minute, &ul_second);
rtc_get_date(RTC, &ul_year, &ul_month, &ul_day, &ul_week);
f_mkdir("0:Logs");
sprintf(file, "0:logs/%04u", ul_year);
f_mkdir((char const *)file);
sprintf(file, "0:logs/%04u/%02u", ul_year, ul_month);
f_mkdir((char const *)file);
sprintf(file, "0:logs/%04u/%02u/%02u", ul_year, ul_month, ul_day);
f_mkdir((char const *)file);
sprintf(file, "0:Logs/%04u/%02u/%02u/Flight_Log_%02u.%02u.%02u.log", ul_year, ul_month, ul_day, ul_hour, ul_minute, ul_second);
f_open(&f_log, (char const *)file, FA_CREATE_ALWAYS | FA_WRITE);
f_puts("Goblin-Tech", &f_log);
f_puts("GT101-0001", &f_log);
f_puts("00.00.00", &f_log);
uint16_t size = f_size(&f_script);
uint8_t dummy;
f_write(&f_log, &size, 2, &dummy);
f_write(&f_log, &Script, size, &dummy);
f_sync(&f_log);
}
示例9: rtc_ioctl
static int
rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg)
{
struct rtc_time rtc_tm;
ulong curr_time;
switch (cmd) {
case RTC_RD_TIME: /* Read the time/date from RTC */
curr_time = rtc_get_time();
to_tm(curr_time, &rtc_tm);
rtc_tm.tm_year -= 1900;
return copy_to_user((void *) arg, &rtc_tm, sizeof(rtc_tm)) ?
-EFAULT : 0;
case RTC_SET_TIME: /* Set the RTC */
if (!capable(CAP_SYS_TIME))
return -EACCES;
if (copy_from_user(&rtc_tm,
(struct rtc_time *) arg,
sizeof(struct rtc_time)))
return -EFAULT;
curr_time = mktime(rtc_tm.tm_year + 1900,
rtc_tm.tm_mon,
rtc_tm.tm_mday,
rtc_tm.tm_hour,
rtc_tm.tm_min,
rtc_tm.tm_sec);
return rtc_set_time(curr_time);
default:
return -EINVAL;
}
}
示例10: time_init
void __init time_init(void)
{
if (board_time_init)
board_time_init();
clk_init();
if (rtc_get_time) {
rtc_get_time(&xtime);
} else {
xtime.tv_sec = mktime(2000, 1, 1, 0, 0, 0);
xtime.tv_nsec = 0;
}
set_normalized_timespec(&wall_to_monotonic,
-xtime.tv_sec, -xtime.tv_nsec);
/*
* Find the timer to use as the system timer, it will be
* initialized for us.
*/
sys_timer = get_sys_timer();
printk(KERN_INFO "Using %s for system timer\n", sys_timer->name);
#if defined(CONFIG_SH_KGDB)
/*
* Set up kgdb as requested. We do it here because the serial
* init uses the timer vars we just set up for figuring baud.
*/
kgdb_init();
#endif
}
示例11: time_init
void __init time_init(void)
{
int ret;
/*
* Make sure we don't get any COMPARE interrupts before we can
* handle them.
*/
sysreg_write(COMPARE, 0);
xtime.tv_sec = rtc_get_time();
xtime.tv_nsec = 0;
set_normalized_timespec(&wall_to_monotonic,
-xtime.tv_sec, -xtime.tv_nsec);
ret = avr32_hpt_init();
if (ret) {
pr_debug("timer: failed setup: %d\n", ret);
return;
}
ret = clocksource_register(&clocksource_avr32);
if (ret)
pr_debug("timer: could not register clocksource: %d\n", ret);
ret = avr32_hpt_start();
if (ret) {
pr_debug("timer: failed starting: %d\n", ret);
return;
}
}
示例12: getDateTime
/**
* RTCの時間を取得します。
*
* @param[out] year 年の格納先を指定します。
* @param[out] mon 月の格納先を指定します。
* @param[out] day 日の格納先を指定します。
* @param[out] hour 時の格納先を指定します。
* @param[out] min 分の格納先を指定します。
* @param[out] sec 秒の格納先を指定します。
* @param[out] week 曜日の格納先を指定します。
*
* @return 時間の取得に成功した場合はtrueを返却します。失敗した場合はfalseを返却します。
*
* @attention なし
***************************************************************************/
bool RTC::getDateTime(int &year, int &mon, int &day, int &hour, int &min, int &sec, int &week)
{
bool bError = true;
RTC_TIMETYPE time;
if (rtc_get_time(&time) == 0) {
year = 0;
mon = 0;
day = 0;
hour = 0;
sec = 0;
week = 0;
bError = false;
}
else {
year = time.year;
mon = time.mon;
day = time.day;
hour = time.hour;
min = time.min;
sec = time.second;
week = time.weekday;
}
return (bError);
}
示例13: time_init
void __init time_init(void)
{
if (board_time_init)
board_time_init();
xtime.tv_sec = rtc_get_time();
xtime.tv_usec = 0;
/* choose appropriate gettimeoffset routine */
do_gettimeoffset = null_gettimeoffset;
/*
* Call board specific timer interrupt setup.
*
* this pointer must be setup in machine setup routine.
*
* Even if the machine choose to use low-level timer interrupt,
* it still needs to setup the timer_irqaction.
* In that case, it might be better to set timer_irqaction.handler
* to be NULL function so that we are sure the high-level code
* is not invoked accidentally.
*/
board_timer_setup(&timer_irqaction);
}
示例14: gettime
void gettime()
{
if(time_start){
rtc_get_time(&t.hour,&t.min,&t.sec);
rtc_get_date(&t.dow,&t.date,&t.month,&t.year);
time_start=0;
}
}
示例15: _prepare_next_alarm
static void _prepare_next_alarm(void)
{
struct tm time;
rtc_get_time(&time);
/* set initial alarm */
time.tm_sec += PERIOD;
mktime(&time);
rtc_set_alarm(&time, rtc_cb, NULL);
}