mbed library sources. Supersedes mbed-src.

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

Committer:
AnnaBridge
Date:
Thu Nov 23 11:57:25 2017 +0000
Revision:
178:79309dc6340a
Parent:
167:e84263d55307
Child:
184:08ed48f1de7f
mbed-dev library. Release version 156

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AnnaBridge 167:e84263d55307 1
AnnaBridge 167:e84263d55307 2 /** \addtogroup platform */
AnnaBridge 167:e84263d55307 3 /** @{*/
AnnaBridge 167:e84263d55307 4 /* mbed Microcontroller Library
AnnaBridge 167:e84263d55307 5 * Copyright (c) 2017-2017 ARM Limited
AnnaBridge 167:e84263d55307 6 *
AnnaBridge 167:e84263d55307 7 * Licensed under the Apache License, Version 2.0 (the "License");
AnnaBridge 167:e84263d55307 8 * you may not use this file except in compliance with the License.
AnnaBridge 167:e84263d55307 9 * You may obtain a copy of the License at
AnnaBridge 167:e84263d55307 10 *
AnnaBridge 167:e84263d55307 11 * http://www.apache.org/licenses/LICENSE-2.0
AnnaBridge 167:e84263d55307 12 *
AnnaBridge 167:e84263d55307 13 * Unless required by applicable law or agreed to in writing, software
AnnaBridge 167:e84263d55307 14 * distributed under the License is distributed on an "AS IS" BASIS,
AnnaBridge 167:e84263d55307 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
AnnaBridge 167:e84263d55307 16 * See the License for the specific language governing permissions and
AnnaBridge 167:e84263d55307 17 * limitations under the License.
AnnaBridge 167:e84263d55307 18 */
AnnaBridge 167:e84263d55307 19
AnnaBridge 167:e84263d55307 20 #ifndef MBED_MKTIME_H
AnnaBridge 167:e84263d55307 21 #define MBED_MKTIME_H
AnnaBridge 167:e84263d55307 22
AnnaBridge 167:e84263d55307 23 #include <time.h>
AnnaBridge 167:e84263d55307 24 #include <stdbool.h>
AnnaBridge 167:e84263d55307 25 #include <stdint.h>
AnnaBridge 167:e84263d55307 26
AnnaBridge 167:e84263d55307 27 #ifdef __cplusplus
AnnaBridge 167:e84263d55307 28 extern "C" {
AnnaBridge 167:e84263d55307 29 #endif
AnnaBridge 167:e84263d55307 30
AnnaBridge 178:79309dc6340a 31 /**
AnnaBridge 178:79309dc6340a 32 * \defgroup platform_mktime mktime functions
AnnaBridge 178:79309dc6340a 33 * @{
AnnaBridge 178:79309dc6340a 34 */
AnnaBridge 178:79309dc6340a 35
AnnaBridge 167:e84263d55307 36 /** Compute if a year is a leap year or not.
AnnaBridge 167:e84263d55307 37 *
AnnaBridge 167:e84263d55307 38 * @param year The year to test it shall be in the range [70:138]. Year 0 is
AnnaBridge 167:e84263d55307 39 * translated into year 1900 CE.
AnnaBridge 167:e84263d55307 40 * @return true if the year in input is a leap year and false otherwise.
AnnaBridge 167:e84263d55307 41 * @note - For use by the HAL only
AnnaBridge 167:e84263d55307 42 */
AnnaBridge 167:e84263d55307 43 bool _rtc_is_leap_year(int year);
AnnaBridge 167:e84263d55307 44
AnnaBridge 167:e84263d55307 45 /* Convert a calendar time into time since UNIX epoch as a time_t.
AnnaBridge 167:e84263d55307 46 *
AnnaBridge 167:e84263d55307 47 * This function is a thread safe (partial) replacement for mktime. It is
AnnaBridge 167:e84263d55307 48 * tailored around RTC peripherals needs and is not by any mean a complete
AnnaBridge 167:e84263d55307 49 * replacement of mktime.
AnnaBridge 167:e84263d55307 50 *
AnnaBridge 167:e84263d55307 51 * @param calendar_time The calendar time to convert into a time_t since epoch.
AnnaBridge 167:e84263d55307 52 * The fields from tm used for the computation are:
AnnaBridge 167:e84263d55307 53 * - tm_sec
AnnaBridge 167:e84263d55307 54 * - tm_min
AnnaBridge 167:e84263d55307 55 * - tm_hour
AnnaBridge 167:e84263d55307 56 * - tm_mday
AnnaBridge 167:e84263d55307 57 * - tm_mon
AnnaBridge 167:e84263d55307 58 * - tm_year
AnnaBridge 167:e84263d55307 59 * Other fields are ignored and won't be renormalized by a call to this function.
AnnaBridge 167:e84263d55307 60 * A valid calendar time is comprised between the 1st january of 1970 at
AnnaBridge 167:e84263d55307 61 * 00:00:00 and the 19th of january 2038 at 03:14:07.
AnnaBridge 167:e84263d55307 62 *
AnnaBridge 167:e84263d55307 63 * @return The calendar time as seconds since UNIX epoch if the input is in the
AnnaBridge 167:e84263d55307 64 * valid range. Otherwise ((time_t) -1).
AnnaBridge 167:e84263d55307 65 *
AnnaBridge 167:e84263d55307 66 * @note Leap seconds are not supported.
AnnaBridge 167:e84263d55307 67 * @note Values in output range from 0 to INT_MAX.
AnnaBridge 167:e84263d55307 68 * @note - For use by the HAL only
AnnaBridge 167:e84263d55307 69 */
AnnaBridge 167:e84263d55307 70 time_t _rtc_mktime(const struct tm* calendar_time);
AnnaBridge 167:e84263d55307 71
AnnaBridge 167:e84263d55307 72 /* Convert a given time in seconds since epoch into calendar time.
AnnaBridge 167:e84263d55307 73 *
AnnaBridge 167:e84263d55307 74 * This function is a thread safe (partial) replacement for localtime. It is
AnnaBridge 167:e84263d55307 75 * tailored around RTC peripherals specification and is not by any means a
AnnaBridge 167:e84263d55307 76 * complete of localtime.
AnnaBridge 167:e84263d55307 77 *
AnnaBridge 167:e84263d55307 78 * @param timestamp The time (in seconds) to convert into calendar time. Valid
AnnaBridge 167:e84263d55307 79 * input are in the range [0 : INT32_MAX].
AnnaBridge 167:e84263d55307 80 * @param calendar_time Pointer to the object which will contain the result of
AnnaBridge 167:e84263d55307 81 * the conversion. The tm fields filled by this function are:
AnnaBridge 167:e84263d55307 82 * - tm_sec
AnnaBridge 167:e84263d55307 83 * - tm_min
AnnaBridge 167:e84263d55307 84 * - tm_hour
AnnaBridge 167:e84263d55307 85 * - tm_mday
AnnaBridge 167:e84263d55307 86 * - tm_mon
AnnaBridge 167:e84263d55307 87 * - tm_year
AnnaBridge 167:e84263d55307 88 * - tm_wday
AnnaBridge 167:e84263d55307 89 * - tm_yday
AnnaBridge 167:e84263d55307 90 * The object remains untouched if the time in input is invalid.
AnnaBridge 167:e84263d55307 91 * @return true if the conversion was successful, false otherwise.
AnnaBridge 167:e84263d55307 92 *
AnnaBridge 167:e84263d55307 93 * @note - For use by the HAL only
AnnaBridge 167:e84263d55307 94 */
AnnaBridge 167:e84263d55307 95 bool _rtc_localtime(time_t timestamp, struct tm* calendar_time);
AnnaBridge 167:e84263d55307 96
AnnaBridge 178:79309dc6340a 97 /** @}*/
AnnaBridge 178:79309dc6340a 98
AnnaBridge 167:e84263d55307 99 #ifdef __cplusplus
AnnaBridge 167:e84263d55307 100 }
AnnaBridge 167:e84263d55307 101 #endif
AnnaBridge 167:e84263d55307 102
AnnaBridge 167:e84263d55307 103 #endif /* MBED_MKTIME_H */
AnnaBridge 167:e84263d55307 104
AnnaBridge 167:e84263d55307 105 /** @}*/