135 lines
3.3 KiB
C
135 lines
3.3 KiB
C
#include "mcu_wrapper_conf.h"
|
|
#ifdef ARM_MATH_LOOPUNROLL
|
|
#include "dsp/none.h"
|
|
#endif
|
|
|
|
#define _sqrtf(...) sqrtf(__VA_ARGS__)
|
|
|
|
#define __disable_irq()
|
|
|
|
#ifndef __ASM
|
|
#define __ASM __asm
|
|
#endif
|
|
|
|
#ifndef __IO
|
|
#define __IO volatile
|
|
#endif
|
|
|
|
#ifndef __inline
|
|
#define __inline inline
|
|
#endif
|
|
|
|
#ifndef __NOINLINE
|
|
#define __NOINLINE __declspec(noinline)
|
|
#endif
|
|
|
|
#ifndef __INLINE
|
|
#define __INLINE __inline
|
|
#endif
|
|
|
|
#ifndef __STATIC_INLINE
|
|
#define __STATIC_INLINE static __inline
|
|
#endif
|
|
|
|
#ifndef __STATIC_FORCEINLINE
|
|
#define __STATIC_FORCEINLINE //static __forceinline
|
|
#endif
|
|
|
|
#ifndef __NO_RETURN
|
|
#define __NO_RETURN __declspec(noreturn)
|
|
#endif
|
|
|
|
#ifndef __USED
|
|
#define __USED __attribute__((used))
|
|
#endif
|
|
|
|
|
|
#ifndef __WEAK
|
|
#define __WEAK __attribute__((weak))
|
|
// #define __weak __WEAK
|
|
#endif
|
|
|
|
#ifndef __PACKED
|
|
#define __PACKED __attribute__((packed))
|
|
#endif
|
|
|
|
#ifndef __PACKED_STRUCT
|
|
#define __PACKED_STRUCT __packed struct
|
|
#endif
|
|
|
|
#ifndef __PACKED_UNION
|
|
#define __PACKED_UNION __packed union
|
|
#endif
|
|
|
|
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
|
#define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
|
|
#endif
|
|
|
|
#ifndef __UNALIGNED_UINT16_WRITE
|
|
#define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
|
|
#endif
|
|
|
|
#ifndef __UNALIGNED_UINT16_READ
|
|
#define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
|
|
#endif
|
|
|
|
#ifndef __UNALIGNED_UINT32_WRITE
|
|
#define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
|
|
#endif
|
|
|
|
#ifndef __UNALIGNED_UINT32_READ
|
|
#define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
|
|
#endif
|
|
|
|
#ifndef __ALIGNED
|
|
#define __ALIGNED(x) __attribute__((aligned(x)))
|
|
#endif
|
|
|
|
#ifndef __RESTRICT
|
|
#define __RESTRICT __restrict
|
|
#endif
|
|
|
|
#ifdef __MINGW64__
|
|
#ifndef __weak
|
|
#define __weak __attribute__((weak))
|
|
#endif
|
|
#else
|
|
#ifndef __weak
|
|
#define __weak
|
|
#endif
|
|
#endif
|
|
#define __DSB()
|
|
#define __ISB()
|
|
#define __NOP()
|
|
#define __WFI()
|
|
#define __SEV()
|
|
#define __WFE()
|
|
#define __DMB()
|
|
|
|
|
|
/**
|
|
\brief Reverse bit order of value
|
|
\details Reverses the bit order of the given value.
|
|
\param [in] value Value to reverse
|
|
\return Reversed value
|
|
*/
|
|
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
|
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
|
#define __RBIT __rbit
|
|
#else
|
|
__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
|
|
{
|
|
uint32_t result;
|
|
uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
|
|
|
|
result = value; /* r will be reversed bits of v; first get LSB of v */
|
|
for (value >>= 1U; value != 0U; value >>= 1U)
|
|
{
|
|
result <<= 1U;
|
|
result |= value & 1U;
|
|
s--;
|
|
}
|
|
result <<= s; /* shift when v's highest bits are zero */
|
|
return result;
|
|
}
|
|
#endif |