test

Dependents:   robotic_fish_6

Committer:
juansal12
Date:
Fri Dec 03 23:00:34 2021 +0000
Revision:
0:c792b17d9f78
uploaded sofi code ;

Who changed what in which revision?

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