|
发表于 2019-12-2 13:35:20
|
显示全部楼层
CMSIS帮助手册中有说明
To implement SVC functions in your Keil RTX5 project, you need to:
Add the SVC User Table file svc_user.c to your project folder and include it into your project. This file is available as a user code template.
Write a function implementation. Example:
uint32_t svc_atomic_inc32 (uint32_t *mem) {
// A protected function to increment a counter.
uint32_t val;
__disable_irq();
val = *mem;
(*mem) = val + 1U;
__enable_irq();
return (val);
}
Add the function to the SVC function table in the svc_user.c module:
void * const osRtxUserSVC[1+USER_SVC_COUNT] = {
(void *)USER_SVC_COUNT,
(void *)svc_atomic_inc32,
};
Increment the number of user SVC functions:
#define USER_SVC_COUNT 1 // Number of user SVC functions
Declare a function wrapper to be called by the user to execute the SVC call.
Code Example (Arm Compiler 6)
__STATIC_FORCEINLINE uint32_t atomic_inc32 (uint32_t *mem) {
register uint32_t val;
__ASM volatile (
"svc 1" : "=l" (val) : "l" (mem) : "cc", "memory"
);
return (val);
}
Code Example (Arm Compiler 5 using __svc(x) attribute)
uint32_t atomic_inc32 (uint32_t *mem) __svc(1); |
|