SPKT

Dependencies:   F746_GUI SD_PlayerSkeleton F746_SAI_IO

Committer:
phungductung
Date:
Tue Jun 04 21:37:21 2019 +0000
Revision:
0:8ede47d38d10
SPKT

Who changed what in which revision?

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