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.

__PKHBT(ARG1, ARG2, ARG3)

Halfword packing instruction.

Combines bits[15:0] of val1 with bits[31:16] of val2 levitated with the val3.

__PKHTB(ARG1, ARG2, ARG3)

Halfword packing instruction.

Combines bits[31:16] of val1 with bits[15:0] of val2 right-shifted with the val3.

Functions

__STATIC_FORCEINLINE int32_t __SSAT (int32_t val, uint32_t sat)

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

__STATIC_FORCEINLINE uint32_t __USAT (int32_t val, uint32_t 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

__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 uint32_t __RBIT (uint32_t value)

Reverse bit order of value.

Reverses the bit order of the given value.

Parameters

value[in] Value to reverse

Returns

Reversed value

__STATIC_FORCEINLINE uint8_t __CLZ (uint32_t 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