L 1 "..\src\STM32Lib\core_cm3.c" N/****************************************************************************** N * @file: core_cm3.c N * @purpose: CMSIS Cortex-M3 Core Peripheral Access Layer Source File N * @version: V1.10 N * @date: 24. Feb. 2009 N *---------------------------------------------------------------------------- N * N * Copyright (C) 2009 ARM Limited. All rights reserved. N * N * ARM Limited (ARM) is supplying this software for use with Cortex-Mx N * processor based microcontrollers. This file can be freely distributed N * within development tools that are supporting such ARM based processors. N * N * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED N * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF N * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. N * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR N * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. N * N ******************************************************************************/ N N N N#include L 1 "d:\Keil\ARM\ARM_Compiler_5.06u7\Bin\..\include\stdint.h" 1 N/* Copyright (C) ARM Ltd., 1999,2014 */ N/* All rights reserved */ N N/* N * RCS $Revision$ N * Checkin $Date$ N * Revising $Author: agrant $ N */ N N#ifndef __stdint_h N#define __stdint_h N#define __ARMCLIB_VERSION 5060044 N N #ifdef __INT64_TYPE__ S /* armclang predefines '__INT64_TYPE__' and '__INT64_C_SUFFIX__' */ S #define __INT64 __INT64_TYPE__ N #else N /* armcc has builtin '__int64' which can be used in --strict mode */ N #define __INT64 __int64 N #define __INT64_C_SUFFIX__ ll N #endif N #define __PASTE2(x, y) x ## y N #define __PASTE(x, y) __PASTE2(x, y) N #define __INT64_C(x) __ESCAPE__(__PASTE(x, __INT64_C_SUFFIX__)) N #define __UINT64_C(x) __ESCAPE__(__PASTE(x ## u, __INT64_C_SUFFIX__)) N #if defined(__clang__) || (defined(__ARMCC_VERSION) && !defined(__STRICT_ANSI__)) X #if 0L || (1L && !0L) N /* armclang and non-strict armcc allow 'long long' in system headers */ N #define __LONGLONG long long N #else S /* strict armcc has '__int64' */ S #define __LONGLONG __int64 N #endif N N #ifndef __STDINT_DECLS N #define __STDINT_DECLS N N #undef __CLIBNS N N #ifdef __cplusplus S namespace std { S #define __CLIBNS std:: S extern "C" { N #else N #define __CLIBNS N #endif /* __cplusplus */ N N N/* N * 'signed' is redundant below, except for 'signed char' and if N * the typedef is used to declare a bitfield. N */ N N /* 7.18.1.1 */ N N /* exact-width signed integer types */ Ntypedef signed char int8_t; Ntypedef signed short int int16_t; Ntypedef signed int int32_t; Ntypedef signed __INT64 int64_t; Xtypedef signed __int64 int64_t; N N /* exact-width unsigned integer types */ Ntypedef unsigned char uint8_t; Ntypedef unsigned short int uint16_t; Ntypedef unsigned int uint32_t; Ntypedef unsigned __INT64 uint64_t; Xtypedef unsigned __int64 uint64_t; N N /* 7.18.1.2 */ N N /* smallest type of at least n bits */ N /* minimum-width signed integer types */ Ntypedef signed char int_least8_t; Ntypedef signed short int int_least16_t; Ntypedef signed int int_least32_t; Ntypedef signed __INT64 int_least64_t; Xtypedef signed __int64 int_least64_t; N N /* minimum-width unsigned integer types */ Ntypedef unsigned char uint_least8_t; Ntypedef unsigned short int uint_least16_t; Ntypedef unsigned int uint_least32_t; Ntypedef unsigned __INT64 uint_least64_t; Xtypedef unsigned __int64 uint_least64_t; N N /* 7.18.1.3 */ N N /* fastest minimum-width signed integer types */ Ntypedef signed int int_fast8_t; Ntypedef signed int int_fast16_t; Ntypedef signed int int_fast32_t; Ntypedef signed __INT64 int_fast64_t; Xtypedef signed __int64 int_fast64_t; N N /* fastest minimum-width unsigned integer types */ Ntypedef unsigned int uint_fast8_t; Ntypedef unsigned int uint_fast16_t; Ntypedef unsigned int uint_fast32_t; Ntypedef unsigned __INT64 uint_fast64_t; Xtypedef unsigned __int64 uint_fast64_t; N N /* 7.18.1.4 integer types capable of holding object pointers */ N#if __sizeof_ptr == 8 X#if 4 == 8 Stypedef signed __INT64 intptr_t; Stypedef unsigned __INT64 uintptr_t; N#else Ntypedef signed int intptr_t; Ntypedef unsigned int uintptr_t; N#endif N N /* 7.18.1.5 greatest-width integer types */ Ntypedef signed __LONGLONG intmax_t; Xtypedef signed long long intmax_t; Ntypedef unsigned __LONGLONG uintmax_t; Xtypedef unsigned long long uintmax_t; N N N#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) X#if !0L || 0L N N /* 7.18.2.1 */ N N /* minimum values of exact-width signed integer types */ N#define INT8_MIN -128 N#define INT16_MIN -32768 N#define INT32_MIN (~0x7fffffff) /* -2147483648 is unsigned */ N#define INT64_MIN __INT64_C(~0x7fffffffffffffff) /* -9223372036854775808 is unsigned */ N N /* maximum values of exact-width signed integer types */ N#define INT8_MAX 127 N#define INT16_MAX 32767 N#define INT32_MAX 2147483647 N#define INT64_MAX __INT64_C(9223372036854775807) N N /* maximum values of exact-width unsigned integer types */ N#define UINT8_MAX 255 N#define UINT16_MAX 65535 N#define UINT32_MAX 4294967295u N#define UINT64_MAX __UINT64_C(18446744073709551615) N N /* 7.18.2.2 */ N N /* minimum values of minimum-width signed integer types */ N#define INT_LEAST8_MIN -128 N#define INT_LEAST16_MIN -32768 N#define INT_LEAST32_MIN (~0x7fffffff) N#define INT_LEAST64_MIN __INT64_C(~0x7fffffffffffffff) N N /* maximum values of minimum-width signed integer types */ N#define INT_LEAST8_MAX 127 N#define INT_LEAST16_MAX 32767 N#define INT_LEAST32_MAX 2147483647 N#define INT_LEAST64_MAX __INT64_C(9223372036854775807) N N /* maximum values of minimum-width unsigned integer types */ N#define UINT_LEAST8_MAX 255 N#define UINT_LEAST16_MAX 65535 N#define UINT_LEAST32_MAX 4294967295u N#define UINT_LEAST64_MAX __UINT64_C(18446744073709551615) N N /* 7.18.2.3 */ N N /* minimum values of fastest minimum-width signed integer types */ N#define INT_FAST8_MIN (~0x7fffffff) N#define INT_FAST16_MIN (~0x7fffffff) N#define INT_FAST32_MIN (~0x7fffffff) N#define INT_FAST64_MIN __INT64_C(~0x7fffffffffffffff) N N /* maximum values of fastest minimum-width signed integer types */ N#define INT_FAST8_MAX 2147483647 N#define INT_FAST16_MAX 2147483647 N#define INT_FAST32_MAX 2147483647 N#define INT_FAST64_MAX __INT64_C(9223372036854775807) N N /* maximum values of fastest minimum-width unsigned integer types */ N#define UINT_FAST8_MAX 4294967295u N#define UINT_FAST16_MAX 4294967295u N#define UINT_FAST32_MAX 4294967295u N#define UINT_FAST64_MAX __UINT64_C(18446744073709551615) N N /* 7.18.2.4 */ N N /* minimum value of pointer-holding signed integer type */ N#if __sizeof_ptr == 8 X#if 4 == 8 S#define INTPTR_MIN INT64_MIN N#else N#define INTPTR_MIN INT32_MIN N#endif N N /* maximum value of pointer-holding signed integer type */ N#if __sizeof_ptr == 8 X#if 4 == 8 S#define INTPTR_MAX INT64_MAX N#else N#define INTPTR_MAX INT32_MAX N#endif N N /* maximum value of pointer-holding unsigned integer type */ N#if __sizeof_ptr == 8 X#if 4 == 8 S#define UINTPTR_MAX UINT64_MAX N#else N#define UINTPTR_MAX UINT32_MAX N#endif N N /* 7.18.2.5 */ N N /* minimum value of greatest-width signed integer type */ N#define INTMAX_MIN __ESCAPE__(~0x7fffffffffffffffll) N N /* maximum value of greatest-width signed integer type */ N#define INTMAX_MAX __ESCAPE__(9223372036854775807ll) N N /* maximum value of greatest-width unsigned integer type */ N#define UINTMAX_MAX __ESCAPE__(18446744073709551615ull) N N /* 7.18.3 */ N N /* limits of ptrdiff_t */ N#if __sizeof_ptr == 8 X#if 4 == 8 S#define PTRDIFF_MIN INT64_MIN S#define PTRDIFF_MAX INT64_MAX N#else N#define PTRDIFF_MIN INT32_MIN N#define PTRDIFF_MAX INT32_MAX N#endif N N /* limits of sig_atomic_t */ N#define SIG_ATOMIC_MIN (~0x7fffffff) N#define SIG_ATOMIC_MAX 2147483647 N N /* limit of size_t */ N#if __sizeof_ptr == 8 X#if 4 == 8 S#define SIZE_MAX UINT64_MAX N#else N#define SIZE_MAX UINT32_MAX N#endif N N /* limits of wchar_t */ N /* NB we have to undef and redef because they're defined in both N * stdint.h and wchar.h */ N#undef WCHAR_MIN N#undef WCHAR_MAX N N#if defined(__WCHAR32) || (defined(__ARM_SIZEOF_WCHAR_T) && __ARM_SIZEOF_WCHAR_T == 4) X#if 0L || (0L && __ARM_SIZEOF_WCHAR_T == 4) S #define WCHAR_MIN 0 S #define WCHAR_MAX 0xffffffffU N#else N #define WCHAR_MIN 0 N #define WCHAR_MAX 65535 N#endif N N /* limits of wint_t */ N#define WINT_MIN (~0x7fffffff) N#define WINT_MAX 2147483647 N N#endif /* __STDC_LIMIT_MACROS */ N N#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) X#if !0L || 0L N N /* 7.18.4.1 macros for minimum-width integer constants */ N#define INT8_C(x) (x) N#define INT16_C(x) (x) N#define INT32_C(x) (x) N#define INT64_C(x) __INT64_C(x) N N#define UINT8_C(x) (x ## u) N#define UINT16_C(x) (x ## u) N#define UINT32_C(x) (x ## u) N#define UINT64_C(x) __UINT64_C(x) N N /* 7.18.4.2 macros for greatest-width integer constants */ N#define INTMAX_C(x) __ESCAPE__(x ## ll) N#define UINTMAX_C(x) __ESCAPE__(x ## ull) N N#endif /* __STDC_CONSTANT_MACROS */ N N #ifdef __cplusplus S } /* extern "C" */ S } /* namespace std */ N #endif /* __cplusplus */ N #endif /* __STDINT_DECLS */ N N #ifdef __cplusplus S #ifndef __STDINT_NO_EXPORTS S using ::std::int8_t; S using ::std::int16_t; S using ::std::int32_t; S using ::std::int64_t; S using ::std::uint8_t; S using ::std::uint16_t; S using ::std::uint32_t; S using ::std::uint64_t; S using ::std::int_least8_t; S using ::std::int_least16_t; S using ::std::int_least32_t; S using ::std::int_least64_t; S using ::std::uint_least8_t; S using ::std::uint_least16_t; S using ::std::uint_least32_t; S using ::std::uint_least64_t; S using ::std::int_fast8_t; S using ::std::int_fast16_t; S using ::std::int_fast32_t; S using ::std::int_fast64_t; S using ::std::uint_fast8_t; S using ::std::uint_fast16_t; S using ::std::uint_fast32_t; S using ::std::uint_fast64_t; S using ::std::intptr_t; S using ::std::uintptr_t; S using ::std::intmax_t; S using ::std::uintmax_t; S #endif N #endif /* __cplusplus */ N N#undef __INT64 N#undef __LONGLONG N N#endif /* __stdint_h */ N N/* end of stdint.h */ L 25 "..\src\STM32Lib\core_cm3.c" 2 N N N/* define compiler specific symbols */ N#if defined ( __CC_ARM ) X#if 1L N#define __ASM __asm /*!< asm keyword for armcc */ N#define __INLINE __inline /*!< inline keyword for armcc */ N N#elif defined ( __ICCARM__ ) S#define __ASM __asm /*!< asm keyword for iarcc */ S#define __INLINE inline /*!< inline keyword for iarcc. Only avaiable in High optimization mode! */ S#define __nop __no_operation /*!< no operation intrinsic in iarcc */ S S#elif defined ( __GNUC__ ) S#define __ASM asm /*!< asm keyword for gcc */ S#define __INLINE inline /*!< inline keyword for gcc */ N#endif N N N N#if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/ X#if 1L N N/** N * @brief Return the Process Stack Pointer N * N * @param none N * @return uint32_t ProcessStackPointer N * N * Return the actual process stack pointer N */ N__ASM uint32_t __get_PSP(void) X__asm uint32_t __get_PSP(void) N{ N mrs r0, psp N bx lr N} N N/** N * @brief Set the Process Stack Pointer N * N * @param uint32_t Process Stack Pointer N * @return none N * N * Assign the value ProcessStackPointer to the MSP N * (process stack pointer) Cortex processor register N */ N__ASM void __set_PSP(uint32_t topOfProcStack) X__asm void __set_PSP(uint32_t topOfProcStack) N{ N msr psp, r0 N bx lr N} N N/** N * @brief Return the Main Stack Pointer N * N * @param none N * @return uint32_t Main Stack Pointer N * N * Return the current value of the MSP (main stack pointer) N * Cortex processor register N */ N__ASM uint32_t __get_MSP(void) X__asm uint32_t __get_MSP(void) N{ N mrs r0, msp N bx lr N} N N/** N * @brief Set the Main Stack Pointer N * N * @param uint32_t Main Stack Pointer N * @return none N * N * Assign the value mainStackPointer to the MSP N * (main stack pointer) Cortex processor register N */ N__ASM void __set_MSP(uint32_t mainStackPointer) X__asm void __set_MSP(uint32_t mainStackPointer) N{ N msr msp, r0 N bx lr N} N N/** N * @brief Reverse byte order in unsigned short value N * N * @param uint16_t value to reverse N * @return uint32_t reversed value N * N * Reverse byte order in unsigned short value N */ N__ASM uint32_t __REV16(uint16_t value) X__asm uint32_t __REV16(uint16_t value) N{ N rev16 r0, r0 N bx lr N} N N/** N * @brief Reverse byte order in signed short value with sign extension to integer N * N * @param int16_t value to reverse N * @return int32_t reversed value N * N * Reverse byte order in signed short value with sign extension to integer N */ N__ASM int32_t __REVSH(int16_t value) X__asm int32_t __REVSH(int16_t value) N{ N revsh r0, r0 N bx lr N} N N N#if (__ARMCC_VERSION < 400000) X#if (5060960 < 400000) S S/** S * @brief Remove the exclusive lock created by ldrex S * S * @param none S * @return none S * S * Removes the exclusive lock which is created by ldrex. S */ S__ASM void __CLREX(void) S{ S clrex S} S S/** S * @brief Return the Base Priority value S * S * @param none S * @return uint32_t BasePriority S * S * Return the content of the base priority register S */ S__ASM uint32_t __get_BASEPRI(void) S{ S mrs r0, basepri S bx lr S} S S/** S * @brief Set the Base Priority value S * S * @param uint32_t BasePriority S * @return none S * S * Set the base priority register S */ S__ASM void __set_BASEPRI(uint32_t basePri) S{ S msr basepri, r0 S bx lr S} S S/** S * @brief Return the Priority Mask value S * S * @param none S * @return uint32_t PriMask S * S * Return the state of the priority mask bit from the priority mask S * register S */ S__ASM uint32_t __get_PRIMASK(void) S{ S mrs r0, primask S bx lr S} S S/** S * @brief Set the Priority Mask value S * S * @param uint32_t PriMask S * @return none S * S * Set the priority mask bit in the priority mask register S */ S__ASM void __set_PRIMASK(uint32_t priMask) S{ S msr primask, r0 S bx lr S} S S/** S * @brief Return the Fault Mask value S * S * @param none S * @return uint32_t FaultMask S * S * Return the content of the fault mask register S */ S__ASM uint32_t __get_FAULTMASK(void) S{ S mrs r0, faultmask S bx lr S} S S/** S * @brief Set the Fault Mask value S * S * @param uint32_t faultMask value S * @return none S * S * Set the fault mask register S */ S__ASM void __set_FAULTMASK(uint32_t faultMask) S{ S msr faultmask, r0 S bx lr S} S S/** S * @brief Return the Control Register value S * S * @param none S * @return uint32_t Control value S * S * Return the content of the control register S */ S__ASM uint32_t __get_CONTROL(void) S{ S mrs r0, control S bx lr S} S S/** S * @brief Set the Control Register value S * S * @param uint32_t Control value S * @return none S * S * Set the control register S */ S__ASM void __set_CONTROL(uint32_t control) S{ S msr control, r0 S bx lr S} S N#endif /* __ARMCC_VERSION */ N N N#elif (defined (__ICCARM__)) /*------------------ ICC Compiler -------------------*/ S#pragma diag_suppress=Pe940 S S/** S * @brief Return the Process Stack Pointer S * S * @param none S * @return uint32_t ProcessStackPointer S * S * Return the actual process stack pointer S */ Suint32_t __get_PSP(void) S{ S __ASM("mrs r0, psp"); S __ASM("bx lr"); S} S S/** S * @brief Set the Process Stack Pointer S * S * @param uint32_t Process Stack Pointer S * @return none S * S * Assign the value ProcessStackPointer to the MSP S * (process stack pointer) Cortex processor register S */ Svoid __set_PSP(uint32_t topOfProcStack) S{ S __ASM("msr psp, r0"); S __ASM("bx lr"); S} S S/** S * @brief Return the Main Stack Pointer S * S * @param none S * @return uint32_t Main Stack Pointer S * S * Return the current value of the MSP (main stack pointer) S * Cortex processor register S */ Suint32_t __get_MSP(void) S{ S __ASM("mrs r0, msp"); S __ASM("bx lr"); S} S S/** S * @brief Set the Main Stack Pointer S * S * @param uint32_t Main Stack Pointer S * @return none S * S * Assign the value mainStackPointer to the MSP S * (main stack pointer) Cortex processor register S */ Svoid __set_MSP(uint32_t topOfMainStack) S{ S __ASM("msr msp, r0"); S __ASM("bx lr"); S} S S/** S * @brief Reverse byte order in unsigned short value S * S * @param uint16_t value to reverse S * @return uint32_t reversed value S * S * Reverse byte order in unsigned short value S */ Suint32_t __REV16(uint16_t value) S{ S __ASM("rev16 r0, r0"); S __ASM("bx lr"); S} S S/** S * @brief Reverse bit order of value S * S * @param uint32_t value to reverse S * @return uint32_t reversed value S * S * Reverse bit order of value S */ Suint32_t __RBIT(uint32_t value) S{ S __ASM("rbit r0, r0"); S __ASM("bx lr"); S} S S/** S * @brief LDR Exclusive S * S * @param uint8_t* address S * @return uint8_t value of (*address) S * S * Exclusive LDR command S */ Suint8_t __LDREXB(uint8_t *addr) S{ S __ASM("ldrexb r0, [r0]"); S __ASM("bx lr"); S} S S/** S * @brief LDR Exclusive S * S * @param uint16_t* address S * @return uint16_t value of (*address) S * S * Exclusive LDR command S */ Suint16_t __LDREXH(uint16_t *addr) S{ S __ASM("ldrexh r0, [r0]"); S __ASM("bx lr"); S} S S/** S * @brief LDR Exclusive S * S * @param uint32_t* address S * @return uint32_t value of (*address) S * S * Exclusive LDR command S */ Suint32_t __LDREXW(uint32_t *addr) S{ S __ASM("ldrex r0, [r0]"); S __ASM("bx lr"); S} S S/** S * @brief STR Exclusive S * S * @param uint8_t *address S * @param uint8_t value to store S * @return uint32_t successful / failed S * S * Exclusive STR command S */ Suint32_t __STREXB(uint8_t value, uint8_t *addr) S{ S __ASM("strexb r0, r0, [r1]"); S __ASM("bx lr"); S} S S/** S * @brief STR Exclusive S * S * @param uint16_t *address S * @param uint16_t value to store S * @return uint32_t successful / failed S * S * Exclusive STR command S */ Suint32_t __STREXH(uint16_t value, uint16_t *addr) S{ S __ASM("strexh r0, r0, [r1]"); S __ASM("bx lr"); S} S S/** S * @brief STR Exclusive S * S * @param uint32_t *address S * @param uint32_t value to store S * @return uint32_t successful / failed S * S * Exclusive STR command S */ Suint32_t __STREXW(uint32_t value, uint32_t *addr) S{ S __ASM("strex r0, r0, [r1]"); S __ASM("bx lr"); S} S S#pragma diag_default=Pe940 S S S#elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/ S S/** S * @brief Return the Process Stack Pointer S * S * @param none S * @return uint32_t ProcessStackPointer S * S * Return the actual process stack pointer S */ Suint32_t __get_PSP(void) S{ S uint32_t result = 0; S S __ASM volatile ("MRS %0, psp" : "=r" (result) ); S return(result); S} S S/** S * @brief Set the Process Stack Pointer S * S * @param uint32_t Process Stack Pointer S * @return none S * S * Assign the value ProcessStackPointer to the MSP S * (process stack pointer) Cortex processor register S */ Svoid __set_PSP(uint32_t topOfProcStack) S{ S __ASM volatile ("MSR psp, %0" : : "r" (topOfProcStack) ); S} S S/** S * @brief Return the Main Stack Pointer S * S * @param none S * @return uint32_t Main Stack Pointer S * S * Return the current value of the MSP (main stack pointer) S * Cortex processor register S */ Suint32_t __get_MSP(void) S{ S uint32_t result = 0; S S __ASM volatile ("MRS %0, msp" : "=r" (result) ); S return(result); S} S S/** S * @brief Set the Main Stack Pointer S * S * @param uint32_t Main Stack Pointer S * @return none S * S * Assign the value mainStackPointer to the MSP S * (main stack pointer) Cortex processor register S */ Svoid __set_MSP(uint32_t topOfMainStack) S{ S __ASM volatile ("MSR msp, %0" : : "r" (topOfMainStack) ); S} S S/** S * @brief Return the Base Priority value S * S * @param none S * @return uint32_t BasePriority S * S * Return the content of the base priority register S */ Suint32_t __get_BASEPRI(void) S{ S uint32_t result = 0; S S __ASM volatile ("MRS %0, basepri_max" : "=r" (result) ); S return(result); S} S S/** S * @brief Set the Base Priority value S * S * @param uint32_t BasePriority S * @return none S * S * Set the base priority register S */ Svoid __set_BASEPRI(uint32_t value) S{ S __ASM volatile ("MSR basepri, %0" : : "r" (value) ); S} S S/** S * @brief Return the Priority Mask value S * S * @param none S * @return uint32_t PriMask S * S * Return the state of the priority mask bit from the priority mask S * register S */ Suint32_t __get_PRIMASK(void) S{ S uint32_t result = 0; S S __ASM volatile ("MRS %0, primask" : "=r" (result) ); S return(result); S} S S/** S * @brief Set the Priority Mask value S * S * @param uint32_t PriMask S * @return none S * S * Set the priority mask bit in the priority mask register S */ Svoid __set_PRIMASK(uint32_t priMask) S{ S __ASM volatile ("MSR primask, %0" : : "r" (priMask) ); S} S S/** S * @brief Return the Fault Mask value S * S * @param none S * @return uint32_t FaultMask S * S * Return the content of the fault mask register S */ Suint32_t __get_FAULTMASK(void) S{ S uint32_t result = 0; S S __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); S return(result); S} S S/** S * @brief Set the Fault Mask value S * S * @param uint32_t faultMask value S * @return none S * S * Set the fault mask register S */ Svoid __set_FAULTMASK(uint32_t faultMask) S{ S __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) ); S} S S/** S * @brief Reverse byte order in integer value S * S * @param uint32_t value to reverse S * @return uint32_t reversed value S * S * Reverse byte order in integer value S */ Suint32_t __REV(uint32_t value) S{ S uint32_t result = 0; S S __ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) ); S return(result); S} S S/** S * @brief Reverse byte order in unsigned short value S * S * @param uint16_t value to reverse S * @return uint32_t reversed value S * S * Reverse byte order in unsigned short value S */ Suint32_t __REV16(uint16_t value) S{ S uint32_t result = 0; S S __ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) ); S return(result); S} S S/** S * @brief Reverse byte order in signed short value with sign extension to integer S * S * @param int32_t value to reverse S * @return int32_t reversed value S * S * Reverse byte order in signed short value with sign extension to integer S */ Sint32_t __REVSH(int16_t value) S{ S uint32_t result = 0; S S __ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) ); S return(result); S} S S/** S * @brief Reverse bit order of value S * S * @param uint32_t value to reverse S * @return uint32_t reversed value S * S * Reverse bit order of value S */ Suint32_t __RBIT(uint32_t value) S{ S uint32_t result = 0; S S __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) ); S return(result); S} S S/** S * @brief LDR Exclusive S * S * @param uint8_t* address S * @return uint8_t value of (*address) S * S * Exclusive LDR command S */ Suint8_t __LDREXB(uint8_t *addr) S{ S uint8_t result = 0; S S __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) ); S return(result); S} S S/** S * @brief LDR Exclusive S * S * @param uint16_t* address S * @return uint16_t value of (*address) S * S * Exclusive LDR command S */ Suint16_t __LDREXH(uint16_t *addr) S{ S uint16_t result = 0; S S __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) ); S return(result); S} S S/** S * @brief LDR Exclusive S * S * @param uint32_t* address S * @return uint32_t value of (*address) S * S * Exclusive LDR command S */ Suint32_t __LDREXW(uint32_t *addr) S{ S uint32_t result = 0; S S __ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) ); S return(result); S} S S/** S * @brief STR Exclusive S * S * @param uint8_t *address S * @param uint8_t value to store S * @return uint32_t successful / failed S * S * Exclusive STR command S */ Suint32_t __STREXB(uint8_t value, uint8_t *addr) S{ S uint32_t result = 0; S S __ASM volatile ("strexb %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) ); S return(result); S} S S/** S * @brief STR Exclusive S * S * @param uint16_t *address S * @param uint16_t value to store S * @return uint32_t successful / failed S * S * Exclusive STR command S */ Suint32_t __STREXH(uint16_t value, uint16_t *addr) S{ S uint32_t result = 0; S S __ASM volatile ("strexh %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) ); S return(result); S} S S/** S * @brief STR Exclusive S * S * @param uint32_t *address S * @param uint32_t value to store S * @return uint32_t successful / failed S * S * Exclusive STR command S */ Suint32_t __STREXW(uint32_t value, uint32_t *addr) S{ S uint32_t result = 0; S S __ASM volatile ("strex %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) ); S return(result); S} S S/** S * @brief Return the Control Register value S * S * @param none S * @return uint32_t Control value S * S * Return the content of the control register S */ Suint32_t __get_CONTROL(void) S{ S uint32_t result = 0; S S __ASM volatile ("MRS %0, control" : "=r" (result) ); S return(result); S} S S/** S * @brief Set the Control Register value S * S * @param uint32_t Control value S * @return none S * S * Set the control register S */ Svoid __set_CONTROL(uint32_t control) S{ S __ASM volatile ("MSR control, %0" : : "r" (control) ); S} S N#endif N N N N N N N N N N N N N N N N N