Control a robot over the internet using UDP and a Wifly module (WiFi).

Dependencies:   Motor TextLCD WiflyInterface mbed-rtos mbed

Committer:
apatel336
Date:
Thu Oct 17 13:27:56 2013 +0000
Revision:
0:c0dc3a76f3d4
Initial Release

Who changed what in which revision?

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