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