mbed-os for GR-LYCHEE

Dependents:   mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more

Committer:
dkato
Date:
Fri Feb 02 05:42:23 2018 +0000
Revision:
0:f782d9c66c49
mbed-os for GR-LYCHEE

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:f782d9c66c49 1
dkato 0:f782d9c66c49 2 /** \addtogroup platform */
dkato 0:f782d9c66c49 3 /** @{*/
dkato 0:f782d9c66c49 4 /* mbed Microcontroller Library
dkato 0:f782d9c66c49 5 * Copyright (c) 2006-2013 ARM Limited
dkato 0:f782d9c66c49 6 *
dkato 0:f782d9c66c49 7 * Licensed under the Apache License, Version 2.0 (the "License");
dkato 0:f782d9c66c49 8 * you may not use this file except in compliance with the License.
dkato 0:f782d9c66c49 9 * You may obtain a copy of the License at
dkato 0:f782d9c66c49 10 *
dkato 0:f782d9c66c49 11 * http://www.apache.org/licenses/LICENSE-2.0
dkato 0:f782d9c66c49 12 *
dkato 0:f782d9c66c49 13 * Unless required by applicable law or agreed to in writing, software
dkato 0:f782d9c66c49 14 * distributed under the License is distributed on an "AS IS" BASIS,
dkato 0:f782d9c66c49 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dkato 0:f782d9c66c49 16 * See the License for the specific language governing permissions and
dkato 0:f782d9c66c49 17 * limitations under the License.
dkato 0:f782d9c66c49 18 */
dkato 0:f782d9c66c49 19
dkato 0:f782d9c66c49 20 #include <time.h>
dkato 0:f782d9c66c49 21
dkato 0:f782d9c66c49 22 #ifdef __cplusplus
dkato 0:f782d9c66c49 23 extern "C" {
dkato 0:f782d9c66c49 24 #endif
dkato 0:f782d9c66c49 25
dkato 0:f782d9c66c49 26 /** Implementation of the C time.h functions
dkato 0:f782d9c66c49 27 *
dkato 0:f782d9c66c49 28 * Provides mechanisms to set and read the current time, based
dkato 0:f782d9c66c49 29 * on the microcontroller Real-Time Clock (RTC), plus some
dkato 0:f782d9c66c49 30 * standard C manipulation and formating functions.
dkato 0:f782d9c66c49 31 *
dkato 0:f782d9c66c49 32 * Example:
dkato 0:f782d9c66c49 33 * @code
dkato 0:f782d9c66c49 34 * #include "mbed.h"
dkato 0:f782d9c66c49 35 *
dkato 0:f782d9c66c49 36 * int main() {
dkato 0:f782d9c66c49 37 * set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37
dkato 0:f782d9c66c49 38 *
dkato 0:f782d9c66c49 39 * while(1) {
dkato 0:f782d9c66c49 40 * time_t seconds = time(NULL);
dkato 0:f782d9c66c49 41 *
dkato 0:f782d9c66c49 42 * printf("Time as seconds since January 1, 1970 = %d\n", seconds);
dkato 0:f782d9c66c49 43 *
dkato 0:f782d9c66c49 44 * printf("Time as a basic string = %s", ctime(&seconds));
dkato 0:f782d9c66c49 45 *
dkato 0:f782d9c66c49 46 * char buffer[32];
dkato 0:f782d9c66c49 47 * strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
dkato 0:f782d9c66c49 48 * printf("Time as a custom formatted string = %s", buffer);
dkato 0:f782d9c66c49 49 *
dkato 0:f782d9c66c49 50 * wait(1);
dkato 0:f782d9c66c49 51 * }
dkato 0:f782d9c66c49 52 * }
dkato 0:f782d9c66c49 53 * @endcode
dkato 0:f782d9c66c49 54 */
dkato 0:f782d9c66c49 55
dkato 0:f782d9c66c49 56 /** Set the current time
dkato 0:f782d9c66c49 57 *
dkato 0:f782d9c66c49 58 * Initialises and sets the time of the microcontroller Real-Time Clock (RTC)
dkato 0:f782d9c66c49 59 * to the time represented by the number of seconds since January 1, 1970
dkato 0:f782d9c66c49 60 * (the UNIX timestamp).
dkato 0:f782d9c66c49 61 *
dkato 0:f782d9c66c49 62 * @param t Number of seconds since January 1, 1970 (the UNIX timestamp)
dkato 0:f782d9c66c49 63 *
dkato 0:f782d9c66c49 64 * @Note Synchronization level: Thread safe
dkato 0:f782d9c66c49 65 *
dkato 0:f782d9c66c49 66 * Example:
dkato 0:f782d9c66c49 67 * @code
dkato 0:f782d9c66c49 68 * #include "mbed.h"
dkato 0:f782d9c66c49 69 *
dkato 0:f782d9c66c49 70 * int main() {
dkato 0:f782d9c66c49 71 * set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37
dkato 0:f782d9c66c49 72 * }
dkato 0:f782d9c66c49 73 * @endcode
dkato 0:f782d9c66c49 74 */
dkato 0:f782d9c66c49 75 void set_time(time_t t);
dkato 0:f782d9c66c49 76
dkato 0:f782d9c66c49 77 /** Attach an external RTC to be used for the C time functions
dkato 0:f782d9c66c49 78 *
dkato 0:f782d9c66c49 79 * @Note Synchronization level: Thread safe
dkato 0:f782d9c66c49 80 *
dkato 0:f782d9c66c49 81 * @param read_rtc pointer to function which returns current UNIX timestamp
dkato 0:f782d9c66c49 82 * @param write_rtc pointer to function which sets current UNIX timestamp, can be NULL
dkato 0:f782d9c66c49 83 * @param init_rtc pointer to funtion which initializes RTC, can be NULL
dkato 0:f782d9c66c49 84 * @param isenabled_rtc pointer to function wich returns if the rtc is enabled, can be NULL
dkato 0:f782d9c66c49 85 */
dkato 0:f782d9c66c49 86 void attach_rtc(time_t (*read_rtc)(void), void (*write_rtc)(time_t), void (*init_rtc)(void), int (*isenabled_rtc)(void));
dkato 0:f782d9c66c49 87
dkato 0:f782d9c66c49 88 #ifdef __cplusplus
dkato 0:f782d9c66c49 89 }
dkato 0:f782d9c66c49 90 #endif
dkato 0:f782d9c66c49 91
dkato 0:f782d9c66c49 92 /** @}*/