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 /* mbed Microcontroller Library
sahilmgandhi 18:6a4db94011d3 2 * Copyright (c) 2016 ARM Limited
sahilmgandhi 18:6a4db94011d3 3 *
sahilmgandhi 18:6a4db94011d3 4 * Licensed under the Apache License, Version 2.0 (the "License");
sahilmgandhi 18:6a4db94011d3 5 * you may not use this file except in compliance with the License.
sahilmgandhi 18:6a4db94011d3 6 * You may obtain a copy of the License at
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * http://www.apache.org/licenses/LICENSE-2.0
sahilmgandhi 18:6a4db94011d3 9 *
sahilmgandhi 18:6a4db94011d3 10 * Unless required by applicable law or agreed to in writing, software
sahilmgandhi 18:6a4db94011d3 11 * distributed under the License is distributed on an "AS IS" BASIS,
sahilmgandhi 18:6a4db94011d3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sahilmgandhi 18:6a4db94011d3 13 * See the License for the specific language governing permissions and
sahilmgandhi 18:6a4db94011d3 14 * limitations under the License.
sahilmgandhi 18:6a4db94011d3 15 */
sahilmgandhi 18:6a4db94011d3 16
sahilmgandhi 18:6a4db94011d3 17 #ifndef _APB_DUAL_TIMER_DRV_H
sahilmgandhi 18:6a4db94011d3 18 #define _APB_DUAL_TIMER_DRV_H
sahilmgandhi 18:6a4db94011d3 19
sahilmgandhi 18:6a4db94011d3 20 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 21 extern "C" {
sahilmgandhi 18:6a4db94011d3 22 #endif
sahilmgandhi 18:6a4db94011d3 23
sahilmgandhi 18:6a4db94011d3 24 /* Supported Number of Dual Timers */
sahilmgandhi 18:6a4db94011d3 25 #define NUM_DUALTIMERS 1
sahilmgandhi 18:6a4db94011d3 26 #define DUALTIMER0 0
sahilmgandhi 18:6a4db94011d3 27 #define SINGLETIMER1 1
sahilmgandhi 18:6a4db94011d3 28 #define SINGLETIMER2 2
sahilmgandhi 18:6a4db94011d3 29 #define ALL_SINGLETIMERS 3
sahilmgandhi 18:6a4db94011d3 30
sahilmgandhi 18:6a4db94011d3 31 /*
sahilmgandhi 18:6a4db94011d3 32 * DualTimer_Initialize(): Initializes a hardware timer
sahilmgandhi 18:6a4db94011d3 33 * timer: timer to be Initialized
sahilmgandhi 18:6a4db94011d3 34 * time_us: timer reload value in us - 0 to reload to timer max value
sahilmgandhi 18:6a4db94011d3 35 * time_us = tick_value / TIMER_TICK_US
sahilmgandhi 18:6a4db94011d3 36 */
sahilmgandhi 18:6a4db94011d3 37 void DualTimer_Initialize(uint32_t timer, uint32_t time_us);
sahilmgandhi 18:6a4db94011d3 38
sahilmgandhi 18:6a4db94011d3 39 /* Enable Mode */
sahilmgandhi 18:6a4db94011d3 40 typedef uint8_t timerenable_t;
sahilmgandhi 18:6a4db94011d3 41 /* Interrupt */
sahilmgandhi 18:6a4db94011d3 42 #define DUALTIMER_INT_MASK (0)
sahilmgandhi 18:6a4db94011d3 43 #define DUALTIMER_INT (1 << DUALTIMER_INT_MASK)
sahilmgandhi 18:6a4db94011d3 44 /* 32 bit Counter */
sahilmgandhi 18:6a4db94011d3 45 #define DUALTIMER_COUNT_32_MASK (1)
sahilmgandhi 18:6a4db94011d3 46 #define DUALTIMER_COUNT_32 (1 << DUALTIMER_COUNT_32_MASK)
sahilmgandhi 18:6a4db94011d3 47 /* Periodic mode */
sahilmgandhi 18:6a4db94011d3 48 #define DUALTIMER_PERIODIC_MASK (2)
sahilmgandhi 18:6a4db94011d3 49 #define DUALTIMER_PERIODIC (1 << DUALTIMER_PERIODIC_MASK)
sahilmgandhi 18:6a4db94011d3 50 /* OneShot mode */
sahilmgandhi 18:6a4db94011d3 51 #define DUALTIMER_ONESHOT_MASK (3)
sahilmgandhi 18:6a4db94011d3 52 #define DUALTIMER_ONESHOT (1 << DUALTIMER_ONESHOT_MASK)
sahilmgandhi 18:6a4db94011d3 53
sahilmgandhi 18:6a4db94011d3 54 /* Default reload */
sahilmgandhi 18:6a4db94011d3 55 #define DUALTIMER_DEFAULT_RELOAD 0xFFFFFFFF
sahilmgandhi 18:6a4db94011d3 56
sahilmgandhi 18:6a4db94011d3 57 /*
sahilmgandhi 18:6a4db94011d3 58 * DualTimer_Enable(): Enables a hardware timer
sahilmgandhi 18:6a4db94011d3 59 * timer: timer to be enabled
sahilmgandhi 18:6a4db94011d3 60 * mode: enable mode
sahilmgandhi 18:6a4db94011d3 61 */
sahilmgandhi 18:6a4db94011d3 62 void DualTimer_Enable(uint32_t timer, timerenable_t mode);
sahilmgandhi 18:6a4db94011d3 63
sahilmgandhi 18:6a4db94011d3 64 /*
sahilmgandhi 18:6a4db94011d3 65 * DualTimer_Disable(): Disables a hardware timer
sahilmgandhi 18:6a4db94011d3 66 * timer: timer to be disabled
sahilmgandhi 18:6a4db94011d3 67 * dis_timer: 0 both - 1 dual timer 1 - 2 dual timer 2
sahilmgandhi 18:6a4db94011d3 68 */
sahilmgandhi 18:6a4db94011d3 69 void DualTimer_Disable(uint32_t timer, uint32_t dis_timer);
sahilmgandhi 18:6a4db94011d3 70
sahilmgandhi 18:6a4db94011d3 71 /*
sahilmgandhi 18:6a4db94011d3 72 * DualTimer_isEnabled(): verifies if a timer is enabled
sahilmgandhi 18:6a4db94011d3 73 * timer: timer to be verified
sahilmgandhi 18:6a4db94011d3 74 * @return: 0 disabled - 1 enabled
sahilmgandhi 18:6a4db94011d3 75 */
sahilmgandhi 18:6a4db94011d3 76 uint32_t DualTimer_isEnabled(uint32_t timer);
sahilmgandhi 18:6a4db94011d3 77
sahilmgandhi 18:6a4db94011d3 78 /*
sahilmgandhi 18:6a4db94011d3 79 * DualTimer_Read_1(): provides single timer 1 VALUE
sahilmgandhi 18:6a4db94011d3 80 * timer: timer to be read
sahilmgandhi 18:6a4db94011d3 81 * @return: timer VALUE us
sahilmgandhi 18:6a4db94011d3 82 */
sahilmgandhi 18:6a4db94011d3 83 uint32_t DualTimer_Read_1(uint32_t timer);
sahilmgandhi 18:6a4db94011d3 84
sahilmgandhi 18:6a4db94011d3 85 /*
sahilmgandhi 18:6a4db94011d3 86 * DualTimer_Read_2(): provides single timer 2 VALUE
sahilmgandhi 18:6a4db94011d3 87 * timer: timer to be read
sahilmgandhi 18:6a4db94011d3 88 * @return: timer VALUE us
sahilmgandhi 18:6a4db94011d3 89 */
sahilmgandhi 18:6a4db94011d3 90 uint32_t DualTimer_Read_2(uint32_t timer);
sahilmgandhi 18:6a4db94011d3 91
sahilmgandhi 18:6a4db94011d3 92 /*
sahilmgandhi 18:6a4db94011d3 93 * DualTimer_SetInterrupt_1(): sets timer 1 Interrupt
sahilmgandhi 18:6a4db94011d3 94 * timer: timer on which interrupt is set
sahilmgandhi 18:6a4db94011d3 95 * time_us: reloading value us
sahilmgandhi 18:6a4db94011d3 96 * mode: enable mode
sahilmgandhi 18:6a4db94011d3 97 */
sahilmgandhi 18:6a4db94011d3 98 void DualTimer_SetInterrupt_1(uint32_t timer, uint32_t time_us,
sahilmgandhi 18:6a4db94011d3 99 timerenable_t mode);
sahilmgandhi 18:6a4db94011d3 100
sahilmgandhi 18:6a4db94011d3 101 /*
sahilmgandhi 18:6a4db94011d3 102 * DualTimer_SetInterrupt_2(): sets timer 2 Interrupt
sahilmgandhi 18:6a4db94011d3 103 * timer: timer on which interrupt is set
sahilmgandhi 18:6a4db94011d3 104 * time_us: reloading value us
sahilmgandhi 18:6a4db94011d3 105 * mode: enable mode
sahilmgandhi 18:6a4db94011d3 106 */
sahilmgandhi 18:6a4db94011d3 107 void DualTimer_SetInterrupt_2(uint32_t timer, uint32_t time_us,
sahilmgandhi 18:6a4db94011d3 108 timerenable_t mode);
sahilmgandhi 18:6a4db94011d3 109
sahilmgandhi 18:6a4db94011d3 110 /*
sahilmgandhi 18:6a4db94011d3 111 * DualTimer_DisableInterrupt(): disables timer interrupts
sahilmgandhi 18:6a4db94011d3 112 * dualimer: dualtimer on which interrupt is disabled
sahilmgandhi 18:6a4db94011d3 113 * single_timer: single timer in the dualtimer on which
sahilmgandhi 18:6a4db94011d3 114 * interrupt is disabled
sahilmgandhi 18:6a4db94011d3 115 */
sahilmgandhi 18:6a4db94011d3 116 void DualTimer_DisableInterrupt(uint32_t dualtimer,
sahilmgandhi 18:6a4db94011d3 117 uint32_t single_timer);
sahilmgandhi 18:6a4db94011d3 118
sahilmgandhi 18:6a4db94011d3 119 /*
sahilmgandhi 18:6a4db94011d3 120 * DualTimer_ClearInterrupt(): clear timer interrupt
sahilmgandhi 18:6a4db94011d3 121 * timer: timer on which interrupt needs to be cleared
sahilmgandhi 18:6a4db94011d3 122 */
sahilmgandhi 18:6a4db94011d3 123 void DualTimer_ClearInterrupt(uint32_t timer);
sahilmgandhi 18:6a4db94011d3 124
sahilmgandhi 18:6a4db94011d3 125 /*
sahilmgandhi 18:6a4db94011d3 126 * DualTimer_GetIRQn(): returns IRQn of a DualTimer
sahilmgandhi 18:6a4db94011d3 127 * timer: timer on which IRQn is defined - 0 if it is not defined
sahilmgandhi 18:6a4db94011d3 128 */
sahilmgandhi 18:6a4db94011d3 129 uint32_t DualTimer_GetIRQn(uint32_t timer);
sahilmgandhi 18:6a4db94011d3 130
sahilmgandhi 18:6a4db94011d3 131 /*
sahilmgandhi 18:6a4db94011d3 132 * DualTimer_GetIRQInfo(): provides the single timer who caused
sahilmgandhi 18:6a4db94011d3 133 * the interrupt.
sahilmgandhi 18:6a4db94011d3 134 * timer: dualtimer that triggered the IRQ
sahilmgandhi 18:6a4db94011d3 135 * @return: a single timer
sahilmgandhi 18:6a4db94011d3 136 */
sahilmgandhi 18:6a4db94011d3 137 uint32_t DualTimer_GetIRQInfo(uint32_t dualtimer);
sahilmgandhi 18:6a4db94011d3 138
sahilmgandhi 18:6a4db94011d3 139 /*
sahilmgandhi 18:6a4db94011d3 140 * DualTimer_GetTicksUS(): returns the Ticks per us
sahilmgandhi 18:6a4db94011d3 141 * timer: timer associated with the Ticks per us
sahilmgandhi 18:6a4db94011d3 142 * @return: Ticks per us - 0 if the timer is disables
sahilmgandhi 18:6a4db94011d3 143 */
sahilmgandhi 18:6a4db94011d3 144 uint32_t DualTimer_GetTicksUS(uint32_t timer);
sahilmgandhi 18:6a4db94011d3 145
sahilmgandhi 18:6a4db94011d3 146 /*
sahilmgandhi 18:6a4db94011d3 147 * DualTimer_GetReloadValue(): returns the load value of the selected
sahilmgandhi 18:6a4db94011d3 148 * singletimer.
sahilmgandhi 18:6a4db94011d3 149 * timer: timer associated with the Ticks per us
sahilmgandhi 18:6a4db94011d3 150 * singletimer: selected singletimer
sahilmgandhi 18:6a4db94011d3 151 * @return: reload value of the selected singletimer
sahilmgandhi 18:6a4db94011d3 152 */
sahilmgandhi 18:6a4db94011d3 153 uint32_t DualTimer_GetReloadValue(uint32_t timer, uint32_t singletimer);
sahilmgandhi 18:6a4db94011d3 154
sahilmgandhi 18:6a4db94011d3 155 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 156 }
sahilmgandhi 18:6a4db94011d3 157 #endif
sahilmgandhi 18:6a4db94011d3 158 #endif /* _APB_DUAL_TIMER_DRV_H */