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 Copyright (c) 2013, Nordic Semiconductor ASA
sahilmgandhi 18:6a4db94011d3 3 All rights reserved.
sahilmgandhi 18:6a4db94011d3 4
sahilmgandhi 18:6a4db94011d3 5 Redistribution and use in source and binary forms, with or without
sahilmgandhi 18:6a4db94011d3 6 modification, are permitted provided that the following conditions are met:
sahilmgandhi 18:6a4db94011d3 7
sahilmgandhi 18:6a4db94011d3 8 * Redistributions of source code must retain the above copyright notice, this
sahilmgandhi 18:6a4db94011d3 9 list of conditions and the following disclaimer.
sahilmgandhi 18:6a4db94011d3 10
sahilmgandhi 18:6a4db94011d3 11 * Redistributions in binary form must reproduce the above copyright notice,
sahilmgandhi 18:6a4db94011d3 12 this list of conditions and the following disclaimer in the documentation
sahilmgandhi 18:6a4db94011d3 13 and/or other materials provided with the distribution.
sahilmgandhi 18:6a4db94011d3 14
sahilmgandhi 18:6a4db94011d3 15 * Neither the name of Nordic Semiconductor ASA nor the names of its
sahilmgandhi 18:6a4db94011d3 16 contributors may be used to endorse or promote products derived from
sahilmgandhi 18:6a4db94011d3 17 this software without specific prior written permission.
sahilmgandhi 18:6a4db94011d3 18
sahilmgandhi 18:6a4db94011d3 19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
sahilmgandhi 18:6a4db94011d3 20 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sahilmgandhi 18:6a4db94011d3 21 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
sahilmgandhi 18:6a4db94011d3 22 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
sahilmgandhi 18:6a4db94011d3 23 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sahilmgandhi 18:6a4db94011d3 24 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
sahilmgandhi 18:6a4db94011d3 25 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
sahilmgandhi 18:6a4db94011d3 26 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
sahilmgandhi 18:6a4db94011d3 27 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
sahilmgandhi 18:6a4db94011d3 28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
sahilmgandhi 18:6a4db94011d3 29 */
sahilmgandhi 18:6a4db94011d3 30
sahilmgandhi 18:6a4db94011d3 31 /*
sahilmgandhi 18:6a4db94011d3 32 NOTE: Template files (including this one) are application specific and therefore
sahilmgandhi 18:6a4db94011d3 33 expected to be copied into the application project folder prior to its use!
sahilmgandhi 18:6a4db94011d3 34 */
sahilmgandhi 18:6a4db94011d3 35
sahilmgandhi 18:6a4db94011d3 36 .syntax unified
sahilmgandhi 18:6a4db94011d3 37 .arch armv6-m
sahilmgandhi 18:6a4db94011d3 38
sahilmgandhi 18:6a4db94011d3 39 .section .stack
sahilmgandhi 18:6a4db94011d3 40 .align 3
sahilmgandhi 18:6a4db94011d3 41 #ifdef __STACK_SIZE
sahilmgandhi 18:6a4db94011d3 42 .equ Stack_Size, __STACK_SIZE
sahilmgandhi 18:6a4db94011d3 43 #else
sahilmgandhi 18:6a4db94011d3 44 .equ Stack_Size, 2048
sahilmgandhi 18:6a4db94011d3 45 #endif
sahilmgandhi 18:6a4db94011d3 46 .globl Stack_Size
sahilmgandhi 18:6a4db94011d3 47 .globl __StackTop
sahilmgandhi 18:6a4db94011d3 48 .globl __StackLimit
sahilmgandhi 18:6a4db94011d3 49 __StackLimit:
sahilmgandhi 18:6a4db94011d3 50 .space Stack_Size
sahilmgandhi 18:6a4db94011d3 51 .size __StackLimit, . - __StackLimit
sahilmgandhi 18:6a4db94011d3 52 __StackTop:
sahilmgandhi 18:6a4db94011d3 53 .size __StackTop, . - __StackTop
sahilmgandhi 18:6a4db94011d3 54
sahilmgandhi 18:6a4db94011d3 55 .section .heap
sahilmgandhi 18:6a4db94011d3 56 .align 3
sahilmgandhi 18:6a4db94011d3 57 .globl __HeapBase
sahilmgandhi 18:6a4db94011d3 58 .globl __HeapLimit
sahilmgandhi 18:6a4db94011d3 59
sahilmgandhi 18:6a4db94011d3 60 .section .Vectors
sahilmgandhi 18:6a4db94011d3 61 .align 2
sahilmgandhi 18:6a4db94011d3 62 .globl __Vectors
sahilmgandhi 18:6a4db94011d3 63 __Vectors:
sahilmgandhi 18:6a4db94011d3 64 .long __StackTop /* Top of Stack */
sahilmgandhi 18:6a4db94011d3 65 .long Reset_Handler /* Reset Handler */
sahilmgandhi 18:6a4db94011d3 66 .long NMI_Handler /* NMI Handler */
sahilmgandhi 18:6a4db94011d3 67 .long HardFault_Handler /* Hard Fault Handler */
sahilmgandhi 18:6a4db94011d3 68 .long 0 /* Reserved */
sahilmgandhi 18:6a4db94011d3 69 .long 0 /* Reserved */
sahilmgandhi 18:6a4db94011d3 70 .long 0 /* Reserved */
sahilmgandhi 18:6a4db94011d3 71 .long 0 /* Reserved */
sahilmgandhi 18:6a4db94011d3 72 .long 0 /* Reserved */
sahilmgandhi 18:6a4db94011d3 73 .long 0 /* Reserved */
sahilmgandhi 18:6a4db94011d3 74 .long 0 /* Reserved */
sahilmgandhi 18:6a4db94011d3 75 .long SVC_Handler /* SVCall Handler */
sahilmgandhi 18:6a4db94011d3 76 .long 0 /* Reserved */
sahilmgandhi 18:6a4db94011d3 77 .long 0 /* Reserved */
sahilmgandhi 18:6a4db94011d3 78 .long PendSV_Handler /* PendSV Handler */
sahilmgandhi 18:6a4db94011d3 79 .long SysTick_Handler /* SysTick Handler */
sahilmgandhi 18:6a4db94011d3 80
sahilmgandhi 18:6a4db94011d3 81 /* External Interrupts */
sahilmgandhi 18:6a4db94011d3 82 .long POWER_CLOCK_IRQHandler /*POWER_CLOCK */
sahilmgandhi 18:6a4db94011d3 83 .long RADIO_IRQHandler /*RADIO */
sahilmgandhi 18:6a4db94011d3 84 .long UART0_IRQHandler /*UART0 */
sahilmgandhi 18:6a4db94011d3 85 .long SPI0_TWI0_IRQHandler /*SPI0_TWI0 */
sahilmgandhi 18:6a4db94011d3 86 .long SPI1_TWI1_IRQHandler /*SPI1_TWI1 */
sahilmgandhi 18:6a4db94011d3 87 .long 0 /*Reserved */
sahilmgandhi 18:6a4db94011d3 88 .long GPIOTE_IRQHandler /*GPIOTE */
sahilmgandhi 18:6a4db94011d3 89 .long ADC_IRQHandler /*ADC */
sahilmgandhi 18:6a4db94011d3 90 .long TIMER0_IRQHandler /*TIMER0 */
sahilmgandhi 18:6a4db94011d3 91 .long TIMER1_IRQHandler /*TIMER1 */
sahilmgandhi 18:6a4db94011d3 92 .long TIMER2_IRQHandler /*TIMER2 */
sahilmgandhi 18:6a4db94011d3 93 .long RTC0_IRQHandler /*RTC0 */
sahilmgandhi 18:6a4db94011d3 94 .long TEMP_IRQHandler /*TEMP */
sahilmgandhi 18:6a4db94011d3 95 .long RNG_IRQHandler /*RNG */
sahilmgandhi 18:6a4db94011d3 96 .long ECB_IRQHandler /*ECB */
sahilmgandhi 18:6a4db94011d3 97 .long CCM_AAR_IRQHandler /*CCM_AAR */
sahilmgandhi 18:6a4db94011d3 98 .long WDT_IRQHandler /*WDT */
sahilmgandhi 18:6a4db94011d3 99 .long RTC1_IRQHandler /*RTC1 */
sahilmgandhi 18:6a4db94011d3 100 .long QDEC_IRQHandler /*QDEC */
sahilmgandhi 18:6a4db94011d3 101 .long LPCOMP_IRQHandler /*LPCOMP */
sahilmgandhi 18:6a4db94011d3 102 .long SWI0_IRQHandler /*SWI0 */
sahilmgandhi 18:6a4db94011d3 103 .long SWI1_IRQHandler /*SWI1 */
sahilmgandhi 18:6a4db94011d3 104 .long SWI2_IRQHandler /*SWI2 */
sahilmgandhi 18:6a4db94011d3 105 .long SWI3_IRQHandler /*SWI3 */
sahilmgandhi 18:6a4db94011d3 106 .long SWI4_IRQHandler /*SWI4 */
sahilmgandhi 18:6a4db94011d3 107 .long SWI5_IRQHandler /*SWI5 */
sahilmgandhi 18:6a4db94011d3 108 .long 0 /*Reserved */
sahilmgandhi 18:6a4db94011d3 109 .long 0 /*Reserved */
sahilmgandhi 18:6a4db94011d3 110 .long 0 /*Reserved */
sahilmgandhi 18:6a4db94011d3 111 .long 0 /*Reserved */
sahilmgandhi 18:6a4db94011d3 112 .long 0 /*Reserved */
sahilmgandhi 18:6a4db94011d3 113 .long 0 /*Reserved */
sahilmgandhi 18:6a4db94011d3 114
sahilmgandhi 18:6a4db94011d3 115
sahilmgandhi 18:6a4db94011d3 116 .size __Vectors, . - __Vectors
sahilmgandhi 18:6a4db94011d3 117
sahilmgandhi 18:6a4db94011d3 118 /* Reset Handler */
sahilmgandhi 18:6a4db94011d3 119
sahilmgandhi 18:6a4db94011d3 120 .equ NRF_POWER_RAMON_ADDRESS, 0x40000524
sahilmgandhi 18:6a4db94011d3 121 .equ NRF_POWER_RAMON_RAMxON_ONMODE_Msk, 0x3
sahilmgandhi 18:6a4db94011d3 122
sahilmgandhi 18:6a4db94011d3 123 .text
sahilmgandhi 18:6a4db94011d3 124 .thumb
sahilmgandhi 18:6a4db94011d3 125 .thumb_func
sahilmgandhi 18:6a4db94011d3 126 .align 1
sahilmgandhi 18:6a4db94011d3 127 .globl Reset_Handler
sahilmgandhi 18:6a4db94011d3 128 .type Reset_Handler, %function
sahilmgandhi 18:6a4db94011d3 129 Reset_Handler:
sahilmgandhi 18:6a4db94011d3 130 .fnstart
sahilmgandhi 18:6a4db94011d3 131
sahilmgandhi 18:6a4db94011d3 132 /* Make sure ALL RAM banks are powered on */
sahilmgandhi 18:6a4db94011d3 133 LDR R0, =NRF_POWER_RAMON_ADDRESS
sahilmgandhi 18:6a4db94011d3 134 LDR R2, [R0]
sahilmgandhi 18:6a4db94011d3 135 MOVS R1, #NRF_POWER_RAMON_RAMxON_ONMODE_Msk
sahilmgandhi 18:6a4db94011d3 136 ORRS R2, R1
sahilmgandhi 18:6a4db94011d3 137 STR R2, [R0]
sahilmgandhi 18:6a4db94011d3 138
sahilmgandhi 18:6a4db94011d3 139 /* Loop to copy data from read only memory to RAM. The ranges
sahilmgandhi 18:6a4db94011d3 140 * of copy from/to are specified by following symbols evaluated in
sahilmgandhi 18:6a4db94011d3 141 * linker script.
sahilmgandhi 18:6a4db94011d3 142 * __etext: End of code section, i.e., begin of data sections to copy from.
sahilmgandhi 18:6a4db94011d3 143 * __data_start__/__data_end__: RAM address range that data should be
sahilmgandhi 18:6a4db94011d3 144 * copied to. Both must be aligned to 4 bytes boundary. */
sahilmgandhi 18:6a4db94011d3 145
sahilmgandhi 18:6a4db94011d3 146 ldr r1, =__etext
sahilmgandhi 18:6a4db94011d3 147 ldr r2, =__data_start__
sahilmgandhi 18:6a4db94011d3 148 ldr r3, =__data_end__
sahilmgandhi 18:6a4db94011d3 149
sahilmgandhi 18:6a4db94011d3 150 subs r3, r2
sahilmgandhi 18:6a4db94011d3 151 ble .LC0
sahilmgandhi 18:6a4db94011d3 152
sahilmgandhi 18:6a4db94011d3 153 .LC1:
sahilmgandhi 18:6a4db94011d3 154 subs r3, 4
sahilmgandhi 18:6a4db94011d3 155 ldr r0, [r1,r3]
sahilmgandhi 18:6a4db94011d3 156 str r0, [r2,r3]
sahilmgandhi 18:6a4db94011d3 157 bgt .LC1
sahilmgandhi 18:6a4db94011d3 158 .LC0:
sahilmgandhi 18:6a4db94011d3 159
sahilmgandhi 18:6a4db94011d3 160 LDR R0, =SystemInit
sahilmgandhi 18:6a4db94011d3 161 BLX R0
sahilmgandhi 18:6a4db94011d3 162 LDR R0, =_start
sahilmgandhi 18:6a4db94011d3 163 BX R0
sahilmgandhi 18:6a4db94011d3 164
sahilmgandhi 18:6a4db94011d3 165 .pool
sahilmgandhi 18:6a4db94011d3 166 .cantunwind
sahilmgandhi 18:6a4db94011d3 167 .fnend
sahilmgandhi 18:6a4db94011d3 168 .size Reset_Handler,.-Reset_Handler
sahilmgandhi 18:6a4db94011d3 169
sahilmgandhi 18:6a4db94011d3 170 .section ".text"
sahilmgandhi 18:6a4db94011d3 171
sahilmgandhi 18:6a4db94011d3 172
sahilmgandhi 18:6a4db94011d3 173 /* Dummy Exception Handlers (infinite loops which can be modified) */
sahilmgandhi 18:6a4db94011d3 174
sahilmgandhi 18:6a4db94011d3 175 .weak NMI_Handler
sahilmgandhi 18:6a4db94011d3 176 .type NMI_Handler, %function
sahilmgandhi 18:6a4db94011d3 177 NMI_Handler:
sahilmgandhi 18:6a4db94011d3 178 B .
sahilmgandhi 18:6a4db94011d3 179 .size NMI_Handler, . - NMI_Handler
sahilmgandhi 18:6a4db94011d3 180
sahilmgandhi 18:6a4db94011d3 181
sahilmgandhi 18:6a4db94011d3 182 .weak HardFault_Handler
sahilmgandhi 18:6a4db94011d3 183 .type HardFault_Handler, %function
sahilmgandhi 18:6a4db94011d3 184 HardFault_Handler:
sahilmgandhi 18:6a4db94011d3 185 B .
sahilmgandhi 18:6a4db94011d3 186 .size HardFault_Handler, . - HardFault_Handler
sahilmgandhi 18:6a4db94011d3 187
sahilmgandhi 18:6a4db94011d3 188
sahilmgandhi 18:6a4db94011d3 189 .weak SVC_Handler
sahilmgandhi 18:6a4db94011d3 190 .type SVC_Handler, %function
sahilmgandhi 18:6a4db94011d3 191 SVC_Handler:
sahilmgandhi 18:6a4db94011d3 192 B .
sahilmgandhi 18:6a4db94011d3 193 .size SVC_Handler, . - SVC_Handler
sahilmgandhi 18:6a4db94011d3 194
sahilmgandhi 18:6a4db94011d3 195
sahilmgandhi 18:6a4db94011d3 196 .weak PendSV_Handler
sahilmgandhi 18:6a4db94011d3 197 .type PendSV_Handler, %function
sahilmgandhi 18:6a4db94011d3 198 PendSV_Handler:
sahilmgandhi 18:6a4db94011d3 199 B .
sahilmgandhi 18:6a4db94011d3 200 .size PendSV_Handler, . - PendSV_Handler
sahilmgandhi 18:6a4db94011d3 201
sahilmgandhi 18:6a4db94011d3 202
sahilmgandhi 18:6a4db94011d3 203 .weak SysTick_Handler
sahilmgandhi 18:6a4db94011d3 204 .type SysTick_Handler, %function
sahilmgandhi 18:6a4db94011d3 205 SysTick_Handler:
sahilmgandhi 18:6a4db94011d3 206 B .
sahilmgandhi 18:6a4db94011d3 207 .size SysTick_Handler, . - SysTick_Handler
sahilmgandhi 18:6a4db94011d3 208
sahilmgandhi 18:6a4db94011d3 209
sahilmgandhi 18:6a4db94011d3 210 /* IRQ Handlers */
sahilmgandhi 18:6a4db94011d3 211
sahilmgandhi 18:6a4db94011d3 212 .globl Default_Handler
sahilmgandhi 18:6a4db94011d3 213 .type Default_Handler, %function
sahilmgandhi 18:6a4db94011d3 214 Default_Handler:
sahilmgandhi 18:6a4db94011d3 215 B .
sahilmgandhi 18:6a4db94011d3 216 .size Default_Handler, . - Default_Handler
sahilmgandhi 18:6a4db94011d3 217
sahilmgandhi 18:6a4db94011d3 218 .macro IRQ handler
sahilmgandhi 18:6a4db94011d3 219 .weak \handler
sahilmgandhi 18:6a4db94011d3 220 .set \handler, Default_Handler
sahilmgandhi 18:6a4db94011d3 221 .endm
sahilmgandhi 18:6a4db94011d3 222
sahilmgandhi 18:6a4db94011d3 223 IRQ POWER_CLOCK_IRQHandler
sahilmgandhi 18:6a4db94011d3 224 IRQ RADIO_IRQHandler
sahilmgandhi 18:6a4db94011d3 225 IRQ UART0_IRQHandler
sahilmgandhi 18:6a4db94011d3 226 IRQ SPI0_TWI0_IRQHandler
sahilmgandhi 18:6a4db94011d3 227 IRQ SPI1_TWI1_IRQHandler
sahilmgandhi 18:6a4db94011d3 228 IRQ GPIOTE_IRQHandler
sahilmgandhi 18:6a4db94011d3 229 IRQ ADC_IRQHandler
sahilmgandhi 18:6a4db94011d3 230 IRQ TIMER0_IRQHandler
sahilmgandhi 18:6a4db94011d3 231 IRQ TIMER1_IRQHandler
sahilmgandhi 18:6a4db94011d3 232 IRQ TIMER2_IRQHandler
sahilmgandhi 18:6a4db94011d3 233 IRQ RTC0_IRQHandler
sahilmgandhi 18:6a4db94011d3 234 IRQ TEMP_IRQHandler
sahilmgandhi 18:6a4db94011d3 235 IRQ RNG_IRQHandler
sahilmgandhi 18:6a4db94011d3 236 IRQ ECB_IRQHandler
sahilmgandhi 18:6a4db94011d3 237 IRQ CCM_AAR_IRQHandler
sahilmgandhi 18:6a4db94011d3 238 IRQ WDT_IRQHandler
sahilmgandhi 18:6a4db94011d3 239 IRQ RTC1_IRQHandler
sahilmgandhi 18:6a4db94011d3 240 IRQ QDEC_IRQHandler
sahilmgandhi 18:6a4db94011d3 241 IRQ LPCOMP_IRQHandler
sahilmgandhi 18:6a4db94011d3 242 IRQ SWI0_IRQHandler
sahilmgandhi 18:6a4db94011d3 243 IRQ SWI1_IRQHandler
sahilmgandhi 18:6a4db94011d3 244 IRQ SWI2_IRQHandler
sahilmgandhi 18:6a4db94011d3 245 IRQ SWI3_IRQHandler
sahilmgandhi 18:6a4db94011d3 246 IRQ SWI4_IRQHandler
sahilmgandhi 18:6a4db94011d3 247 IRQ SWI5_IRQHandler
sahilmgandhi 18:6a4db94011d3 248
sahilmgandhi 18:6a4db94011d3 249
sahilmgandhi 18:6a4db94011d3 250 .end