?? alarm.c
字號:
//============================================================================
// Include
//============================================================================
#include <stdio.h>
#include <cyg/kernel/kapi.h>
#include <cyg/io/rtc/fie702x_rtc.h>
#include "RTCSystem.h"
//============================================================================
// Global Variables
//============================================================================
cyg_io_handle_t rtc_handle;
static int RTC_alarm = 0;
void DSR_handler (void)
{
RTC_alarm = 1;
}
int main (void)
{
RTC_Time time;
int err;
printf("RTC test\n");
/* open rtc driver
*/
err = cyg_io_lookup( "/dev/rtc", &rtc_handle );
if (ENOERR != err)
{
printf("Can't open '%s'\n", "/dev/rtc");
}
API_RTC_set_AlarmHandler(rtc_handle, DSR_handler);
while (1)
{
API_RTC_get_Time(rtc_handle, &time);
printf("Hour:%d Min:%d Sec:%d\n",time.hour,time.minute,time.second);
time.second += 5; // after five second, the alarm will be triggered
if (time.second >= 60)
{
time.second -= 60;
time.minute ++;
if (time.minute >= 60)
{
time.minute -= 60;
time.hour ++;
}
}
API_RTC_set_Alarm(rtc_handle, &time);
while (1)
{
if (RTC_alarm)
{
printf("RTC alarm!!!\n");
RTC_alarm = 0;
break;
}
}
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -