proj raimes sinal acqusition for biomedical signals

Fork of mbed-rtos by mbed official

Committer:
bogdanm
Date:
Mon Aug 05 14:12:52 2013 +0300
Revision:
13:869ef732a8a2
Parent:
rtx/LPC1768/GCC_ARM/HAL_CM3.s@6:350b53afb889
Update sources to revision 64

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 6:350b53afb889 1 /*----------------------------------------------------------------------------
emilmont 6:350b53afb889 2 * RL-ARM - RTX
emilmont 6:350b53afb889 3 *----------------------------------------------------------------------------
emilmont 6:350b53afb889 4 * Name: HAL_CM3.S
emilmont 6:350b53afb889 5 * Purpose: Hardware Abstraction Layer for Cortex-M3
emilmont 6:350b53afb889 6 * Rev.: V4.60
emilmont 6:350b53afb889 7 *----------------------------------------------------------------------------
emilmont 6:350b53afb889 8 *
emilmont 6:350b53afb889 9 * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
emilmont 6:350b53afb889 10 * All rights reserved.
emilmont 6:350b53afb889 11 * Redistribution and use in source and binary forms, with or without
emilmont 6:350b53afb889 12 * modification, are permitted provided that the following conditions are met:
emilmont 6:350b53afb889 13 * - Redistributions of source code must retain the above copyright
emilmont 6:350b53afb889 14 * notice, this list of conditions and the following disclaimer.
emilmont 6:350b53afb889 15 * - Redistributions in binary form must reproduce the above copyright
emilmont 6:350b53afb889 16 * notice, this list of conditions and the following disclaimer in the
emilmont 6:350b53afb889 17 * documentation and/or other materials provided with the distribution.
emilmont 6:350b53afb889 18 * - Neither the name of ARM nor the names of its contributors may be used
emilmont 6:350b53afb889 19 * to endorse or promote products derived from this software without
emilmont 6:350b53afb889 20 * specific prior written permission.
emilmont 6:350b53afb889 21 *
emilmont 6:350b53afb889 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
emilmont 6:350b53afb889 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
emilmont 6:350b53afb889 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
emilmont 6:350b53afb889 25 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
emilmont 6:350b53afb889 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
emilmont 6:350b53afb889 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
emilmont 6:350b53afb889 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
emilmont 6:350b53afb889 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
emilmont 6:350b53afb889 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
emilmont 6:350b53afb889 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
emilmont 6:350b53afb889 32 * POSSIBILITY OF SUCH DAMAGE.
emilmont 6:350b53afb889 33 *---------------------------------------------------------------------------*/
emilmont 6:350b53afb889 34
emilmont 6:350b53afb889 35 .file "HAL_CM3.S"
emilmont 6:350b53afb889 36 .syntax unified
emilmont 6:350b53afb889 37
emilmont 6:350b53afb889 38 .equ TCB_TSTACK, 36
emilmont 6:350b53afb889 39
emilmont 6:350b53afb889 40
emilmont 6:350b53afb889 41 /*----------------------------------------------------------------------------
emilmont 6:350b53afb889 42 * Functions
emilmont 6:350b53afb889 43 *---------------------------------------------------------------------------*/
emilmont 6:350b53afb889 44
emilmont 6:350b53afb889 45 .thumb
emilmont 6:350b53afb889 46
emilmont 6:350b53afb889 47 .section ".text"
emilmont 6:350b53afb889 48 .align 2
emilmont 6:350b53afb889 49
emilmont 6:350b53afb889 50
emilmont 6:350b53afb889 51 /*--------------------------- rt_set_PSP ------------------------------------*/
emilmont 6:350b53afb889 52
emilmont 6:350b53afb889 53 # void rt_set_PSP (U32 stack);
emilmont 6:350b53afb889 54
emilmont 6:350b53afb889 55 .thumb_func
emilmont 6:350b53afb889 56 .type rt_set_PSP, %function
emilmont 6:350b53afb889 57 .global rt_set_PSP
emilmont 6:350b53afb889 58 rt_set_PSP:
emilmont 6:350b53afb889 59 .fnstart
emilmont 6:350b53afb889 60 .cantunwind
emilmont 6:350b53afb889 61
emilmont 6:350b53afb889 62 MSR PSP,R0
emilmont 6:350b53afb889 63 BX LR
emilmont 6:350b53afb889 64
emilmont 6:350b53afb889 65 .fnend
emilmont 6:350b53afb889 66 .size rt_set_PSP, .-rt_set_PSP
emilmont 6:350b53afb889 67
emilmont 6:350b53afb889 68
emilmont 6:350b53afb889 69 /*--------------------------- rt_get_PSP ------------------------------------*/
emilmont 6:350b53afb889 70
emilmont 6:350b53afb889 71 # U32 rt_get_PSP (void);
emilmont 6:350b53afb889 72
emilmont 6:350b53afb889 73 .thumb_func
emilmont 6:350b53afb889 74 .type rt_get_PSP, %function
emilmont 6:350b53afb889 75 .global rt_get_PSP
emilmont 6:350b53afb889 76 rt_get_PSP:
emilmont 6:350b53afb889 77 .fnstart
emilmont 6:350b53afb889 78 .cantunwind
emilmont 6:350b53afb889 79
emilmont 6:350b53afb889 80 MRS R0,PSP
emilmont 6:350b53afb889 81 BX LR
emilmont 6:350b53afb889 82
emilmont 6:350b53afb889 83 .fnend
emilmont 6:350b53afb889 84 .size rt_get_PSP, .-rt_get_PSP
emilmont 6:350b53afb889 85
emilmont 6:350b53afb889 86
emilmont 6:350b53afb889 87 /*--------------------------- os_set_env ------------------------------------*/
emilmont 6:350b53afb889 88
emilmont 6:350b53afb889 89 # void os_set_env (void);
emilmont 6:350b53afb889 90 /* Switch to Unprivileged/Privileged Thread mode, use PSP. */
emilmont 6:350b53afb889 91
emilmont 6:350b53afb889 92 .thumb_func
emilmont 6:350b53afb889 93 .type os_set_env, %function
emilmont 6:350b53afb889 94 .global os_set_env
emilmont 6:350b53afb889 95 os_set_env:
emilmont 6:350b53afb889 96 .fnstart
emilmont 6:350b53afb889 97 .cantunwind
emilmont 6:350b53afb889 98
emilmont 6:350b53afb889 99 MOV R0,SP /* PSP = MSP */
emilmont 6:350b53afb889 100 MSR PSP,R0
emilmont 6:350b53afb889 101 LDR R0,=os_flags
emilmont 6:350b53afb889 102 LDRB R0,[R0]
emilmont 6:350b53afb889 103 LSLS R0,#31
emilmont 6:350b53afb889 104 ITE NE
emilmont 6:350b53afb889 105 MOVNE R0,#0x02 /* Privileged Thread mode, use PSP */
emilmont 6:350b53afb889 106 MOVEQ R0,#0x03 /* Unprivileged Thread mode, use PSP */
emilmont 6:350b53afb889 107 MSR CONTROL,R0
emilmont 6:350b53afb889 108 BX LR
emilmont 6:350b53afb889 109
emilmont 6:350b53afb889 110 .fnend
emilmont 6:350b53afb889 111 .size os_set_env, .-os_set_env
emilmont 6:350b53afb889 112
emilmont 6:350b53afb889 113
emilmont 6:350b53afb889 114 /*--------------------------- _alloc_box ------------------------------------*/
emilmont 6:350b53afb889 115
emilmont 6:350b53afb889 116 # void *_alloc_box (void *box_mem);
emilmont 6:350b53afb889 117 /* Function wrapper for Unprivileged/Privileged mode. */
emilmont 6:350b53afb889 118
emilmont 6:350b53afb889 119 .thumb_func
emilmont 6:350b53afb889 120 .type _alloc_box, %function
emilmont 6:350b53afb889 121 .global _alloc_box
emilmont 6:350b53afb889 122 _alloc_box:
emilmont 6:350b53afb889 123 .fnstart
emilmont 6:350b53afb889 124 .cantunwind
emilmont 6:350b53afb889 125
emilmont 6:350b53afb889 126 LDR R12,=rt_alloc_box
emilmont 6:350b53afb889 127 MRS R3,IPSR
emilmont 6:350b53afb889 128 LSLS R3,#24
emilmont 6:350b53afb889 129 IT NE
emilmont 6:350b53afb889 130 BXNE R12
emilmont 6:350b53afb889 131 MRS R3,CONTROL
emilmont 6:350b53afb889 132 LSLS R3,#31
emilmont 6:350b53afb889 133 IT EQ
emilmont 6:350b53afb889 134 BXEQ R12
emilmont 6:350b53afb889 135 SVC 0
emilmont 6:350b53afb889 136 BX LR
emilmont 6:350b53afb889 137
emilmont 6:350b53afb889 138 .fnend
emilmont 6:350b53afb889 139 .size _alloc_box, .-_alloc_box
emilmont 6:350b53afb889 140
emilmont 6:350b53afb889 141
emilmont 6:350b53afb889 142 /*--------------------------- _free_box -------------------------------------*/
emilmont 6:350b53afb889 143
emilmont 6:350b53afb889 144 # int _free_box (void *box_mem, void *box);
emilmont 6:350b53afb889 145 /* Function wrapper for Unprivileged/Privileged mode. */
emilmont 6:350b53afb889 146
emilmont 6:350b53afb889 147 .thumb_func
emilmont 6:350b53afb889 148 .type _free_box, %function
emilmont 6:350b53afb889 149 .global _free_box
emilmont 6:350b53afb889 150 _free_box:
emilmont 6:350b53afb889 151 .fnstart
emilmont 6:350b53afb889 152 .cantunwind
emilmont 6:350b53afb889 153
emilmont 6:350b53afb889 154 LDR R12,=rt_free_box
emilmont 6:350b53afb889 155 MRS R3,IPSR
emilmont 6:350b53afb889 156 LSLS R3,#24
emilmont 6:350b53afb889 157 IT NE
emilmont 6:350b53afb889 158 BXNE R12
emilmont 6:350b53afb889 159 MRS R3,CONTROL
emilmont 6:350b53afb889 160 LSLS R3,#31
emilmont 6:350b53afb889 161 IT EQ
emilmont 6:350b53afb889 162 BXEQ R12
emilmont 6:350b53afb889 163 SVC 0
emilmont 6:350b53afb889 164 BX LR
emilmont 6:350b53afb889 165
emilmont 6:350b53afb889 166 .fnend
emilmont 6:350b53afb889 167 .size _free_box, .-_free_box
emilmont 6:350b53afb889 168
emilmont 6:350b53afb889 169
emilmont 6:350b53afb889 170 /*-------------------------- SVC_Handler ------------------------------------*/
emilmont 6:350b53afb889 171
emilmont 6:350b53afb889 172 # void SVC_Handler (void);
emilmont 6:350b53afb889 173
emilmont 6:350b53afb889 174 .thumb_func
emilmont 6:350b53afb889 175 .type SVC_Handler, %function
emilmont 6:350b53afb889 176 .global SVC_Handler
emilmont 6:350b53afb889 177 SVC_Handler:
emilmont 6:350b53afb889 178 .fnstart
emilmont 6:350b53afb889 179 .cantunwind
emilmont 6:350b53afb889 180
emilmont 6:350b53afb889 181 MRS R0,PSP /* Read PSP */
emilmont 6:350b53afb889 182 LDR R1,[R0,#24] /* Read Saved PC from Stack */
emilmont 6:350b53afb889 183 LDRB R1,[R1,#-2] /* Load SVC Number */
emilmont 6:350b53afb889 184 CBNZ R1,SVC_User
emilmont 6:350b53afb889 185
emilmont 6:350b53afb889 186 LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */
emilmont 6:350b53afb889 187 BLX R12 /* Call SVC Function */
emilmont 6:350b53afb889 188
emilmont 6:350b53afb889 189 MRS R12,PSP /* Read PSP */
emilmont 6:350b53afb889 190 STM R12,{R0-R2} /* Store return values */
emilmont 6:350b53afb889 191
emilmont 6:350b53afb889 192 LDR R3,=os_tsk
emilmont 6:350b53afb889 193 LDM R3,{R1,R2} /* os_tsk.run, os_tsk.new */
emilmont 6:350b53afb889 194 CMP R1,R2
emilmont 6:350b53afb889 195 BEQ SVC_Exit /* no task switch */
emilmont 6:350b53afb889 196
emilmont 6:350b53afb889 197 CBZ R1,SVC_Next /* Runtask deleted? */
emilmont 6:350b53afb889 198 STMDB R12!,{R4-R11} /* Save Old context */
emilmont 6:350b53afb889 199 STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
emilmont 6:350b53afb889 200
emilmont 6:350b53afb889 201 PUSH {R2,R3}
emilmont 6:350b53afb889 202 BL rt_stk_check /* Check for Stack overflow */
emilmont 6:350b53afb889 203 POP {R2,R3}
emilmont 6:350b53afb889 204
emilmont 6:350b53afb889 205 SVC_Next:
emilmont 6:350b53afb889 206 STR R2,[R3] /* os_tsk.run = os_tsk.new */
emilmont 6:350b53afb889 207
emilmont 6:350b53afb889 208 LDR R12,[R2,#TCB_TSTACK] /* os_tsk.new->tsk_stack */
emilmont 6:350b53afb889 209 LDMIA R12!,{R4-R11} /* Restore New Context */
emilmont 6:350b53afb889 210 MSR PSP,R12 /* Write PSP */
emilmont 6:350b53afb889 211
emilmont 6:350b53afb889 212 SVC_Exit:
emilmont 6:350b53afb889 213 MVN LR,#~0xFFFFFFFD /* set EXC_RETURN value */
emilmont 6:350b53afb889 214 BX LR
emilmont 6:350b53afb889 215
emilmont 6:350b53afb889 216 /*------------------- User SVC ------------------------------*/
emilmont 6:350b53afb889 217
emilmont 6:350b53afb889 218 SVC_User:
emilmont 6:350b53afb889 219 PUSH {R4,LR} /* Save Registers */
emilmont 6:350b53afb889 220 LDR R2,=SVC_Count
emilmont 6:350b53afb889 221 LDR R2,[R2]
emilmont 6:350b53afb889 222 CMP R1,R2
emilmont 6:350b53afb889 223 BHI SVC_Done /* Overflow */
emilmont 6:350b53afb889 224
emilmont 6:350b53afb889 225 LDR R4,=SVC_Table-4
emilmont 6:350b53afb889 226 LDR R4,[R4,R1,LSL #2] /* Load SVC Function Address */
emilmont 6:350b53afb889 227
emilmont 6:350b53afb889 228 LDM R0,{R0-R3,R12} /* Read R0-R3,R12 from stack */
emilmont 6:350b53afb889 229 BLX R4 /* Call SVC Function */
emilmont 6:350b53afb889 230
emilmont 6:350b53afb889 231 MRS R12,PSP
emilmont 6:350b53afb889 232 STM R12,{R0-R3} /* Function return values */
emilmont 6:350b53afb889 233 SVC_Done:
emilmont 6:350b53afb889 234 POP {R4,PC} /* RETI */
emilmont 6:350b53afb889 235
emilmont 6:350b53afb889 236 .fnend
emilmont 6:350b53afb889 237 .size SVC_Handler, .-SVC_Handler
emilmont 6:350b53afb889 238
emilmont 6:350b53afb889 239
emilmont 6:350b53afb889 240 /*-------------------------- PendSV_Handler ---------------------------------*/
emilmont 6:350b53afb889 241
emilmont 6:350b53afb889 242 # void PendSV_Handler (void);
emilmont 6:350b53afb889 243
emilmont 6:350b53afb889 244 .thumb_func
emilmont 6:350b53afb889 245 .type PendSV_Handler, %function
emilmont 6:350b53afb889 246 .global PendSV_Handler
emilmont 6:350b53afb889 247 .global Sys_Switch
emilmont 6:350b53afb889 248 PendSV_Handler:
emilmont 6:350b53afb889 249 .fnstart
emilmont 6:350b53afb889 250 .cantunwind
emilmont 6:350b53afb889 251
emilmont 6:350b53afb889 252 BL rt_pop_req
emilmont 6:350b53afb889 253
emilmont 6:350b53afb889 254 Sys_Switch:
emilmont 6:350b53afb889 255 LDR R3,=os_tsk
emilmont 6:350b53afb889 256 LDM R3,{R1,R2} /* os_tsk.run, os_tsk.new */
emilmont 6:350b53afb889 257 CMP R1,R2
emilmont 6:350b53afb889 258 BEQ Sys_Exit
emilmont 6:350b53afb889 259
emilmont 6:350b53afb889 260 MRS R12,PSP /* Read PSP */
emilmont 6:350b53afb889 261 STMDB R12!,{R4-R11} /* Save Old context */
emilmont 6:350b53afb889 262 STR R12,[R1,#TCB_TSTACK] /* Update os_tsk.run->tsk_stack */
emilmont 6:350b53afb889 263
emilmont 6:350b53afb889 264 PUSH {R2,R3}
emilmont 6:350b53afb889 265 BL rt_stk_check /* Check for Stack overflow */
emilmont 6:350b53afb889 266 POP {R2,R3}
emilmont 6:350b53afb889 267
emilmont 6:350b53afb889 268 STR R2,[R3] /* os_tsk.run = os_tsk.new */
emilmont 6:350b53afb889 269
emilmont 6:350b53afb889 270 LDR R12,[R2,#TCB_TSTACK] /* os_tsk.new->tsk_stack */
emilmont 6:350b53afb889 271 LDMIA R12!,{R4-R11} /* Restore New Context */
emilmont 6:350b53afb889 272 MSR PSP,R12 /* Write PSP */
emilmont 6:350b53afb889 273
emilmont 6:350b53afb889 274 Sys_Exit:
emilmont 6:350b53afb889 275 MVN LR,#~0xFFFFFFFD /* set EXC_RETURN value */
emilmont 6:350b53afb889 276 BX LR /* Return to Thread Mode */
emilmont 6:350b53afb889 277
emilmont 6:350b53afb889 278 .fnend
emilmont 6:350b53afb889 279 .size PendSV_Handler, .-PendSV_Handler
emilmont 6:350b53afb889 280
emilmont 6:350b53afb889 281
emilmont 6:350b53afb889 282 /*-------------------------- SysTick_Handler --------------------------------*/
emilmont 6:350b53afb889 283
emilmont 6:350b53afb889 284 # void SysTick_Handler (void);
emilmont 6:350b53afb889 285
emilmont 6:350b53afb889 286 .thumb_func
emilmont 6:350b53afb889 287 .type SysTick_Handler, %function
emilmont 6:350b53afb889 288 .global SysTick_Handler
emilmont 6:350b53afb889 289 SysTick_Handler:
emilmont 6:350b53afb889 290 .fnstart
emilmont 6:350b53afb889 291 .cantunwind
emilmont 6:350b53afb889 292
emilmont 6:350b53afb889 293 BL rt_systick
emilmont 6:350b53afb889 294 B Sys_Switch
emilmont 6:350b53afb889 295
emilmont 6:350b53afb889 296 .fnend
emilmont 6:350b53afb889 297 .size SysTick_Handler, .-SysTick_Handler
emilmont 6:350b53afb889 298
emilmont 6:350b53afb889 299
emilmont 6:350b53afb889 300 /*-------------------------- OS_Tick_Handler --------------------------------*/
emilmont 6:350b53afb889 301
emilmont 6:350b53afb889 302 # void OS_Tick_Handler (void);
emilmont 6:350b53afb889 303
emilmont 6:350b53afb889 304 .thumb_func
emilmont 6:350b53afb889 305 .type OS_Tick_Handler, %function
emilmont 6:350b53afb889 306 .global OS_Tick_Handler
emilmont 6:350b53afb889 307 OS_Tick_Handler:
emilmont 6:350b53afb889 308 .fnstart
emilmont 6:350b53afb889 309 .cantunwind
emilmont 6:350b53afb889 310
emilmont 6:350b53afb889 311 BL os_tick_irqack
emilmont 6:350b53afb889 312 BL rt_systick
emilmont 6:350b53afb889 313 B Sys_Switch
emilmont 6:350b53afb889 314
emilmont 6:350b53afb889 315 .fnend
emilmont 6:350b53afb889 316 .size OS_Tick_Handler, .-OS_Tick_Handler
emilmont 6:350b53afb889 317
emilmont 6:350b53afb889 318
emilmont 6:350b53afb889 319 .end
emilmont 6:350b53afb889 320
emilmont 6:350b53afb889 321 /*----------------------------------------------------------------------------
emilmont 6:350b53afb889 322 * end of file
emilmont 6:350b53afb889 323 *---------------------------------------------------------------------------*/