Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit 797a41b

Browse files
authored
Merge pull request #4 from TeroJaasko/iar_fixes
Iar fixes
2 parents 26c0d8b + dd32918 commit 797a41b

File tree

2 files changed

+20
-69
lines changed

2 files changed

+20
-69
lines changed

Source/Port/Reference-Impl/mbedOS/Networking/pal_plat_network.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "mbed.h"
2323

2424

25-
#if defined (__CC_ARM)
25+
#if defined (__CC_ARM) || defined(__IAR_SYSTEMS_ICC__)
2626

2727

2828
void palSelectCallbackNull()

Source/Port/Reference-Impl/mbedOS/RTOS/pal_plat_rtos.c

+19-68
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,22 @@
2121
#include "stdlib.h"
2222
#include "string.h"
2323

24-
#include "cmsis/TARGET_Freescale/TARGET_MCU_K64F/cmsis_nvic.h"
25-
#include "targets/cmsis/core_cm4.h"
2624
#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"
2740

2841
#define PAL_RTOS_TRANSLATE_CMSIS_ERROR_CODE(cmsisCode)\
2942
((int32_t)(cmsisCode + PAL_ERR_RTOS_ERROR_BASE))
@@ -941,77 +954,15 @@ palStatus_t pal_plat_osMessageQueueDestroy(palMessageQID_t* messageQID)
941954
return status;
942955
}
943956

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
969957

970958
int32_t pal_plat_osAtomicIncrement(int32_t* valuePtr, int32_t increment)
971959
{
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);
994963
}
995964
else
996965
{
997-
return 0;
966+
return core_util_atomic_decr_u32((uint32_t*)valuePtr, 0 - increment);
998967
}
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-
1008968
}
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

Comments
 (0)