mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
<>
Date:
Tue Mar 14 16:40:56 2017 +0000
Revision:
160:d5399cc887bb
Child:
167:e84263d55307
This updates the lib to the mbed lib v138

Who changed what in which revision?

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