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