The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Thu Nov 23 11:44:04 2017 +0000
Revision:
158:1c57384330a6
Parent:
145:64910690c574
Child:
165:d1b4690b3f8b
mbed library. Release version 156

Who changed what in which revision?

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