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