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