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