mbed library for NZ32-SC151

Committer:
modtronix-com
Date:
Fri Aug 19 15:46:42 2016 +1000
Revision:
17:639ed60ce759
Parent:
1:71204b8406f2
Added tag v1.1 for changeset 076cbe3e55be

Who changed what in which revision?

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