The prosthetic control(MIT)

Committer:
ganlikun
Date:
Thu Jun 23 05:23:34 2022 +0000
Revision:
0:20e0c61e0684
01

Who changed what in which revision?

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