mbed library sources. Supersedes mbed-src.

Fork of mbed-dev by mbed official

Committer:
Splith
Date:
Sat Jan 30 16:48:54 2016 +0000
Revision:
57:dd901dec6bd0
Parent:
0:9b334a45a8ff
Add USART3 pin mapping to Seeed arch max

Who changed what in which revision?

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