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