Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /**
sahilmgandhi 18:6a4db94011d3 2 * \file
sahilmgandhi 18:6a4db94011d3 3 *
sahilmgandhi 18:6a4db94011d3 4 * \brief Common Delay Service
sahilmgandhi 18:6a4db94011d3 5 *
sahilmgandhi 18:6a4db94011d3 6 * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * \asf_license_start
sahilmgandhi 18:6a4db94011d3 9 *
sahilmgandhi 18:6a4db94011d3 10 * \page License
sahilmgandhi 18:6a4db94011d3 11 *
sahilmgandhi 18:6a4db94011d3 12 * Redistribution and use in source and binary forms, with or without
sahilmgandhi 18:6a4db94011d3 13 * modification, are permitted provided that the following conditions are met:
sahilmgandhi 18:6a4db94011d3 14 *
sahilmgandhi 18:6a4db94011d3 15 * 1. Redistributions of source code must retain the above copyright notice,
sahilmgandhi 18:6a4db94011d3 16 * this list of conditions and the following disclaimer.
sahilmgandhi 18:6a4db94011d3 17 *
sahilmgandhi 18:6a4db94011d3 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
sahilmgandhi 18:6a4db94011d3 19 * this list of conditions and the following disclaimer in the documentation
sahilmgandhi 18:6a4db94011d3 20 * and/or other materials provided with the distribution.
sahilmgandhi 18:6a4db94011d3 21 *
sahilmgandhi 18:6a4db94011d3 22 * 3. The name of Atmel may not be used to endorse or promote products derived
sahilmgandhi 18:6a4db94011d3 23 * from this software without specific prior written permission.
sahilmgandhi 18:6a4db94011d3 24 *
sahilmgandhi 18:6a4db94011d3 25 * 4. This software may only be redistributed and used in connection with an
sahilmgandhi 18:6a4db94011d3 26 * Atmel microcontroller product.
sahilmgandhi 18:6a4db94011d3 27 *
sahilmgandhi 18:6a4db94011d3 28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
sahilmgandhi 18:6a4db94011d3 29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
sahilmgandhi 18:6a4db94011d3 30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
sahilmgandhi 18:6a4db94011d3 31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
sahilmgandhi 18:6a4db94011d3 32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sahilmgandhi 18:6a4db94011d3 33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sahilmgandhi 18:6a4db94011d3 34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sahilmgandhi 18:6a4db94011d3 35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
sahilmgandhi 18:6a4db94011d3 36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
sahilmgandhi 18:6a4db94011d3 37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
sahilmgandhi 18:6a4db94011d3 38 * POSSIBILITY OF SUCH DAMAGE.
sahilmgandhi 18:6a4db94011d3 39 *
sahilmgandhi 18:6a4db94011d3 40 * \asf_license_stop
sahilmgandhi 18:6a4db94011d3 41 *
sahilmgandhi 18:6a4db94011d3 42 */
sahilmgandhi 18:6a4db94011d3 43 /*
sahilmgandhi 18:6a4db94011d3 44 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
sahilmgandhi 18:6a4db94011d3 45 */
sahilmgandhi 18:6a4db94011d3 46 #ifndef _DELAY_H_
sahilmgandhi 18:6a4db94011d3 47 #define _DELAY_H_
sahilmgandhi 18:6a4db94011d3 48
sahilmgandhi 18:6a4db94011d3 49 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 50 extern "C" {
sahilmgandhi 18:6a4db94011d3 51 #endif
sahilmgandhi 18:6a4db94011d3 52
sahilmgandhi 18:6a4db94011d3 53 #include <sysclk.h>
sahilmgandhi 18:6a4db94011d3 54
sahilmgandhi 18:6a4db94011d3 55 #if UC3
sahilmgandhi 18:6a4db94011d3 56 # include <cycle_counter.h>
sahilmgandhi 18:6a4db94011d3 57 #elif XMEGA
sahilmgandhi 18:6a4db94011d3 58 # include "xmega/cycle_counter.h"
sahilmgandhi 18:6a4db94011d3 59 #elif MEGA
sahilmgandhi 18:6a4db94011d3 60 # include "mega/cycle_counter.h"
sahilmgandhi 18:6a4db94011d3 61 #elif SAM
sahilmgandhi 18:6a4db94011d3 62 # include "sam/cycle_counter.h"
sahilmgandhi 18:6a4db94011d3 63 #endif
sahilmgandhi 18:6a4db94011d3 64
sahilmgandhi 18:6a4db94011d3 65 /**
sahilmgandhi 18:6a4db94011d3 66 * @defgroup group_common_services_delay Busy-Wait Delay Routines
sahilmgandhi 18:6a4db94011d3 67 *
sahilmgandhi 18:6a4db94011d3 68 * This module provides simple loop-based delay routines for those
sahilmgandhi 18:6a4db94011d3 69 * applications requiring a brief wait during execution. Common API
sahilmgandhi 18:6a4db94011d3 70 * for UC3, XMEGA, and AVR MEGA.
sahilmgandhi 18:6a4db94011d3 71 *
sahilmgandhi 18:6a4db94011d3 72 * @{
sahilmgandhi 18:6a4db94011d3 73 */
sahilmgandhi 18:6a4db94011d3 74
sahilmgandhi 18:6a4db94011d3 75 /**
sahilmgandhi 18:6a4db94011d3 76 * @def F_CPU
sahilmgandhi 18:6a4db94011d3 77 * @brief MCU Clock Frequency (Hertz)
sahilmgandhi 18:6a4db94011d3 78 *
sahilmgandhi 18:6a4db94011d3 79 * @deprecated
sahilmgandhi 18:6a4db94011d3 80 * The \ref F_CPU configuration constant is used for compatibility with the
sahilmgandhi 18:6a4db94011d3 81 * \ref group_common_services_delay routines. The common loop-based delay
sahilmgandhi 18:6a4db94011d3 82 * routines are designed to use the \ref clk_group modules while anticipating
sahilmgandhi 18:6a4db94011d3 83 * support for legacy applications assuming a statically defined clock
sahilmgandhi 18:6a4db94011d3 84 * frequency. Applications using a statically configured MCU clock frequency
sahilmgandhi 18:6a4db94011d3 85 * can define \ref F_CPU (Hertz), in which case the common delay routines will
sahilmgandhi 18:6a4db94011d3 86 * use this value rather than calling sysclk_get_cpu_hz() to get the current
sahilmgandhi 18:6a4db94011d3 87 * MCU clock frequency.
sahilmgandhi 18:6a4db94011d3 88 */
sahilmgandhi 18:6a4db94011d3 89 #ifndef F_CPU
sahilmgandhi 18:6a4db94011d3 90 # define F_CPU sysclk_get_cpu_hz()
sahilmgandhi 18:6a4db94011d3 91 #endif
sahilmgandhi 18:6a4db94011d3 92
sahilmgandhi 18:6a4db94011d3 93 /**
sahilmgandhi 18:6a4db94011d3 94 * @def delay_init
sahilmgandhi 18:6a4db94011d3 95 *
sahilmgandhi 18:6a4db94011d3 96 * @brief Initialize the delay driver.
sahilmgandhi 18:6a4db94011d3 97 * @param fcpu_hz CPU frequency in Hz
sahilmgandhi 18:6a4db94011d3 98 *
sahilmgandhi 18:6a4db94011d3 99 * @deprecated
sahilmgandhi 18:6a4db94011d3 100 * This function is provided for compatibility with ASF applications that
sahilmgandhi 18:6a4db94011d3 101 * may not have been updated to configure the system clock via the common
sahilmgandhi 18:6a4db94011d3 102 * clock service; e.g. sysclk_init() and a configuration header file are
sahilmgandhi 18:6a4db94011d3 103 * used to configure clocks.
sahilmgandhi 18:6a4db94011d3 104 *
sahilmgandhi 18:6a4db94011d3 105 * The functions in this module call \ref sysclk_get_cpu_hz() function to
sahilmgandhi 18:6a4db94011d3 106 * obtain the system clock frequency.
sahilmgandhi 18:6a4db94011d3 107 */
sahilmgandhi 18:6a4db94011d3 108 #define delay_init(fcpu_hz)
sahilmgandhi 18:6a4db94011d3 109
sahilmgandhi 18:6a4db94011d3 110 /**
sahilmgandhi 18:6a4db94011d3 111 * @def delay_s
sahilmgandhi 18:6a4db94011d3 112 * @brief Delay in seconds.
sahilmgandhi 18:6a4db94011d3 113 * @param delay Delay in seconds
sahilmgandhi 18:6a4db94011d3 114 */
sahilmgandhi 18:6a4db94011d3 115 #define delay_s(delay) cpu_delay_ms(1000 * delay, F_CPU)
sahilmgandhi 18:6a4db94011d3 116
sahilmgandhi 18:6a4db94011d3 117 /**
sahilmgandhi 18:6a4db94011d3 118 * @def delay_ms
sahilmgandhi 18:6a4db94011d3 119 * @brief Delay in milliseconds.
sahilmgandhi 18:6a4db94011d3 120 * @param delay Delay in milliseconds
sahilmgandhi 18:6a4db94011d3 121 */
sahilmgandhi 18:6a4db94011d3 122 #define delay_ms(delay) cpu_delay_ms(delay, F_CPU)
sahilmgandhi 18:6a4db94011d3 123
sahilmgandhi 18:6a4db94011d3 124 /**
sahilmgandhi 18:6a4db94011d3 125 * @def delay_us
sahilmgandhi 18:6a4db94011d3 126 * @brief Delay in microseconds.
sahilmgandhi 18:6a4db94011d3 127 * @param delay Delay in microseconds
sahilmgandhi 18:6a4db94011d3 128 */
sahilmgandhi 18:6a4db94011d3 129 #define delay_us(delay) cpu_delay_us(delay, F_CPU)
sahilmgandhi 18:6a4db94011d3 130
sahilmgandhi 18:6a4db94011d3 131 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 132 }
sahilmgandhi 18:6a4db94011d3 133 #endif
sahilmgandhi 18:6a4db94011d3 134
sahilmgandhi 18:6a4db94011d3 135 /**
sahilmgandhi 18:6a4db94011d3 136 * @}
sahilmgandhi 18:6a4db94011d3 137 */
sahilmgandhi 18:6a4db94011d3 138
sahilmgandhi 18:6a4db94011d3 139 #endif /* _DELAY_H_ */