in OS_TSK, rename run as tsk_run and new as tsk_new.
rt_HAL_CM.h@0:5f46ebd8588e, 2012-09-02 (annotated)
- Committer:
- jonathonfletcher
- Date:
- Sun Sep 02 03:24:20 2012 +0000
- Revision:
- 0:5f46ebd8588e
in OS_TSK, rename run as tsk_run and new as tsk_new.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jonathonfletcher | 0:5f46ebd8588e | 1 | /*---------------------------------------------------------------------------- |
jonathonfletcher | 0:5f46ebd8588e | 2 | * RL-ARM - RTX |
jonathonfletcher | 0:5f46ebd8588e | 3 | *---------------------------------------------------------------------------- |
jonathonfletcher | 0:5f46ebd8588e | 4 | * Name: RT_HAL_CM.H |
jonathonfletcher | 0:5f46ebd8588e | 5 | * Purpose: Hardware Abstraction Layer for Cortex-M definitions |
jonathonfletcher | 0:5f46ebd8588e | 6 | * Rev.: V4.50 |
jonathonfletcher | 0:5f46ebd8588e | 7 | *---------------------------------------------------------------------------- |
jonathonfletcher | 0:5f46ebd8588e | 8 | * |
jonathonfletcher | 0:5f46ebd8588e | 9 | * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH |
jonathonfletcher | 0:5f46ebd8588e | 10 | * All rights reserved. |
jonathonfletcher | 0:5f46ebd8588e | 11 | * Redistribution and use in source and binary forms, with or without |
jonathonfletcher | 0:5f46ebd8588e | 12 | * modification, are permitted provided that the following conditions are met: |
jonathonfletcher | 0:5f46ebd8588e | 13 | * - Redistributions of source code must retain the above copyright |
jonathonfletcher | 0:5f46ebd8588e | 14 | * notice, this list of conditions and the following disclaimer. |
jonathonfletcher | 0:5f46ebd8588e | 15 | * - Redistributions in binary form must reproduce the above copyright |
jonathonfletcher | 0:5f46ebd8588e | 16 | * notice, this list of conditions and the following disclaimer in the |
jonathonfletcher | 0:5f46ebd8588e | 17 | * documentation and/or other materials provided with the distribution. |
jonathonfletcher | 0:5f46ebd8588e | 18 | * - Neither the name of ARM nor the names of its contributors may be used |
jonathonfletcher | 0:5f46ebd8588e | 19 | * to endorse or promote products derived from this software without |
jonathonfletcher | 0:5f46ebd8588e | 20 | * specific prior written permission. |
jonathonfletcher | 0:5f46ebd8588e | 21 | * |
jonathonfletcher | 0:5f46ebd8588e | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
jonathonfletcher | 0:5f46ebd8588e | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
jonathonfletcher | 0:5f46ebd8588e | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
jonathonfletcher | 0:5f46ebd8588e | 25 | * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
jonathonfletcher | 0:5f46ebd8588e | 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
jonathonfletcher | 0:5f46ebd8588e | 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
jonathonfletcher | 0:5f46ebd8588e | 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
jonathonfletcher | 0:5f46ebd8588e | 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
jonathonfletcher | 0:5f46ebd8588e | 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
jonathonfletcher | 0:5f46ebd8588e | 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
jonathonfletcher | 0:5f46ebd8588e | 32 | * POSSIBILITY OF SUCH DAMAGE. |
jonathonfletcher | 0:5f46ebd8588e | 33 | *---------------------------------------------------------------------------*/ |
jonathonfletcher | 0:5f46ebd8588e | 34 | |
jonathonfletcher | 0:5f46ebd8588e | 35 | /* Definitions */ |
jonathonfletcher | 0:5f46ebd8588e | 36 | #define INITIAL_xPSR 0x01000000 |
jonathonfletcher | 0:5f46ebd8588e | 37 | #define DEMCR_TRCENA 0x01000000 |
jonathonfletcher | 0:5f46ebd8588e | 38 | #define ITM_ITMENA 0x00000001 |
jonathonfletcher | 0:5f46ebd8588e | 39 | #define MAGIC_WORD 0xE25A2EA5 |
jonathonfletcher | 0:5f46ebd8588e | 40 | |
jonathonfletcher | 0:5f46ebd8588e | 41 | #if defined (__CC_ARM) /* ARM Compiler */ |
jonathonfletcher | 0:5f46ebd8588e | 42 | |
jonathonfletcher | 0:5f46ebd8588e | 43 | #if ((__TARGET_ARCH_7_M || __TARGET_ARCH_7E_M) && !NO_EXCLUSIVE_ACCESS) |
jonathonfletcher | 0:5f46ebd8588e | 44 | #define __USE_EXCLUSIVE_ACCESS |
jonathonfletcher | 0:5f46ebd8588e | 45 | #else |
jonathonfletcher | 0:5f46ebd8588e | 46 | #undef __USE_EXCLUSIVE_ACCESS |
jonathonfletcher | 0:5f46ebd8588e | 47 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 48 | |
jonathonfletcher | 0:5f46ebd8588e | 49 | #elif defined (__GNUC__) /* GNU Compiler */ |
jonathonfletcher | 0:5f46ebd8588e | 50 | |
jonathonfletcher | 0:5f46ebd8588e | 51 | #undef __USE_EXCLUSIVE_ACCESS |
jonathonfletcher | 0:5f46ebd8588e | 52 | |
jonathonfletcher | 0:5f46ebd8588e | 53 | #if defined (__CORTEX_M0) |
jonathonfletcher | 0:5f46ebd8588e | 54 | #define __TARGET_ARCH_6S_M 1 |
jonathonfletcher | 0:5f46ebd8588e | 55 | #else |
jonathonfletcher | 0:5f46ebd8588e | 56 | #define __TARGET_ARCH_6S_M 0 |
jonathonfletcher | 0:5f46ebd8588e | 57 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 58 | |
jonathonfletcher | 0:5f46ebd8588e | 59 | #if defined (__VFP_FP__) && !defined(__SOFTFP__) |
jonathonfletcher | 0:5f46ebd8588e | 60 | #define __TARGET_FPU_VFP 1 |
jonathonfletcher | 0:5f46ebd8588e | 61 | #else |
jonathonfletcher | 0:5f46ebd8588e | 62 | #define __TARGET_FPU_VFP 0 |
jonathonfletcher | 0:5f46ebd8588e | 63 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 64 | |
jonathonfletcher | 0:5f46ebd8588e | 65 | #define __inline inline |
jonathonfletcher | 0:5f46ebd8588e | 66 | #define __weak __attribute__((weak)) |
jonathonfletcher | 0:5f46ebd8588e | 67 | |
jonathonfletcher | 0:5f46ebd8588e | 68 | #ifndef __CMSIS_GENERIC |
jonathonfletcher | 0:5f46ebd8588e | 69 | |
jonathonfletcher | 0:5f46ebd8588e | 70 | __attribute__((always_inline)) static inline void __enable_irq(void) |
jonathonfletcher | 0:5f46ebd8588e | 71 | { |
jonathonfletcher | 0:5f46ebd8588e | 72 | __asm volatile ("cpsie i"); |
jonathonfletcher | 0:5f46ebd8588e | 73 | } |
jonathonfletcher | 0:5f46ebd8588e | 74 | |
jonathonfletcher | 0:5f46ebd8588e | 75 | __attribute__((always_inline)) static inline U32 __disable_irq(void) |
jonathonfletcher | 0:5f46ebd8588e | 76 | { |
jonathonfletcher | 0:5f46ebd8588e | 77 | U32 result; |
jonathonfletcher | 0:5f46ebd8588e | 78 | |
jonathonfletcher | 0:5f46ebd8588e | 79 | __asm volatile ("mrs %0, primask" : "=r" (result)); |
jonathonfletcher | 0:5f46ebd8588e | 80 | __asm volatile ("cpsid i"); |
jonathonfletcher | 0:5f46ebd8588e | 81 | return(result & 1); |
jonathonfletcher | 0:5f46ebd8588e | 82 | } |
jonathonfletcher | 0:5f46ebd8588e | 83 | |
jonathonfletcher | 0:5f46ebd8588e | 84 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 85 | |
jonathonfletcher | 0:5f46ebd8588e | 86 | __attribute__(( always_inline)) static inline U8 __clz(U32 value) |
jonathonfletcher | 0:5f46ebd8588e | 87 | { |
jonathonfletcher | 0:5f46ebd8588e | 88 | U8 result; |
jonathonfletcher | 0:5f46ebd8588e | 89 | |
jonathonfletcher | 0:5f46ebd8588e | 90 | __asm volatile ("clz %0, %1" : "=r" (result) : "r" (value)); |
jonathonfletcher | 0:5f46ebd8588e | 91 | return(result); |
jonathonfletcher | 0:5f46ebd8588e | 92 | } |
jonathonfletcher | 0:5f46ebd8588e | 93 | |
jonathonfletcher | 0:5f46ebd8588e | 94 | #elif defined (__ICCARM__) /* IAR Compiler */ |
jonathonfletcher | 0:5f46ebd8588e | 95 | |
jonathonfletcher | 0:5f46ebd8588e | 96 | #undef __USE_EXCLUSIVE_ACCESS |
jonathonfletcher | 0:5f46ebd8588e | 97 | |
jonathonfletcher | 0:5f46ebd8588e | 98 | #if (__CORE__ == __ARM6M__) |
jonathonfletcher | 0:5f46ebd8588e | 99 | #define __TARGET_ARCH_6S_M 1 |
jonathonfletcher | 0:5f46ebd8588e | 100 | #else |
jonathonfletcher | 0:5f46ebd8588e | 101 | #define __TARGET_ARCH_6S_M 0 |
jonathonfletcher | 0:5f46ebd8588e | 102 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 103 | |
jonathonfletcher | 0:5f46ebd8588e | 104 | #if defined __ARMVFP__ |
jonathonfletcher | 0:5f46ebd8588e | 105 | #define __TARGET_FPU_VFP 1 |
jonathonfletcher | 0:5f46ebd8588e | 106 | #else |
jonathonfletcher | 0:5f46ebd8588e | 107 | #define __TARGET_FPU_VFP 0 |
jonathonfletcher | 0:5f46ebd8588e | 108 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 109 | |
jonathonfletcher | 0:5f46ebd8588e | 110 | #define __inline inline |
jonathonfletcher | 0:5f46ebd8588e | 111 | |
jonathonfletcher | 0:5f46ebd8588e | 112 | #ifndef __CMSIS_GENERIC |
jonathonfletcher | 0:5f46ebd8588e | 113 | |
jonathonfletcher | 0:5f46ebd8588e | 114 | static inline void __enable_irq(void) |
jonathonfletcher | 0:5f46ebd8588e | 115 | { |
jonathonfletcher | 0:5f46ebd8588e | 116 | __asm volatile ("cpsie i"); |
jonathonfletcher | 0:5f46ebd8588e | 117 | } |
jonathonfletcher | 0:5f46ebd8588e | 118 | |
jonathonfletcher | 0:5f46ebd8588e | 119 | static inline U32 __disable_irq(void) |
jonathonfletcher | 0:5f46ebd8588e | 120 | { |
jonathonfletcher | 0:5f46ebd8588e | 121 | U32 result; |
jonathonfletcher | 0:5f46ebd8588e | 122 | |
jonathonfletcher | 0:5f46ebd8588e | 123 | __asm volatile ("mrs %0, primask" : "=r" (result)); |
jonathonfletcher | 0:5f46ebd8588e | 124 | __asm volatile ("cpsid i"); |
jonathonfletcher | 0:5f46ebd8588e | 125 | return(result & 1); |
jonathonfletcher | 0:5f46ebd8588e | 126 | } |
jonathonfletcher | 0:5f46ebd8588e | 127 | |
jonathonfletcher | 0:5f46ebd8588e | 128 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 129 | |
jonathonfletcher | 0:5f46ebd8588e | 130 | static inline U8 __clz(U32 value) |
jonathonfletcher | 0:5f46ebd8588e | 131 | { |
jonathonfletcher | 0:5f46ebd8588e | 132 | U8 result; |
jonathonfletcher | 0:5f46ebd8588e | 133 | |
jonathonfletcher | 0:5f46ebd8588e | 134 | __asm volatile ("clz %0, %1" : "=r" (result) : "r" (value)); |
jonathonfletcher | 0:5f46ebd8588e | 135 | return(result); |
jonathonfletcher | 0:5f46ebd8588e | 136 | } |
jonathonfletcher | 0:5f46ebd8588e | 137 | |
jonathonfletcher | 0:5f46ebd8588e | 138 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 139 | |
jonathonfletcher | 0:5f46ebd8588e | 140 | /* NVIC registers */ |
jonathonfletcher | 0:5f46ebd8588e | 141 | #define NVIC_ST_CTRL (*((volatile U32 *)0xE000E010)) |
jonathonfletcher | 0:5f46ebd8588e | 142 | #define NVIC_ST_RELOAD (*((volatile U32 *)0xE000E014)) |
jonathonfletcher | 0:5f46ebd8588e | 143 | #define NVIC_ST_CURRENT (*((volatile U32 *)0xE000E018)) |
jonathonfletcher | 0:5f46ebd8588e | 144 | #define NVIC_ISER ((volatile U32 *)0xE000E100) |
jonathonfletcher | 0:5f46ebd8588e | 145 | #define NVIC_ICER ((volatile U32 *)0xE000E180) |
jonathonfletcher | 0:5f46ebd8588e | 146 | #define NVIC_IP ((volatile U8 *)0xE000E400) |
jonathonfletcher | 0:5f46ebd8588e | 147 | #define NVIC_INT_CTRL (*((volatile U32 *)0xE000ED04)) |
jonathonfletcher | 0:5f46ebd8588e | 148 | #define NVIC_AIR_CTRL (*((volatile U32 *)0xE000ED0C)) |
jonathonfletcher | 0:5f46ebd8588e | 149 | #define NVIC_SYS_PRI2 (*((volatile U32 *)0xE000ED1C)) |
jonathonfletcher | 0:5f46ebd8588e | 150 | #define NVIC_SYS_PRI3 (*((volatile U32 *)0xE000ED20)) |
jonathonfletcher | 0:5f46ebd8588e | 151 | |
jonathonfletcher | 0:5f46ebd8588e | 152 | #define OS_PEND_IRQ() NVIC_INT_CTRL = (1<<28) |
jonathonfletcher | 0:5f46ebd8588e | 153 | #define OS_PENDING ((NVIC_INT_CTRL >> 26) & (1<<2 | 1)) |
jonathonfletcher | 0:5f46ebd8588e | 154 | #define OS_UNPEND(fl) NVIC_INT_CTRL = (*fl = OS_PENDING) << 25 |
jonathonfletcher | 0:5f46ebd8588e | 155 | #define OS_PEND(fl,p) NVIC_INT_CTRL = (fl | p<<2) << 26 |
jonathonfletcher | 0:5f46ebd8588e | 156 | #define OS_LOCK() NVIC_ST_CTRL = 0x0005 |
jonathonfletcher | 0:5f46ebd8588e | 157 | #define OS_UNLOCK() NVIC_ST_CTRL = 0x0007 |
jonathonfletcher | 0:5f46ebd8588e | 158 | |
jonathonfletcher | 0:5f46ebd8588e | 159 | #define OS_X_PENDING ((NVIC_INT_CTRL >> 28) & 1) |
jonathonfletcher | 0:5f46ebd8588e | 160 | #define OS_X_UNPEND(fl) NVIC_INT_CTRL = (*fl = OS_X_PENDING) << 27 |
jonathonfletcher | 0:5f46ebd8588e | 161 | #define OS_X_PEND(fl,p) NVIC_INT_CTRL = (fl | p) << 28 |
jonathonfletcher | 0:5f46ebd8588e | 162 | #define OS_X_INIT(n) NVIC_IP[n] = 0xFF; \ |
jonathonfletcher | 0:5f46ebd8588e | 163 | NVIC_ISER[n>>5] = 1 << (n & 0x1F) |
jonathonfletcher | 0:5f46ebd8588e | 164 | #define OS_X_LOCK(n) NVIC_ICER[n>>5] = 1 << (n & 0x1F) |
jonathonfletcher | 0:5f46ebd8588e | 165 | #define OS_X_UNLOCK(n) NVIC_ISER[n>>5] = 1 << (n & 0x1F) |
jonathonfletcher | 0:5f46ebd8588e | 166 | |
jonathonfletcher | 0:5f46ebd8588e | 167 | /* Core Debug registers */ |
jonathonfletcher | 0:5f46ebd8588e | 168 | #define DEMCR (*((volatile U32 *)0xE000EDFC)) |
jonathonfletcher | 0:5f46ebd8588e | 169 | |
jonathonfletcher | 0:5f46ebd8588e | 170 | /* ITM registers */ |
jonathonfletcher | 0:5f46ebd8588e | 171 | #define ITM_CONTROL (*((volatile U32 *)0xE0000E80)) |
jonathonfletcher | 0:5f46ebd8588e | 172 | #define ITM_ENABLE (*((volatile U32 *)0xE0000E00)) |
jonathonfletcher | 0:5f46ebd8588e | 173 | #define ITM_PORT30_U32 (*((volatile U32 *)0xE0000078)) |
jonathonfletcher | 0:5f46ebd8588e | 174 | #define ITM_PORT31_U32 (*((volatile U32 *)0xE000007C)) |
jonathonfletcher | 0:5f46ebd8588e | 175 | #define ITM_PORT31_U16 (*((volatile U16 *)0xE000007C)) |
jonathonfletcher | 0:5f46ebd8588e | 176 | #define ITM_PORT31_U8 (*((volatile U8 *)0xE000007C)) |
jonathonfletcher | 0:5f46ebd8588e | 177 | |
jonathonfletcher | 0:5f46ebd8588e | 178 | /* Variables */ |
jonathonfletcher | 0:5f46ebd8588e | 179 | extern BIT dbg_msg; |
jonathonfletcher | 0:5f46ebd8588e | 180 | |
jonathonfletcher | 0:5f46ebd8588e | 181 | /* Functions */ |
jonathonfletcher | 0:5f46ebd8588e | 182 | #ifdef __USE_EXCLUSIVE_ACCESS |
jonathonfletcher | 0:5f46ebd8588e | 183 | #define rt_inc(p) while(__strex((__ldrex(p)+1),p)) |
jonathonfletcher | 0:5f46ebd8588e | 184 | #define rt_dec(p) while(__strex((__ldrex(p)-1),p)) |
jonathonfletcher | 0:5f46ebd8588e | 185 | #else |
jonathonfletcher | 0:5f46ebd8588e | 186 | #define rt_inc(p) __disable_irq();(*p)++;__enable_irq(); |
jonathonfletcher | 0:5f46ebd8588e | 187 | #define rt_dec(p) __disable_irq();(*p)--;__enable_irq(); |
jonathonfletcher | 0:5f46ebd8588e | 188 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 189 | |
jonathonfletcher | 0:5f46ebd8588e | 190 | __inline static U32 rt_inc_qi (U32 size, U8 *count, U8 *first) { |
jonathonfletcher | 0:5f46ebd8588e | 191 | U32 cnt,c2; |
jonathonfletcher | 0:5f46ebd8588e | 192 | #ifdef __USE_EXCLUSIVE_ACCESS |
jonathonfletcher | 0:5f46ebd8588e | 193 | do { |
jonathonfletcher | 0:5f46ebd8588e | 194 | if ((cnt = __ldrex(count)) == size) { |
jonathonfletcher | 0:5f46ebd8588e | 195 | __clrex(); |
jonathonfletcher | 0:5f46ebd8588e | 196 | return (cnt); } |
jonathonfletcher | 0:5f46ebd8588e | 197 | } while (__strex(cnt+1, count)); |
jonathonfletcher | 0:5f46ebd8588e | 198 | do { |
jonathonfletcher | 0:5f46ebd8588e | 199 | c2 = (cnt = __ldrex(first)) + 1; |
jonathonfletcher | 0:5f46ebd8588e | 200 | if (c2 == size) c2 = 0; |
jonathonfletcher | 0:5f46ebd8588e | 201 | } while (__strex(c2, first)); |
jonathonfletcher | 0:5f46ebd8588e | 202 | #else |
jonathonfletcher | 0:5f46ebd8588e | 203 | __disable_irq(); |
jonathonfletcher | 0:5f46ebd8588e | 204 | if ((cnt = *count) < size) { |
jonathonfletcher | 0:5f46ebd8588e | 205 | *count = cnt+1; |
jonathonfletcher | 0:5f46ebd8588e | 206 | c2 = (cnt = *first) + 1; |
jonathonfletcher | 0:5f46ebd8588e | 207 | if (c2 == size) c2 = 0; |
jonathonfletcher | 0:5f46ebd8588e | 208 | *first = c2; |
jonathonfletcher | 0:5f46ebd8588e | 209 | } |
jonathonfletcher | 0:5f46ebd8588e | 210 | __enable_irq (); |
jonathonfletcher | 0:5f46ebd8588e | 211 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 212 | return (cnt); |
jonathonfletcher | 0:5f46ebd8588e | 213 | } |
jonathonfletcher | 0:5f46ebd8588e | 214 | |
jonathonfletcher | 0:5f46ebd8588e | 215 | __inline static void rt_systick_init (void) { |
jonathonfletcher | 0:5f46ebd8588e | 216 | NVIC_ST_RELOAD = os_trv; |
jonathonfletcher | 0:5f46ebd8588e | 217 | NVIC_ST_CURRENT = 0; |
jonathonfletcher | 0:5f46ebd8588e | 218 | NVIC_ST_CTRL = 0x0007; |
jonathonfletcher | 0:5f46ebd8588e | 219 | NVIC_SYS_PRI3 |= 0xFF000000; |
jonathonfletcher | 0:5f46ebd8588e | 220 | } |
jonathonfletcher | 0:5f46ebd8588e | 221 | |
jonathonfletcher | 0:5f46ebd8588e | 222 | __inline static void rt_svc_init (void) { |
jonathonfletcher | 0:5f46ebd8588e | 223 | #if !(__TARGET_ARCH_6S_M) |
jonathonfletcher | 0:5f46ebd8588e | 224 | int sh,prigroup; |
jonathonfletcher | 0:5f46ebd8588e | 225 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 226 | NVIC_SYS_PRI3 |= 0x00FF0000; |
jonathonfletcher | 0:5f46ebd8588e | 227 | #if (__TARGET_ARCH_6S_M) |
jonathonfletcher | 0:5f46ebd8588e | 228 | NVIC_SYS_PRI2 |= (NVIC_SYS_PRI3<<(8+1)) & 0xFC000000; |
jonathonfletcher | 0:5f46ebd8588e | 229 | #else |
jonathonfletcher | 0:5f46ebd8588e | 230 | sh = 8 - __clz (~((NVIC_SYS_PRI3 << 8) & 0xFF000000)); |
jonathonfletcher | 0:5f46ebd8588e | 231 | prigroup = ((NVIC_AIR_CTRL >> 8) & 0x07); |
jonathonfletcher | 0:5f46ebd8588e | 232 | if (prigroup >= sh) { |
jonathonfletcher | 0:5f46ebd8588e | 233 | sh = prigroup + 1; |
jonathonfletcher | 0:5f46ebd8588e | 234 | } |
jonathonfletcher | 0:5f46ebd8588e | 235 | NVIC_SYS_PRI2 = ((0xFEFFFFFF << sh) & 0xFF000000) | (NVIC_SYS_PRI2 & 0x00FFFFFF); |
jonathonfletcher | 0:5f46ebd8588e | 236 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 237 | } |
jonathonfletcher | 0:5f46ebd8588e | 238 | |
jonathonfletcher | 0:5f46ebd8588e | 239 | extern void rt_set_PSP (U32 stack); |
jonathonfletcher | 0:5f46ebd8588e | 240 | extern U32 rt_get_PSP (void); |
jonathonfletcher | 0:5f46ebd8588e | 241 | extern void os_set_env (void); |
jonathonfletcher | 0:5f46ebd8588e | 242 | extern void *_alloc_box (void *box_mem); |
jonathonfletcher | 0:5f46ebd8588e | 243 | extern int _free_box (void *box_mem, void *box); |
jonathonfletcher | 0:5f46ebd8588e | 244 | |
jonathonfletcher | 0:5f46ebd8588e | 245 | extern void rt_init_stack (P_TCB p_TCB, FUNCP task_body); |
jonathonfletcher | 0:5f46ebd8588e | 246 | extern void rt_ret_val (P_TCB p_TCB, U32 v0); |
jonathonfletcher | 0:5f46ebd8588e | 247 | extern void rt_ret_val2 (P_TCB p_TCB, U32 v0, U32 v1); |
jonathonfletcher | 0:5f46ebd8588e | 248 | |
jonathonfletcher | 0:5f46ebd8588e | 249 | extern void dbg_init (void); |
jonathonfletcher | 0:5f46ebd8588e | 250 | extern void dbg_task_notify (P_TCB p_tcb, BOOL create); |
jonathonfletcher | 0:5f46ebd8588e | 251 | extern void dbg_task_switch (U32 task_id); |
jonathonfletcher | 0:5f46ebd8588e | 252 | |
jonathonfletcher | 0:5f46ebd8588e | 253 | #ifdef DBG_MSG |
jonathonfletcher | 0:5f46ebd8588e | 254 | #define DBG_INIT() dbg_init() |
jonathonfletcher | 0:5f46ebd8588e | 255 | #define DBG_TASK_NOTIFY(p_tcb,create) if (dbg_msg) dbg_task_notify(p_tcb,create) |
jonathonfletcher | 0:5f46ebd8588e | 256 | #define DBG_TASK_SWITCH(task_id) if (dbg_msg && (os_tsk.new!=os_tsk.run)) \ |
jonathonfletcher | 0:5f46ebd8588e | 257 | dbg_task_switch(task_id) |
jonathonfletcher | 0:5f46ebd8588e | 258 | #else |
jonathonfletcher | 0:5f46ebd8588e | 259 | #define DBG_INIT() |
jonathonfletcher | 0:5f46ebd8588e | 260 | #define DBG_TASK_NOTIFY(p_tcb,create) |
jonathonfletcher | 0:5f46ebd8588e | 261 | #define DBG_TASK_SWITCH(task_id) |
jonathonfletcher | 0:5f46ebd8588e | 262 | #endif |
jonathonfletcher | 0:5f46ebd8588e | 263 | |
jonathonfletcher | 0:5f46ebd8588e | 264 | /*---------------------------------------------------------------------------- |
jonathonfletcher | 0:5f46ebd8588e | 265 | * end of file |
jonathonfletcher | 0:5f46ebd8588e | 266 | *---------------------------------------------------------------------------*/ |
jonathonfletcher | 0:5f46ebd8588e | 267 |