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:
Kojto
Date:
Wed Jul 19 16:46:19 2017 +0100
Revision:
147:a97add6d7e64
Parent:
145:64910690c574
Child:
158:1c57384330a6
Release 147 of the mbed library.

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 145:64910690c574 31 /** Compute if a year is a leap year or not.
AnnaBridge 145:64910690c574 32 *
AnnaBridge 145:64910690c574 33 * @param year The year to test it shall be in the range [70:138]. Year 0 is
AnnaBridge 145:64910690c574 34 * translated into year 1900 CE.
AnnaBridge 145:64910690c574 35 * @return true if the year in input is a leap year and false otherwise.
AnnaBridge 145:64910690c574 36 * @note - For use by the HAL only
AnnaBridge 145:64910690c574 37 */
AnnaBridge 145:64910690c574 38 bool _rtc_is_leap_year(int year);
AnnaBridge 145:64910690c574 39
AnnaBridge 145:64910690c574 40 /* Convert a calendar time into time since UNIX epoch as a time_t.
AnnaBridge 145:64910690c574 41 *
AnnaBridge 145:64910690c574 42 * This function is a thread safe (partial) replacement for mktime. It is
AnnaBridge 145:64910690c574 43 * tailored around RTC peripherals needs and is not by any mean a complete
AnnaBridge 145:64910690c574 44 * replacement of mktime.
AnnaBridge 145:64910690c574 45 *
AnnaBridge 145:64910690c574 46 * @param calendar_time The calendar time to convert into a time_t since epoch.
AnnaBridge 145:64910690c574 47 * The fields from tm used for the computation are:
AnnaBridge 145:64910690c574 48 * - tm_sec
AnnaBridge 145:64910690c574 49 * - tm_min
AnnaBridge 145:64910690c574 50 * - tm_hour
AnnaBridge 145:64910690c574 51 * - tm_mday
AnnaBridge 145:64910690c574 52 * - tm_mon
AnnaBridge 145:64910690c574 53 * - tm_year
AnnaBridge 145:64910690c574 54 * Other fields are ignored and won't be renormalized by a call to this function.
AnnaBridge 145:64910690c574 55 * A valid calendar time is comprised between the 1st january of 1970 at
AnnaBridge 145:64910690c574 56 * 00:00:00 and the 19th of january 2038 at 03:14:07.
AnnaBridge 145:64910690c574 57 *
AnnaBridge 145:64910690c574 58 * @return The calendar time as seconds since UNIX epoch if the input is in the
AnnaBridge 145:64910690c574 59 * valid range. Otherwise ((time_t) -1).
AnnaBridge 145:64910690c574 60 *
AnnaBridge 145:64910690c574 61 * @note Leap seconds are not supported.
AnnaBridge 145:64910690c574 62 * @note Values in output range from 0 to INT_MAX.
AnnaBridge 145:64910690c574 63 * @note - For use by the HAL only
AnnaBridge 145:64910690c574 64 */
AnnaBridge 145:64910690c574 65 time_t _rtc_mktime(const struct tm* calendar_time);
AnnaBridge 145:64910690c574 66
AnnaBridge 145:64910690c574 67 /* Convert a given time in seconds since epoch into calendar time.
AnnaBridge 145:64910690c574 68 *
AnnaBridge 145:64910690c574 69 * This function is a thread safe (partial) replacement for localtime. It is
AnnaBridge 145:64910690c574 70 * tailored around RTC peripherals specification and is not by any means a
AnnaBridge 145:64910690c574 71 * complete of localtime.
AnnaBridge 145:64910690c574 72 *
AnnaBridge 145:64910690c574 73 * @param timestamp The time (in seconds) to convert into calendar time. Valid
AnnaBridge 145:64910690c574 74 * input are in the range [0 : INT32_MAX].
AnnaBridge 145:64910690c574 75 * @param calendar_time Pointer to the object which will contain the result of
AnnaBridge 145:64910690c574 76 * the conversion. The tm fields filled by this function are:
AnnaBridge 145:64910690c574 77 * - tm_sec
AnnaBridge 145:64910690c574 78 * - tm_min
AnnaBridge 145:64910690c574 79 * - tm_hour
AnnaBridge 145:64910690c574 80 * - tm_mday
AnnaBridge 145:64910690c574 81 * - tm_mon
AnnaBridge 145:64910690c574 82 * - tm_year
AnnaBridge 145:64910690c574 83 * - tm_wday
AnnaBridge 145:64910690c574 84 * - tm_yday
AnnaBridge 145:64910690c574 85 * The object remains untouched if the time in input is invalid.
AnnaBridge 145:64910690c574 86 * @return true if the conversion was successful, false otherwise.
AnnaBridge 145:64910690c574 87 *
AnnaBridge 145:64910690c574 88 * @note - For use by the HAL only
AnnaBridge 145:64910690c574 89 */
AnnaBridge 145:64910690c574 90 bool _rtc_localtime(time_t timestamp, struct tm* calendar_time);
AnnaBridge 145:64910690c574 91
AnnaBridge 145:64910690c574 92 #ifdef __cplusplus
AnnaBridge 145:64910690c574 93 }
AnnaBridge 145:64910690c574 94 #endif
AnnaBridge 145:64910690c574 95
AnnaBridge 145:64910690c574 96 #endif /* MBED_MKTIME_H */
AnnaBridge 145:64910690c574 97
AnnaBridge 145:64910690c574 98 /** @}*/