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 *
sahilmgandhi 18:6a4db94011d3 3 * Part one of the system initialization code, contains low-level
sahilmgandhi 18:6a4db94011d3 4 * initialization, plain thumb variant.
sahilmgandhi 18:6a4db94011d3 5 *
sahilmgandhi 18:6a4db94011d3 6 * Copyright 2011 IAR Systems. All rights reserved.
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * $Revision: 47876 $
sahilmgandhi 18:6a4db94011d3 9 *
sahilmgandhi 18:6a4db94011d3 10 **************************************************/
sahilmgandhi 18:6a4db94011d3 11
sahilmgandhi 18:6a4db94011d3 12 ;
sahilmgandhi 18:6a4db94011d3 13 ; The modules in this file are included in the libraries, and may be replaced
sahilmgandhi 18:6a4db94011d3 14 ; by any user-defined modules that define the PUBLIC symbol _program_start or
sahilmgandhi 18:6a4db94011d3 15 ; a user defined start symbol.
sahilmgandhi 18:6a4db94011d3 16 ; To override the cstartup defined in the library, simply add your modified
sahilmgandhi 18:6a4db94011d3 17 ; version to the workbench project.
sahilmgandhi 18:6a4db94011d3 18 ;
sahilmgandhi 18:6a4db94011d3 19 ; The vector table is normally located at address 0.
sahilmgandhi 18:6a4db94011d3 20 ; When debugging in RAM, it can be located in RAM, aligned to at least 2^6.
sahilmgandhi 18:6a4db94011d3 21 ; The name "__vector_table" has special meaning for C-SPY:
sahilmgandhi 18:6a4db94011d3 22 ; it is where the SP start value is found, and the NVIC vector
sahilmgandhi 18:6a4db94011d3 23 ; table register (VTOR) is initialized to this address if != 0.
sahilmgandhi 18:6a4db94011d3 24 ;
sahilmgandhi 18:6a4db94011d3 25 ; Cortex-M version
sahilmgandhi 18:6a4db94011d3 26 ;
sahilmgandhi 18:6a4db94011d3 27
sahilmgandhi 18:6a4db94011d3 28
sahilmgandhi 18:6a4db94011d3 29 MODULE ?cstartup
sahilmgandhi 18:6a4db94011d3 30
sahilmgandhi 18:6a4db94011d3 31 ;; Forward declaration of sections.
sahilmgandhi 18:6a4db94011d3 32 SECTION CSTACK:DATA:NOROOT(3)
sahilmgandhi 18:6a4db94011d3 33
sahilmgandhi 18:6a4db94011d3 34 SECTION .intvec:CODE:NOROOT(2)
sahilmgandhi 18:6a4db94011d3 35
sahilmgandhi 18:6a4db94011d3 36 EXTERN __iar_program_start
sahilmgandhi 18:6a4db94011d3 37 EXTERN SystemInit
sahilmgandhi 18:6a4db94011d3 38 PUBLIC __vector_table
sahilmgandhi 18:6a4db94011d3 39 PUBLIC __vector_table_0x1c
sahilmgandhi 18:6a4db94011d3 40 PUBLIC __Vectors
sahilmgandhi 18:6a4db94011d3 41 PUBLIC __Vectors_End
sahilmgandhi 18:6a4db94011d3 42 PUBLIC __Vectors_Size
sahilmgandhi 18:6a4db94011d3 43
sahilmgandhi 18:6a4db94011d3 44 DATA
sahilmgandhi 18:6a4db94011d3 45
sahilmgandhi 18:6a4db94011d3 46 __vector_table
sahilmgandhi 18:6a4db94011d3 47 DCD sfe(CSTACK)
sahilmgandhi 18:6a4db94011d3 48 DCD Reset_Handler
sahilmgandhi 18:6a4db94011d3 49 DCD NMI_Handler
sahilmgandhi 18:6a4db94011d3 50 DCD HardFault_Handler
sahilmgandhi 18:6a4db94011d3 51 DCD 0
sahilmgandhi 18:6a4db94011d3 52 DCD 0
sahilmgandhi 18:6a4db94011d3 53 DCD 0
sahilmgandhi 18:6a4db94011d3 54 __vector_table_0x1c
sahilmgandhi 18:6a4db94011d3 55 DCD 0
sahilmgandhi 18:6a4db94011d3 56 DCD 0
sahilmgandhi 18:6a4db94011d3 57 DCD 0
sahilmgandhi 18:6a4db94011d3 58 DCD 0
sahilmgandhi 18:6a4db94011d3 59 DCD SVC_Handler
sahilmgandhi 18:6a4db94011d3 60 DCD 0
sahilmgandhi 18:6a4db94011d3 61 DCD 0
sahilmgandhi 18:6a4db94011d3 62 DCD PendSV_Handler
sahilmgandhi 18:6a4db94011d3 63 DCD SysTick_Handler
sahilmgandhi 18:6a4db94011d3 64
sahilmgandhi 18:6a4db94011d3 65 ; External Interrupts
sahilmgandhi 18:6a4db94011d3 66 DCD SPI0_IRQHandler ; SPI0 controller
sahilmgandhi 18:6a4db94011d3 67 DCD SPI1_IRQHandler ; SPI1 controller
sahilmgandhi 18:6a4db94011d3 68 DCD 0 ; Reserved
sahilmgandhi 18:6a4db94011d3 69 DCD UART0_IRQHandler ; UART0
sahilmgandhi 18:6a4db94011d3 70 DCD UART1_IRQHandler ; UART1
sahilmgandhi 18:6a4db94011d3 71 DCD UART2_IRQHandler ; UART2
sahilmgandhi 18:6a4db94011d3 72 DCD 0 ; Reserved
sahilmgandhi 18:6a4db94011d3 73 DCD I2C1_IRQHandler ; I2C1 controller
sahilmgandhi 18:6a4db94011d3 74 DCD I2C0_IRQHandler ; I2C0 controller
sahilmgandhi 18:6a4db94011d3 75 DCD SCT_IRQHandler ; Smart Counter Timer
sahilmgandhi 18:6a4db94011d3 76 DCD MRT_IRQHandler ; Multi-Rate Timer
sahilmgandhi 18:6a4db94011d3 77 DCD CMP_IRQHandler ; Comparator
sahilmgandhi 18:6a4db94011d3 78 DCD WDT_IRQHandler ; PIO1 (0:11)
sahilmgandhi 18:6a4db94011d3 79 DCD BOD_IRQHandler ; Brown Out Detect
sahilmgandhi 18:6a4db94011d3 80 DCD Flash_IRQHandler ; Flash interrupt
sahilmgandhi 18:6a4db94011d3 81 DCD WKT_IRQHandler ; Wakeup timer
sahilmgandhi 18:6a4db94011d3 82 DCD ADC_SEQA_IRQHandler ; ADC sequence A completion
sahilmgandhi 18:6a4db94011d3 83 DCD ADC_SEQB_IRQHandler ; ADC sequence B completion
sahilmgandhi 18:6a4db94011d3 84 DCD ADC_THCMP_IRQHandler ; ADC threshold compare
sahilmgandhi 18:6a4db94011d3 85 DCD ADC_OVR_IRQHandler ; ADC overrun
sahilmgandhi 18:6a4db94011d3 86 DCD DMA__RQHandler ; DMA interrupt
sahilmgandhi 18:6a4db94011d3 87 DCD I2C2_IRQHandler ; I2C2 controller
sahilmgandhi 18:6a4db94011d3 88 DCD I2C3_IRQHandler ; I2C3 controller
sahilmgandhi 18:6a4db94011d3 89 DCD 0 ; Reserved
sahilmgandhi 18:6a4db94011d3 90 DCD PININT0_IRQHandler ; PIO INT0
sahilmgandhi 18:6a4db94011d3 91 DCD PININT1_IRQHandler ; PIO INT1
sahilmgandhi 18:6a4db94011d3 92 DCD PININT2_IRQHandler ; PIO INT2
sahilmgandhi 18:6a4db94011d3 93 DCD PININT3_IRQHandler ; PIO INT3
sahilmgandhi 18:6a4db94011d3 94 DCD PININT4_IRQHandler ; PIO INT4
sahilmgandhi 18:6a4db94011d3 95 DCD PININT5_IRQHandler ; PIO INT5
sahilmgandhi 18:6a4db94011d3 96 DCD PININT6_IRQHandler ; PIO INT6
sahilmgandhi 18:6a4db94011d3 97 DCD PININT7_IRQHandler ; PIO INT7
sahilmgandhi 18:6a4db94011d3 98 __Vectors_End
sahilmgandhi 18:6a4db94011d3 99
sahilmgandhi 18:6a4db94011d3 100 __Vectors EQU __vector_table
sahilmgandhi 18:6a4db94011d3 101 __Vectors_Size EQU __Vectors_End - __Vectors
sahilmgandhi 18:6a4db94011d3 102
sahilmgandhi 18:6a4db94011d3 103 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sahilmgandhi 18:6a4db94011d3 104 ;;
sahilmgandhi 18:6a4db94011d3 105 ;; Default interrupt handlers.
sahilmgandhi 18:6a4db94011d3 106 ;;
sahilmgandhi 18:6a4db94011d3 107 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sahilmgandhi 18:6a4db94011d3 108
sahilmgandhi 18:6a4db94011d3 109 THUMB
sahilmgandhi 18:6a4db94011d3 110 PUBWEAK Reset_Handler
sahilmgandhi 18:6a4db94011d3 111 SECTION .text:CODE:NOROOT:REORDER(2)
sahilmgandhi 18:6a4db94011d3 112 Reset_Handler
sahilmgandhi 18:6a4db94011d3 113 LDR R0, =SystemInit
sahilmgandhi 18:6a4db94011d3 114 BLX R0
sahilmgandhi 18:6a4db94011d3 115 LDR R0, =__iar_program_start
sahilmgandhi 18:6a4db94011d3 116 BX R0
sahilmgandhi 18:6a4db94011d3 117
sahilmgandhi 18:6a4db94011d3 118 PUBWEAK NMI_Handler
sahilmgandhi 18:6a4db94011d3 119 PUBWEAK HardFault_Handler
sahilmgandhi 18:6a4db94011d3 120 PUBWEAK SVC_Handler
sahilmgandhi 18:6a4db94011d3 121 PUBWEAK PendSV_Handler
sahilmgandhi 18:6a4db94011d3 122 PUBWEAK SysTick_Handler
sahilmgandhi 18:6a4db94011d3 123 PUBWEAK SPI0_IRQHandler
sahilmgandhi 18:6a4db94011d3 124 PUBWEAK SPI1_IRQHandler
sahilmgandhi 18:6a4db94011d3 125 PUBWEAK UART0_IRQHandler
sahilmgandhi 18:6a4db94011d3 126 PUBWEAK UART1_IRQHandler
sahilmgandhi 18:6a4db94011d3 127 PUBWEAK UART2_IRQHandler
sahilmgandhi 18:6a4db94011d3 128 PUBWEAK I2C1_IRQHandler
sahilmgandhi 18:6a4db94011d3 129 PUBWEAK I2C0_IRQHandler
sahilmgandhi 18:6a4db94011d3 130 PUBWEAK SCT_IRQHandler
sahilmgandhi 18:6a4db94011d3 131 PUBWEAK MRT_IRQHandler
sahilmgandhi 18:6a4db94011d3 132 PUBWEAK CMP_IRQHandler
sahilmgandhi 18:6a4db94011d3 133 PUBWEAK WDT_IRQHandler
sahilmgandhi 18:6a4db94011d3 134 PUBWEAK BOD_IRQHandler
sahilmgandhi 18:6a4db94011d3 135 PUBWEAK Flash_IRQHandler
sahilmgandhi 18:6a4db94011d3 136 PUBWEAK WKT_IRQHandler
sahilmgandhi 18:6a4db94011d3 137 PUBWEAK ADC_SEQA_IRQHandler
sahilmgandhi 18:6a4db94011d3 138 PUBWEAK ADC_SEQB_IRQHandler
sahilmgandhi 18:6a4db94011d3 139 PUBWEAK ADC_THCMP_IRQHandler
sahilmgandhi 18:6a4db94011d3 140 PUBWEAK ADC_OVR_IRQHandler
sahilmgandhi 18:6a4db94011d3 141 PUBWEAK DMA__RQHandler
sahilmgandhi 18:6a4db94011d3 142 PUBWEAK I2C2_IRQHandler
sahilmgandhi 18:6a4db94011d3 143 PUBWEAK I2C3_IRQHandler
sahilmgandhi 18:6a4db94011d3 144 PUBWEAK PININT0_IRQHandler
sahilmgandhi 18:6a4db94011d3 145 PUBWEAK PININT1_IRQHandler
sahilmgandhi 18:6a4db94011d3 146 PUBWEAK PININT2_IRQHandler
sahilmgandhi 18:6a4db94011d3 147 PUBWEAK PININT3_IRQHandler
sahilmgandhi 18:6a4db94011d3 148 PUBWEAK PININT4_IRQHandler
sahilmgandhi 18:6a4db94011d3 149 PUBWEAK PININT5_IRQHandler
sahilmgandhi 18:6a4db94011d3 150 PUBWEAK PININT6_IRQHandler
sahilmgandhi 18:6a4db94011d3 151 PUBWEAK PININT7_IRQHandler
sahilmgandhi 18:6a4db94011d3 152
sahilmgandhi 18:6a4db94011d3 153 SECTION .text:CODE:REORDER:NOROOT(1)
sahilmgandhi 18:6a4db94011d3 154 THUMB
sahilmgandhi 18:6a4db94011d3 155
sahilmgandhi 18:6a4db94011d3 156 NMI_Handler
sahilmgandhi 18:6a4db94011d3 157 HardFault_Handler
sahilmgandhi 18:6a4db94011d3 158 SVC_Handler
sahilmgandhi 18:6a4db94011d3 159 PendSV_Handler
sahilmgandhi 18:6a4db94011d3 160 SysTick_Handler
sahilmgandhi 18:6a4db94011d3 161 SPI0_IRQHandler
sahilmgandhi 18:6a4db94011d3 162 SPI1_IRQHandler
sahilmgandhi 18:6a4db94011d3 163 UART0_IRQHandler
sahilmgandhi 18:6a4db94011d3 164 UART1_IRQHandler
sahilmgandhi 18:6a4db94011d3 165 UART2_IRQHandler
sahilmgandhi 18:6a4db94011d3 166 I2C1_IRQHandler
sahilmgandhi 18:6a4db94011d3 167 I2C0_IRQHandler
sahilmgandhi 18:6a4db94011d3 168 SCT_IRQHandler
sahilmgandhi 18:6a4db94011d3 169 MRT_IRQHandler
sahilmgandhi 18:6a4db94011d3 170 CMP_IRQHandler
sahilmgandhi 18:6a4db94011d3 171 WDT_IRQHandler
sahilmgandhi 18:6a4db94011d3 172 BOD_IRQHandler
sahilmgandhi 18:6a4db94011d3 173 Flash_IRQHandler
sahilmgandhi 18:6a4db94011d3 174 WKT_IRQHandler
sahilmgandhi 18:6a4db94011d3 175 ADC_SEQA_IRQHandler
sahilmgandhi 18:6a4db94011d3 176 ADC_SEQB_IRQHandler
sahilmgandhi 18:6a4db94011d3 177 ADC_THCMP_IRQHandler
sahilmgandhi 18:6a4db94011d3 178 ADC_OVR_IRQHandler
sahilmgandhi 18:6a4db94011d3 179 DMA__RQHandler
sahilmgandhi 18:6a4db94011d3 180 I2C2_IRQHandler
sahilmgandhi 18:6a4db94011d3 181 I2C3_IRQHandler
sahilmgandhi 18:6a4db94011d3 182 PININT0_IRQHandler
sahilmgandhi 18:6a4db94011d3 183 PININT1_IRQHandler
sahilmgandhi 18:6a4db94011d3 184 PININT2_IRQHandler
sahilmgandhi 18:6a4db94011d3 185 PININT3_IRQHandler
sahilmgandhi 18:6a4db94011d3 186 PININT4_IRQHandler
sahilmgandhi 18:6a4db94011d3 187 PININT5_IRQHandler
sahilmgandhi 18:6a4db94011d3 188 PININT6_IRQHandler
sahilmgandhi 18:6a4db94011d3 189 PININT7_IRQHandler
sahilmgandhi 18:6a4db94011d3 190 Default_IRQHandler
sahilmgandhi 18:6a4db94011d3 191 B Default_IRQHandler
sahilmgandhi 18:6a4db94011d3 192
sahilmgandhi 18:6a4db94011d3 193 SECTION .crp:CODE:ROOT(2)
sahilmgandhi 18:6a4db94011d3 194 DATA
sahilmgandhi 18:6a4db94011d3 195 /* Code Read Protection
sahilmgandhi 18:6a4db94011d3 196 NO_ISP 0x4E697370 - Prevents sampling of pin PIO0_1 for entering ISP mode
sahilmgandhi 18:6a4db94011d3 197 CRP1 0x12345678 - Write to RAM command cannot access RAM below 0x10000300.
sahilmgandhi 18:6a4db94011d3 198 - Copy RAM to flash command can not write to Sector 0.
sahilmgandhi 18:6a4db94011d3 199 - Erase command can erase Sector 0 only when all sectors
sahilmgandhi 18:6a4db94011d3 200 are selected for erase.
sahilmgandhi 18:6a4db94011d3 201 - Compare command is disabled.
sahilmgandhi 18:6a4db94011d3 202 - Read Memory command is disabled.
sahilmgandhi 18:6a4db94011d3 203 CRP2 0x87654321 - Read Memory is disabled.
sahilmgandhi 18:6a4db94011d3 204 - Write to RAM is disabled.
sahilmgandhi 18:6a4db94011d3 205 - "Go" command is disabled.
sahilmgandhi 18:6a4db94011d3 206 - Copy RAM to flash is disabled.
sahilmgandhi 18:6a4db94011d3 207 - Compare is disabled.
sahilmgandhi 18:6a4db94011d3 208 CRP3 0x43218765 - Access to chip via the SWD pins is disabled. ISP entry
sahilmgandhi 18:6a4db94011d3 209 by pulling PIO0_1 LOW is disabled if a valid user code is
sahilmgandhi 18:6a4db94011d3 210 present in flash sector 0.
sahilmgandhi 18:6a4db94011d3 211 Caution: If CRP3 is selected, no future factory testing can be
sahilmgandhi 18:6a4db94011d3 212 performed on the device.
sahilmgandhi 18:6a4db94011d3 213 */
sahilmgandhi 18:6a4db94011d3 214 DCD 0xFFFFFFFF
sahilmgandhi 18:6a4db94011d3 215
sahilmgandhi 18:6a4db94011d3 216 END