PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Dependents:   Sensitive

Fork of PokittoLib by Jonne Valola

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rtc_time.h Source File

rtc_time.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include <time.h>
00018 
00019 #ifdef __cplusplus
00020 extern "C" {
00021 #endif
00022 
00023 /** Implementation of the C time.h functions
00024  *
00025  * Provides mechanisms to set and read the current time, based
00026  * on the microcontroller Real-Time Clock (RTC), plus some
00027  * standard C manipulation and formating functions.
00028  *
00029  * Example:
00030  * @code
00031  * #include "mbed.h"
00032  *
00033  * int main() {
00034  *     set_time(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37
00035  *
00036  *     while(1) {
00037  *         time_t seconds = time(NULL);
00038  *
00039  *         printf("Time as seconds since January 1, 1970 = %d\n", seconds);
00040  *
00041  *         printf("Time as a basic string = %s", ctime(&seconds));
00042  *
00043  *         char buffer[32];
00044  *         strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
00045  *         printf("Time as a custom formatted string = %s", buffer);
00046  *
00047  *         wait(1);
00048  *     }
00049  * }
00050  * @endcode
00051  */
00052 
00053 /** Set the current time
00054  *
00055  * Initialises and sets the time of the microcontroller Real-Time Clock (RTC)
00056  * to the time represented by the number of seconds since January 1, 1970
00057  * (the UNIX timestamp).
00058  *
00059  * @param t Number of seconds since January 1, 1970 (the UNIX timestamp)
00060  *
00061  * Example:
00062  * @code
00063  * #include "mbed.h"
00064  *
00065  * int main() {
00066  *     set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37
00067  * }
00068  * @endcode
00069  */
00070 void set_time(time_t t);
00071 
00072 /** Attach an external RTC to be used for the C time functions
00073  *
00074  * Do not call this function from an interrupt while an RTC read/write operation may be occurring 
00075  *
00076  * @param read_rtc pointer to function which returns current UNIX timestamp
00077  * @param write_rtc pointer to function which sets current UNIX timestamp, can be NULL
00078  * @param init_rtc pointer to funtion which initializes RTC, can be NULL
00079  * @param isenabled_rtc pointer to function wich returns if the rtc is enabled, can be NULL
00080  */
00081 void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void));
00082 
00083 #ifdef __cplusplus
00084 }
00085 #endif