initial commit of kl25z rtc code. local changes for debug
Fork of KL25Z_RTC by
KL25Z_RTC.h
00001 /* Copyright (c) 2010-2011 mbed.org, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without 00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish, 00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 00007 * Software is furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #ifndef __KL25Z_RTC_H 00020 #define __KL25Z_RTC_H 00021 00022 #include "mbed.h" 00023 00024 // Usage: 00025 // #include "mbed.h" 00026 // #include "KL25Z_RTC.h" 00027 // 00028 // DigitalOut myled(LED1); 00029 // KL25Z_RTC rtc( 15); 00030 // Serial pc(USBTX, USBRX); 00031 // 00032 // void alm ( void); 00033 // void sec ( void); 00034 // 00035 // int main() { 00036 // 00037 // pc.baud( 230400); 00038 // pc.printf("RTC Management.\r\n"); 00039 // 00040 // rtc.RTC_Start( &sec, &alm); 00041 // 00042 // while(1) { 00043 // // pc.printf("RTC [%0d].\r\n", rtc.RTC_Read()); 00044 // wait( 1.0); 00045 // } 00046 // } 00047 // 00048 // void sec ( void) 00049 // { 00050 // pc.printf("sec\r\n"); 00051 // } 00052 // 00053 // void alm ( void) 00054 // { 00055 // pc.printf("alrm\r\n"); 00056 // } 00057 // 00058 00059 00060 class KL25Z_RTC 00061 { 00062 public: 00063 /** Constructor. 00064 * 00065 * @param alarm espressed in seconds 00066 */ 00067 KL25Z_RTC( unsigned int alarm); 00068 00069 /** Desctructor 00070 */ 00071 ~KL25Z_RTC(); 00072 00073 /** Start the RTC module, using IRQ but without registering user defined callback functions. 00074 * Access to the elapsed time is possible using the "Read" methid. 00075 * The IRQ transaction is visible through "RTC_isIRQxxxxDone" methods. 00076 * 00077 * @param none 00078 * @return none 00079 */ 00080 void RTC_Start( void); 00081 00082 /** Start the module. Setting up the IRQ handler for the second IRQ and/or for the Alarm 00083 * @param sec_ptr, alrm_ptr pointer to the IRQ handler 00084 * @return none 00085 */ 00086 void RTC_Start( void(*sec_ptr)(void), void(*alrm_ptr)(void)); 00087 00088 /** Return the alarm value 00089 * @param none 00090 * #return the alarm value 00091 */ 00092 unsigned int RTC_GetAlarm( void); 00093 00094 /** Configure the alarm value 00095 * @param alarm in seconds 00096 * @return none 00097 */ 00098 void RTC_SetAlarm( unsigned int alarm); 00099 00100 /** Return the second elapsed 00101 * @param none 00102 * @return the second elapsed 00103 */ 00104 unsigned int RTC_Read( void); 00105 00106 /** Return the status of the IRQ for seconds elapsed. 00107 * Use this function for a polling like method, using the IRQ internally the module but without callbacks define. 00108 * The flag is reset after the read. 00109 * 00110 * @param none 00111 * @return 1 if the IRQ is done. 00112 */ 00113 unsigned int RTC_isIRQSecondDone( void); 00114 00115 /** Return the status of the IRQ for the alarm. 00116 * Use this function for a polling like method, using the IRQ internally the module but without callbacks define. 00117 * The flag is reset after the read. 00118 * 00119 * @param none 00120 * @return 1 if the IRQ is done. 00121 */ 00122 unsigned int RTC_isIRQAlarmDone( void); 00123 00124 private: 00125 00126 static void _RTC_IRQHandler(void); 00127 static void _RTC_Seconds_IRQHandler(void); 00128 00129 }; 00130 00131 #endif
Generated on Sun Jul 24 2022 11:46:00 by
