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