SAMV71 Xplained Ultra Software Package 1.3

main.c

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2014, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 /**
00031  * \page rtc RTC Example
00032  *
00033  * \section Purpose
00034  *
00035  * This basic example shows how to use the Real-Time Clock (RTC) peripheral
00036  * available on the Atmel SAMV7 microcontrollers. The RTC enables easy
00037  * time and date management and allows the user to monitor events like a
00038  * configurable alarm, second change, calendar change, and so on.
00039  *
00040  * \section Requirements
00041  *
00042  * This package can be used with SAM V71 Xplained Ultra board.
00043  *
00044  * \section Description
00045  *
00046  * Upon startup, the program displays the currently set time and date
00047  * and a menu to perform the following:
00048  *     \code
00049  *     Menu:
00050  *        t - Set time
00051  *        d - Set date
00052  *        i - Set time alarm
00053  *        m - Set date alarm
00054  *        c - Clear the alarm notification (only if it has been triggered)
00055  *     \endcode
00056  *
00057  * Setting the time, date and time alarm is done by using Menu option "t", "d",
00058  * the display is updated accordingly.
00059  *
00060  * The time alarm is triggered only when the second, minute and hour match the 
00061  * pre-set values; the date alarm is triggered only when the month and date 
00062  * match the pre-set values. If both time alarm and date alarm are set, only 
00063  * when the second, minute, hour, month and date match the pre-set values,
00064  * the alarm will be triggered.
00065  *
00066  * \section Usage
00067  *
00068  *  -# Build the program and download it inside the SAM V71 Xplained Ultra board. 
00069  *     Please refer to the Getting Started with SAM V71 Microcontrollers.pdf
00070  * -# On the computer, open and configure a terminal application
00071  *    (e.g. HyperTerminal on Microsoft Windows) with these settings:
00072  *   - 115200 baud rate
00073  *   - 8 bits of data
00074  *   - No parity
00075  *   - 1 stop bit
00076  *   - No flow control
00077  * -# Start the application.
00078  * -# In the terminal window, the following text should appear:
00079  *    \code
00080  *     -- RTC Example xxx --
00081  *     -- xxxxxx-xx
00082  *     -- Compiled: xxx xx xxxx xx:xx:xx --
00083  *
00084  *     Menu:
00085  *     t - Set time
00086  *     d - Set date
00087  *     i - Set time alarm
00088  *     m - Set date alarm
00089  *     q - Quit
00090  *    \endcode
00091  * -# Press one of the keys listed in the menu to perform the corresponding action.
00092  *
00093  * \section References
00094  * - rtc/main.c
00095  * - rtc.c
00096  * - rtc.h
00097 */
00098 
00099 /**
00100  * \file
00101  *
00102  * This file contains all the specific code for the rtc example.
00103  */
00104 
00105 /*----------------------------------------------------------------------------
00106  *        Headers
00107  *----------------------------------------------------------------------------*/
00108 
00109 #include "board.h"
00110 
00111 #include <stdint.h>
00112 #include <stdio.h>
00113 #include <stdarg.h>
00114 
00115 /*----------------------------------------------------------------------------
00116  *        Local definitions
00117  *----------------------------------------------------------------------------*/
00118 
00119 /** Main menu is being displayed. */
00120 #define STATE_MENU              0
00121 /** Time is being edited. */
00122 #define STATE_SET_TIME          1
00123 /** Date is being edited. */
00124 #define STATE_SET_DATE          2
00125 /** Time alarm is being edited. */
00126 #define STATE_SET_TIME_ALARM    3
00127 /** Date alarm is being edited. */
00128 #define STATE_SET_DATE_ALARM    4
00129 
00130 /** Maximum size of edited string */
00131 #define MAX_EDIT_SIZE       10
00132 
00133 /** Macro for check digit character */
00134 #define IsDigitChar(c) ((c) >= '0' && (c) <='9')
00135 /** Macro for converting char to digit */
00136 #define CharToDigit(c) ((c) - '0')
00137 
00138 /*----------------------------------------------------------------------------
00139  *        Local variables
00140  *----------------------------------------------------------------------------*/
00141 volatile uint16_t Temperature=0;
00142 volatile uint32_t CountDownTimer = 0;
00143 /** Current state of application. */
00144 static unsigned int bState = STATE_MENU;
00145 
00146 /** Edited hour. */
00147 static unsigned char newHour;
00148 /** Edited minute. */
00149 static unsigned char newMinute;
00150 /** Edited second. */
00151 static unsigned char newSecond;
00152 
00153 /** Edited year. */
00154 static unsigned short newYear;
00155 /** Edited month. */
00156 static unsigned char newMonth;
00157 /** Edited day. */
00158 static unsigned char newDay;
00159 /** Edited day-of-the-week. */
00160 static unsigned char newWeek;
00161 
00162 /** Indicates if alarm has been triggered and not yet cleared. */
00163 static unsigned char alarmTriggered = 0;
00164 
00165 /** store time string */
00166 static char rtc_time[8+1] = {'0', '0', ':', '0', '0', ':', '0', '0','\0'};
00167 /** store date string */
00168 static char date[10+1] = {'0', '0', '/', '0', '0', '/', '0', '0', '0', '0', '\0'};
00169 /** week string */
00170 static char pDayNames[7][4] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
00171 /** console erase sequence */
00172 static char pEraseSeq[] = "\b \b";
00173 /** output format string buffer */
00174 static char calendar[80];
00175 /** identify refreshing menu */
00176 static unsigned int bMenuShown = 0;
00177 
00178 /*----------------------------------------------------------------------------
00179  *        Local functions
00180  *----------------------------------------------------------------------------*/
00181 /**
00182  * \brief Print a formatted string into a buffer.
00183  */
00184 static signed int _PrnToBuf( char *pBuf, const char *pFormat, ... )
00185 {
00186     va_list ap ;
00187     signed int rc ;
00188 
00189     va_start( ap, pFormat ) ;
00190     rc = vsprintf( pBuf, pFormat, ap ) ;
00191     va_end( ap ) ;
00192 
00193     return rc ;
00194 }
00195 
00196 /**
00197  * \brief Get new time, successful value is put in newHour, newMinute, newSecond.
00198  */
00199 static int _GetNewTime( void )
00200 {
00201     char ucKey ;
00202     int i=0 ;
00203 
00204     /* clear setting variable */
00205     newHour = newMinute = newSecond = 0xFF;
00206 
00207     /* use time[] as a format template */
00208     while ( 1 ) {
00209         ucKey = DBG_GetChar();
00210 
00211         /* end input */
00212         if ( ucKey == 0x0d || ucKey == 0x0a ) {
00213             puts("\n\r");
00214             break;
00215         }
00216 
00217         /* DEL or BACKSPACE */
00218         if ( ucKey == 0x7f || ucKey == 0x08 ) {
00219             if ( i > 0 ) {
00220                 /* end of time[], index then one more back */
00221                 if ( !rtc_time[i] ) {
00222                     --i ;
00223                 }
00224 
00225                 puts( pEraseSeq ) ;
00226                 --i ;
00227 
00228                 /* delimiter ':' for time is uneditable */
00229                 if ( !IsDigitChar( rtc_time[i] ) && i > 0 ) {
00230                     puts( pEraseSeq ) ;
00231                     --i ;
00232                 }
00233             }
00234         }
00235 
00236         /* end of time[], no more input except above DEL/BS or enter to end */
00237         if ( !rtc_time[i] ) {
00238             continue ;
00239         }
00240 
00241         if ( !IsDigitChar( ucKey ) ) {
00242             continue ;
00243         }
00244 
00245         DBG_PutChar( ucKey ) ;
00246         rtc_time[i++] = ucKey ;
00247 
00248         /* ignore non digit position if not end */
00249         if ( !IsDigitChar( rtc_time[i] ) && i < 8 ) {
00250             DBG_PutChar( rtc_time[i] ) ;
00251             ++i ;
00252         }
00253     }
00254 
00255     if ( i == 0 ) {
00256         return 0 ;
00257     }
00258 
00259     if ( i != 0 && rtc_time[i] != '\0' ) {
00260         return 1 ; /* failure input */
00261     }
00262 
00263     newHour = CharToDigit( rtc_time[0] ) * 10 + CharToDigit( rtc_time[1] ) ;
00264     newMinute = CharToDigit( rtc_time[3] ) * 10 + CharToDigit( rtc_time[4] ) ;
00265     newSecond = CharToDigit( rtc_time[6] ) * 10 + CharToDigit( rtc_time[7] ) ;
00266 
00267     /* verification of data is left to RTC internal Error Checking */
00268     return 0 ;
00269 }
00270 
00271 /**
00272  * \brief Calculate week from year, month,day.
00273  */
00274 static char _CalcWeek( int year, int month, int day )
00275 {
00276     char week ;
00277 
00278     if ( month == 1 || month == 2 ) {
00279         month += 12 ;
00280         --year ;
00281     }
00282 
00283     week = (day + 2 * month + 3 * (month + 1 ) / 5 + year + year / 4 - 
00284             year / 100 + year / 400 ) % 7;
00285     ++week ;
00286 
00287     return week ;
00288 }
00289 
00290 /**
00291  * \brief Get new time, successful value is put in newYear, newMonth, newDay, 
00292  * newWeek.
00293  */
00294 static int _GetNewDate( void )
00295 {
00296     char ucKey ;
00297     int i=0;
00298 
00299     /* clear setting variable */
00300     newYear = 0xFFFF;
00301     newMonth = newDay= newWeek = 0xFF;
00302 
00303     /* use time[] as a format template */
00304     while ( 1 ) {
00305         ucKey = DBG_GetChar() ;
00306 
00307         /* end input */
00308         if ( ucKey == 0x0d || ucKey == 0x0a ) {
00309             puts( "\n\r" ) ;
00310             break ;
00311         }
00312         /* DEL or BACKSPACE */
00313         if ( ucKey == 0x7f || ucKey == 0x08 ) {
00314             if ( i > 0 ) {
00315                 /* end of date[], index then one more back */
00316                 if ( !date[i] ) {
00317                     --i ;
00318                 }
00319 
00320                 puts( pEraseSeq ) ;
00321                 --i ;
00322 
00323                 /* delimiter '/' for date is uneditable */
00324                 if ( !IsDigitChar( date[i] ) && i > 0 ) {
00325                     puts( pEraseSeq ) ;
00326                     --i ;
00327                 }
00328             }
00329         }
00330 
00331         /* end of time[], no more input except above DEL/BS or enter to end */
00332         if ( !date[i] ) {
00333             continue ;
00334         }
00335 
00336         if ( !IsDigitChar( ucKey ) ) {
00337             continue;
00338         }
00339 
00340         DBG_PutChar( ucKey ) ;
00341         date[i++] = ucKey ;
00342 
00343         /* ignore non digit position */
00344         if ( !IsDigitChar( date[i] ) && i < 10 ) {
00345             DBG_PutChar( date[i] ) ;
00346             ++i ;
00347         }
00348     }
00349 
00350     if ( i == 0 ) {
00351         return 0 ;
00352     }
00353 
00354     if ( i != 0 && date[i] != '\0' && i != 6 ) {
00355         return 1 ; /* failure input */
00356     }
00357 
00358     /* MM-DD-YY */
00359     newMonth = CharToDigit( date[0] ) * 10 + CharToDigit( date[1] ) ;
00360     newDay = CharToDigit( date[3] ) * 10 + CharToDigit( date[4] ) ;
00361     if ( i != 6 )
00362     {/* not scenario of getting mm/dd/ only for alarm */
00363         newYear = CharToDigit(date[6]) * 1000 + CharToDigit(date[7]) * 100 +
00364             CharToDigit(date[8]) * 10 + CharToDigit(date[9] ) ;
00365         newWeek = _CalcWeek( newYear, newMonth, newDay ) ;
00366     }
00367 
00368     /* verification of data is left to RTC internal Error Checking */
00369     return 0 ;
00370 }
00371 
00372 /**
00373  *  Interrupt handler for TC0 interrupt.
00374  */
00375 void TC0_Handler( void )
00376 {
00377     volatile uint32_t dummy;  
00378     /* Clear status bit to acknowledge interrupt */
00379     dummy = TC0->TC_CHANNEL[ 0 ].TC_SR ;
00380     // Recalibrate at every 1 minute
00381     if(CountDownTimer >= 240 ) {
00382         RTC_ClockCalibration(RTC, Temperature);
00383         TRACE_INFO("RTC has been re-calibrated \n\r");
00384         CountDownTimer = 0;
00385     }
00386     CountDownTimer++;
00387 }
00388 
00389 /**
00390  * \brief Displays the user interface on the terminal.
00391  */
00392 static void _RefreshDisplay( void )
00393 {
00394     unsigned char hour, minute, second ;
00395     unsigned short year ;
00396     unsigned char month, day, week ;
00397 
00398     if ( bState != STATE_MENU ) { /* not in menu display mode, in set mode */
00399     } else {
00400         /* Retrieve date and time */
00401         RTC_GetTime( RTC, &hour, &minute, &second ) ;
00402         RTC_GetDate( RTC, &year, &month, &day, &week ) ;
00403 
00404         /* display */
00405         if ( !bMenuShown ) {
00406             printf( "\n\rMenu:\n\r" ) ;
00407             printf( "  t - Set time\n\r" ) ;
00408             printf( "  d - Set date\n\r" ) ;
00409             printf( "  i - Set time alarm\n\r" ) ;
00410             printf( "  m - Set date alarm\n\r" ) ;
00411             printf( "  p - PPM calibration of RTC\n\r" ) ;
00412 
00413             if ( alarmTriggered ) {
00414                 printf( "  c - Clear alarm notification\n\r" ) ;
00415             }
00416 
00417             printf( "  q - Quit!\n\r" ) ;
00418             printf( "\n\r" ) ;
00419             bMenuShown = 1 ;
00420         }
00421 
00422         /* update current date and time */
00423         _PrnToBuf( rtc_time, "%02d:%02d:%02d", hour, minute, second ) ;
00424         _PrnToBuf( date, "%02d/%02d/%04d", month, day, year ) ;
00425         _PrnToBuf( calendar, " [Time/Date: %s, %s %s ][Alarm status:%s]", 
00426                 rtc_time, date, pDayNames[week-1], alarmTriggered?"Triggered!":"" ) ;
00427         printf( "\r%s", calendar ) ;
00428     }
00429 }
00430 
00431 /**
00432  * \brief Interrupt handler for the RTC. Refreshes the display.
00433  */
00434 void RTC_Handler( void )
00435 {
00436     uint32_t dwStatus = RTC->RTC_SR ;
00437 
00438     /* Second increment interrupt */
00439     if ( (dwStatus & RTC_SR_SEC) == RTC_SR_SEC ) {
00440         /* Disable RTC interrupt */
00441         RTC_DisableIt( RTC, RTC_IDR_SECDIS ) ;
00442 
00443         _RefreshDisplay() ;
00444 
00445         RTC->RTC_SCCR = RTC_SCCR_SECCLR ;
00446 
00447         RTC_EnableIt( RTC, RTC_IER_SECEN ) ;
00448     }
00449     /* Time or date alarm */
00450     else {
00451         if ( (dwStatus & RTC_SR_ALARM) == RTC_SR_ALARM ) {
00452             /* Disable RTC interrupt */
00453             RTC_DisableIt( RTC, RTC_IDR_ALRDIS ) ;
00454 
00455             alarmTriggered = 1 ;
00456             _RefreshDisplay() ;
00457             bMenuShown = 0 ; /* shown additional menu item for clear notification */
00458             RTC->RTC_SCCR = RTC_SCCR_ALRCLR ;
00459 
00460             RTC_EnableIt( RTC, RTC_IER_ALREN ) ;
00461         }
00462     }
00463 }
00464 
00465 /**
00466  *  Configure Timer Counter 0 to generate an interrupt every 250ms.
00467  */
00468 static void _ConfigureTc( void )
00469 {
00470     uint32_t div;
00471     uint32_t tcclks;
00472 
00473     /** Enable peripheral clock. */
00474     PMC_EnablePeripheral( ID_TC0);
00475 
00476     /** Configure TC for a 4Hz frequency and trigger on RC compare. */
00477     TC_FindMckDivisor( 4, BOARD_MCK/2, &div, &tcclks, BOARD_MCK );
00478     TC_Configure( TC0, 0, tcclks | TC_CMR_CPCTRG );
00479     TC0->TC_CHANNEL[ 0 ].TC_RC = ( BOARD_MCK / div ) / 4;
00480 
00481     /* Configure and enable interrupt on RC compare */    
00482     NVIC_ClearPendingIRQ(TC0_IRQn);
00483     NVIC_EnableIRQ(TC0_IRQn);
00484 
00485     NVIC_SetPriority( TC0_IRQn , 2);
00486     TC0->TC_CHANNEL[ 0 ].TC_IER = TC_IER_CPCS ;
00487 
00488     TC_Start( TC0, 0 );
00489    
00490 }
00491 
00492 /*----------------------------------------------------------------------------
00493  *         Global functions
00494  *----------------------------------------------------------------------------*/
00495 
00496 /**
00497  * \brief Application entry point for RTC example.
00498  *
00499  * \return Unused (ANSI-C compatibility).
00500  */
00501 
00502 extern int main( void )
00503 {
00504     uint8_t ucKey ;
00505 
00506     /* Disable watchdog */
00507     WDT_Disable( WDT ) ;
00508 
00509     /* Enable I and D cache */
00510     SCB_EnableICache();
00511     SCB_EnableDCache();
00512     
00513     /* Output example information */
00514     printf( "\n\r\n\r\n\r" ) ;
00515     printf( "-- RTC Example %s --\n\r", SOFTPACK_VERSION ) ;
00516     printf( "-- %s\n\r", BOARD_NAME ) ;
00517     printf( "-- Compiled: %s %s With %s--\n\r", __DATE__, __TIME__ , COMPILER_NAME) ;
00518 
00519     
00520      printf( "Configure TC.\n\r" );
00521     _ConfigureTc() ;
00522     //put 25  as a default temp, if there is no temperature sensor
00523     Temperature = 25;
00524     
00525     /* Default RTC configuration */
00526     RTC_SetHourMode( RTC, 0 ) ; /* 24-hour mode */
00527     if ( RTC_SetTimeAlarm( RTC, 0, 0, 0 ) ) {
00528         printf( "\n\r Disable time alarm fail!" ) ;
00529     }
00530 
00531     if ( RTC_SetDateAlarm( RTC, 0, 0 ) ) {
00532         printf( "\n\r Disable date alarm fail!" ) ;
00533     }
00534 
00535     /* Configure RTC interrupts */
00536     NVIC_DisableIRQ( RTC_IRQn ) ;
00537     NVIC_ClearPendingIRQ( RTC_IRQn ) ;
00538     NVIC_SetPriority( RTC_IRQn, 0 ) ;
00539     NVIC_EnableIRQ( RTC_IRQn ) ;
00540     RTC_EnableIt( RTC, RTC_IER_SECEN | RTC_IER_ALREN ) ;
00541 
00542     /* Refresh display once */
00543     _RefreshDisplay() ;
00544     newHour = 0; newMinute =0; newSecond = 30;
00545     RTC_SetTimeAlarm( RTC, &newHour, &newMinute, &newSecond ) ;
00546     bMenuShown = 0 ;alarmTriggered = 0 ;
00547     RTC_ClockCalibration(RTC, Temperature);
00548 
00549     /* Handle key presses */
00550     while ( 1 ) {
00551         ucKey = DBG_GetChar() ;
00552 
00553         /* set time */
00554         if ( ucKey == 't' ) {
00555             bState = STATE_SET_TIME;
00556 
00557             do {
00558                 printf( "\n\r\n\r Set time(hh:mm:ss): " ) ;
00559             } while( _GetNewTime() ) ;
00560 
00561             /* if valid input, none of variable for time is 0xff */
00562             if ( newHour != 0xFF ) {
00563                 if ( RTC_SetTime( RTC, newHour, newMinute, newSecond ) ) {
00564                     printf( "\n\r Time not set, invalid input!\n\r" ) ;
00565                 }
00566             }
00567 
00568             bState = STATE_MENU ;
00569             bMenuShown = 0 ;
00570             _RefreshDisplay() ;
00571             CountDownTimer = 0;
00572         }
00573 
00574         if ( ucKey == 'p' ) {
00575             
00576             RTC_ClockCalibration(RTC, 30);
00577             bState = STATE_MENU ;
00578             bMenuShown = 0 ;
00579             _RefreshDisplay() ;
00580         }
00581 
00582         /* set date */
00583         if ( ucKey == 'd' ) {
00584             bState = STATE_SET_DATE ;
00585 
00586             do {
00587                 printf( "\n\r\n\r Set date(mm/dd/yyyy): " ) ;
00588             } while ( _GetNewDate() ) ;
00589 
00590             /* if valid input, none of variable for date is 0xff(ff) */
00591             if ( newYear !=0xFFFF ) {
00592                 if ( RTC_SetDate( RTC, newYear, newMonth, newDay, newWeek ) ) {
00593                     printf( "\n\r Date not set, invalid input!\n\r" ) ;
00594                 }
00595             }
00596 
00597             /* only 'mm/dd' input */
00598             if ( newMonth != 0xFF && newYear == 0xFFFF ) {
00599                 printf( "\n\r Not Set for no year field!\n\r" ) ;
00600             }
00601 
00602             bState = STATE_MENU ;
00603             bMenuShown = 0 ;
00604             CountDownTimer = 0;
00605             _RefreshDisplay() ;
00606         }
00607 
00608 
00609         /* set time alarm */
00610         if ( ucKey == 'i') {
00611             bState = STATE_SET_TIME_ALARM ;
00612 
00613             do {
00614                 printf( "\n\r\n\r Set time alarm(hh:mm:ss): " ) ;
00615             } while ( _GetNewTime() ) ;
00616 
00617             if ( newHour != 0xFF ) {
00618                 if ( RTC_SetTimeAlarm( RTC, &newHour, &newMinute, &newSecond ) ) {
00619                     printf( "\n\r Time alarm not set, invalid input!\n\r" ) ;
00620                 } else {
00621                     printf( "\n\r Time alarm is set at %02d:%02d:%02d!", 
00622                             newHour, newMinute, newSecond ) ;
00623                 }
00624             }
00625             bState = STATE_MENU ;
00626             bMenuShown = 0 ;
00627             alarmTriggered = 0 ;
00628             CountDownTimer = 0;
00629             _RefreshDisplay() ;
00630         }
00631 
00632         /* set date alarm */
00633         if ( ucKey == 'm' ) {
00634             bState = STATE_SET_DATE_ALARM;
00635 
00636             do {
00637                 printf( "\n\r\n\r Set date alarm(mm/dd/): " ) ;
00638             } while ( _GetNewDate() ) ;
00639 
00640             if ( newYear == 0xFFFF && newMonth != 0xFF ) {
00641                 if ( RTC_SetDateAlarm( RTC, &newMonth, &newDay ) ) {
00642                     printf( "\n\r Date alarm not set, invalid input!\n\r" ) ;
00643                 } else {
00644                     printf( "\n\r Date alarm is set on %02d/%02d!", 
00645                             newMonth, newDay ) ;
00646                 }
00647 
00648             }
00649             bState = STATE_MENU ;
00650             bMenuShown = 0 ;
00651             alarmTriggered = 0 ;
00652             CountDownTimer = 0;
00653             _RefreshDisplay() ;
00654         }
00655 
00656         /* clear trigger flag */
00657         if ( ucKey == 'c' ) {
00658             alarmTriggered = 0 ;
00659             bMenuShown = 0 ;
00660             _RefreshDisplay() ;
00661         }
00662 
00663         /* quit */
00664         if ( ucKey == 'q' ) {
00665             break ;
00666         }
00667     }
00668 
00669     return 0 ;
00670 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines