ARM Compatiable Functions

group NMSIS_Core_ARMCompatiable_Functions

A few functions that compatiable with ARM CMSIS-Core.

Here we provided a few functions that compatiable with ARM CMSIS-Core, mostly used in the DSP and NN library.

Defines

__ISB() __RWMB()

Instruction Synchronization Barrier, compatiable with ARM.

__DSB() __RWMB()

Data Synchronization Barrier, compatiable with ARM.

__DMB() __RWMB()

Data Memory Barrier, compatiable with ARM.

__LDRBT(ptr) __LB((ptr))

LDRT Unprivileged (8 bit), ARM Compatiable.

__LDRHT(ptr) __LH((ptr))

LDRT Unprivileged (16 bit), ARM Compatiable.

__LDRT(ptr) __LW((ptr))

LDRT Unprivileged (32 bit), ARM Compatiable.

__STRBT(val, ptr) __SB((ptr), (val))

STRT Unprivileged (8 bit), ARM Compatiable.

__STRHT(val, ptr) __SH((ptr), (val))

STRT Unprivileged (16 bit), ARM Compatiable.

__STRT(val, ptr) __SW((ptr), (val))

STRT Unprivileged (32 bit), ARM Compatiable.

__SSAT(val, sat) __RV_SCLIP32((val), (sat-1))

Signed Saturate.

Saturates a signed value.

Parameters
  • value[in] Value to be saturated

  • sat[in] Bit position to saturate to (1..32)

Returns

Saturated value

__USAT(val, sat) __RV_UCLIP32((val), (sat))

Unsigned Saturate.

Saturates an unsigned value.

Parameters
  • value[in] Value to be saturated

  • sat[in] Bit position to saturate to (0..31)

Returns

Saturated value

__RBIT(value) __RV_BITREVI((value), 31)

Reverse bit order of value.

Reverses the bit order of the given value.

Parameters
  • value[in] Value to reverse

Returns

Reversed value

__CLZ(data) __RV_CLZ32(data)

Count leading zeros.

Counts the number of leading zeros of a data value.

Parameters
  • data[in] Value to count the leading zeros

Returns

number of leading zeros in value

__EXPD_BYTE(x)

Expand byte to unsigned long value.

Expand byte value x to unsigned long value’s each byte.

Parameters
  • x[in] the byte value to be expand, the input must be uint8_t type

Returns

Expanded value in unsigned long

Functions

__STATIC_FORCEINLINE uint32_t __REV (uint32_t value)

Reverse byte order (32 bit)

Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.

Parameters

value[in] Value to reverse

Returns

Reversed value

__STATIC_FORCEINLINE uint32_t __REV16 (uint32_t value)

Reverse byte order (16 bit)

Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.

Parameters

value[in] Value to reverse

Returns

Reversed value

__STATIC_FORCEINLINE int16_t __REVSH (int16_t value)

Reverse byte order (16 bit)

Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.

Parameters

value[in] Value to reverse

Returns

Reversed value

__STATIC_FORCEINLINE uint32_t __ROR (uint32_t op1, uint32_t op2)

Rotate Right in unsigned value (32 bit)

Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.

Parameters
  • op1[in] Value to rotate

  • op2[in] Number of Bits to rotate(0-31)

Returns

Rotated value

__STATIC_FORCEINLINE unsigned long __CTZ (unsigned long data)

Count tailing zero.

Return the count of least-significant bit zero.for example, return 3 if x=0bxxx1000

Parameters

data[in] Value to count the tailing zeros

Returns

number of tailing zeros in value