|
21 | 21 | #include "stdlib.h"
|
22 | 22 | #include "string.h"
|
23 | 23 |
|
24 |
| -#include "cmsis/TARGET_Freescale/TARGET_MCU_K64F/cmsis_nvic.h" |
25 |
| -#include "targets/cmsis/core_cm4.h" |
26 | 24 | #include "cmsis_os.h" // Revision: V1.02
|
| 25 | +// these includes try to find declaration of NVIC_SystemReset |
| 26 | +#include "cmsis_nvic.h" |
| 27 | +#if defined (__CORTEX_M0) |
| 28 | +#include "core_cm0.h" |
| 29 | +#elif defined (__CORTEX_M3) |
| 30 | +#include "core_cm3.h" |
| 31 | +#elif defined (__CORTEX_M4) |
| 32 | +#include "core_cm4.h" |
| 33 | +#elif defined (__CORTEX_M7) |
| 34 | +#include "core_cm7.h" |
| 35 | +#else |
| 36 | +#error "unsupported CPU arch" |
| 37 | +#endif |
| 38 | + |
| 39 | +#include "critical.h" |
27 | 40 |
|
28 | 41 | #define PAL_RTOS_TRANSLATE_CMSIS_ERROR_CODE(cmsisCode)\
|
29 | 42 | ((int32_t)(cmsisCode + PAL_ERR_RTOS_ERROR_BASE))
|
@@ -941,77 +954,15 @@ palStatus_t pal_plat_osMessageQueueDestroy(palMessageQID_t* messageQID)
|
941 | 954 | return status;
|
942 | 955 | }
|
943 | 956 |
|
944 |
| -#if defined (__CC_ARM) /* ARM Compiler */ |
945 |
| - |
946 |
| -#pragma push |
947 |
| -#pragma O0 |
948 |
| - |
949 |
| -#if ((defined(__TARGET_ARCH_7_M) || defined(__TARGET_ARCH_7E_M)) && !defined(NO_EXCLUSIVE_ACCESS)) |
950 |
| -#define __USE_EXCLUSIVE_ACCESS |
951 |
| -#else |
952 |
| -#undef __USE_EXCLUSIVE_ACCESS |
953 |
| -#endif // ARMCC end |
954 |
| - |
955 |
| -#elif defined (__GNUC__) /* GNU Compiler */ |
956 |
| - |
957 |
| -#undef __USE_EXCLUSIVE_ACCESS |
958 |
| -#pragma GCC push_options |
959 |
| -#pragma GCC optimize ("O0") |
960 |
| - |
961 |
| -#if defined (__CORTEX_M0) |
962 |
| -#define __TARGET_ARCH_6S_M |
963 |
| -#endif |
964 |
| - |
965 |
| -#if defined (__VFP_FP__) && !defined(__SOFTFP__) |
966 |
| -#define __TARGET_FPU_VFP |
967 |
| -#endif |
968 |
| -#endif |
969 | 957 |
|
970 | 958 | int32_t pal_plat_osAtomicIncrement(int32_t* valuePtr, int32_t increment)
|
971 | 959 | {
|
972 |
| -#ifdef __USE_EXCLUSIVE_ACCESS |
973 |
| - int32_t res; |
974 |
| - res = __ldrex(valuePtr) + increment; |
975 |
| - do { |
976 |
| - } while (__strex(res, valuePtr)); |
977 |
| - return (res); |
978 |
| -#elif !defined (__CORTEX_M0) |
979 |
| - if (valuePtr != NULL) |
980 |
| - { |
981 |
| - asm volatile( |
982 |
| - "try:\n\t" |
983 |
| - "LDREX R0, [%[valuePtr]]\n\t" |
984 |
| - "ADD R0, %[increment]\n\t" |
985 |
| - "CMP R0, R0\n\t" |
986 |
| - "ITT EQ\n\t" |
987 |
| - "STREXEQ R1, R0, [%[valuePtr]]\n\t" |
988 |
| - "CMPEQ R1, #0\n\t" |
989 |
| - "BNE try\n\t" |
990 |
| - :[valuePtr]"+r"(valuePtr) |
991 |
| - :[increment]"r"(increment) |
992 |
| - ); |
993 |
| - return *valuePtr; |
| 960 | + if (increment >= 0) |
| 961 | + { |
| 962 | + return core_util_atomic_incr_u32((uint32_t*)valuePtr, increment); |
994 | 963 | }
|
995 | 964 | else
|
996 | 965 | {
|
997 |
| - return 0; |
| 966 | + return core_util_atomic_decr_u32((uint32_t*)valuePtr, 0 - increment); |
998 | 967 | }
|
999 |
| -#else |
1000 |
| - int32_t res; |
1001 |
| - __disable_irq(); |
1002 |
| - res = *valuePtr + increment; |
1003 |
| - *valuePtr = res; |
1004 |
| - __enable_irq(); |
1005 |
| - return (res); |
1006 |
| -#endif |
1007 |
| - |
1008 | 968 | }
|
1009 |
| -#if defined (__CC_ARM) /* ARM Compiler */ |
1010 |
| - |
1011 |
| -#pragma pop |
1012 |
| - |
1013 |
| -#elif defined (__GNUC__) |
1014 |
| - |
1015 |
| -#pragma GCC pop_options |
1016 |
| - |
1017 |
| -#endif |
0 commit comments