Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DS1820 HighSpeedAnalogIn devices mbed
RTC Class Reference
Library to get access to the interrupt functionality of the LPC1768's RTC. More...
#include <RTC.h>
Public Types | |
| enum | TimeUnit |
Available time units for interrupts. More... | |
Static Public Member Functions | |
| static void | attach (void(*function)(void), TimeUnit interval) |
| Call a function when the specified time unit increases. | |
| static void | detach (TimeUnit interval) |
| Detach an interrupt function. | |
| static void | alarm (void(*function)(void), tm alarmTime) |
| Call a function when a specified time is reached. | |
| static void | alarmOff (void) |
| Disable the alarm. | |
| static tm | getDefaultTM (void) |
| Returns a default tm structure where each field is initialized to -1, so it is ignored by the alarm function. | |
Detailed Description
Library to get access to the interrupt functionality of the LPC1768's RTC.
This class is completely static: which means you don't have to create an RTC object, there is always one object automatically created when you include this class. Since there is only one RTC, more than one would make no sense.
#include "mbed.h" #include "RTC.h" DigitalOut led(LED1); void ledFunction( void ) { led = 1; RTC::detach(RTC::Second); } void displayFunction( void ) { time_t seconds = time(NULL); printf("%s", ctime(&seconds)); } void alarmFunction( void ) { error("Not most useful alarm function"); } int main() { set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37 tm t = RTC::getDefaultTM(); t.tm_sec = 5; t.tm_min = 36; RTC::alarm(&alarmFunction, t); RTC::attach(&displayFunction, RTC::Second); RTC::attach(&ledFunction, RTC::Minute); while(1); }
Definition at line 52 of file RTC.h.
Member Enumeration Documentation
| enum TimeUnit |
Member Function Documentation
| void alarm | ( | void(*)(void) | function, |
| tm | alarmTime | ||
| ) | [static] |
Call a function when a specified time is reached.
Only one alarm is possible. Make fields of the tm structure -1 for don't care.
Member functions of a class can be attached the normal way (similar to for example Ticker).
- Parameters:
-
function - the function to call alarmTime - tm structure which specifies when to activate the alarm
| void attach | ( | void(*)(void) | function, |
| TimeUnit | interval | ||
| ) | [static] |
Call a function when the specified time unit increases.
You can attach one function for each TimeUnit. When several are attached the smalles TimeUnit is called first.
Member functions of a class can be attached the normal way (similar to for example Ticker).
- Parameters:
-
function - the function to call interval - the TimeUnit which specifies the interval
| void detach | ( | TimeUnit | interval ) | [static] |
| tm getDefaultTM | ( | void | ) | [static] |
Returns a default tm structure where each field is initialized to -1, so it is ignored by the alarm function.
Available fields: http://www.cplusplus.com/reference/ctime/tm/ Except tm_isdst all of them can be used for the alarm
- Parameters:
-
return - tm structure initialized to -1
Generated on Wed Jul 13 2022 12:46:24 by
1.7.2