Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

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