Yihui Xiong / Mbed 2 deprecated Seeed_nRF51822_Motion

Dependencies:   mbed

Committer:
yihui
Date:
Mon Jan 11 02:32:24 2016 +0000
Revision:
0:638edba3adf6
initial

Who changed what in which revision?

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