| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
Byte Reordering
Endianness and Byte Ordering

## Detailed Description

Macros and functions for forced byte reordering.

## Macros
#define | SWAPENDIAN_16(x) (uint16_t)((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
#define | SWAPENDIAN_32(x)

## Functions
static uint16_t | SwapEndian_16 (const uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST
static uint32_t | SwapEndian_32 (const uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST
static void | SwapEndian_n (void *const Data, uint8_t Length) ATTR_NON_NULL_PTR_ARG(1)

## Macro Definition Documentation

#define SWAPENDIAN_16 | ( |  | x | ) | (uint16_t)((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))

Swaps the byte ordering of a 16-bit value at compile-time. Do not use this macro for swapping byte orderings of dynamic values computed at runtime, use SwapEndian_16() instead. The result of this macro can be used inside struct or other variable initializers outside of a function, something that is not possible with the inline function variant.

Parameters

  x | 16-bit value whose byte ordering is to be swapped.

Returns
  Input value with the byte ordering reversed.

Definition at line 84 of file Endianness.h.

#define SWAPENDIAN_32 | ( |  | x | ) |

Value:
(uint32_t)((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \
(((x) & 0x0000FF00UL) << 8UL) | (((x) & 0x000000FFUL) << 24UL))

Swaps the byte ordering of a 32-bit value at compile-time. Do not use this macro for swapping byte orderings of dynamic values computed at runtime- use SwapEndian_32() instead. The result of this macro can be used inside struct or other variable initializers outside of a function, something that is not possible with the inline function variant.

Parameters

  x | 32-bit value whose byte ordering is to be swapped.

Returns
  Input value with the byte ordering reversed.

Definition at line 97 of file Endianness.h.

## Function Documentation

static uint16_t SwapEndian_16 | ( | const uint16_t | Word | ) |
| inline static

Function to reverse the byte ordering of the individual bytes in a 16 bit value.

Parameters

  Word | Word of data whose bytes are to be swapped.

Definition at line 393 of file Endianness.h.

static uint32_t SwapEndian_32 | ( | const uint32_t | DWord | ) |
| inline static

Function to reverse the byte ordering of the individual bytes in a 32 bit value.

Parameters

  DWord | Double word of data whose bytes are to be swapped.

Definition at line 422 of file Endianness.h.

static void SwapEndian_n | ( | void *const | Data,
|  | uint8_t | Length
| ) |  |
| inline static

Function to reverse the byte ordering of the individual bytes in a n byte value.

Parameters

  [in,out] | Data | Pointer to a number containing an even number of bytes to be reversed.
  | Length | Length of the data in bytes.

Definition at line 457 of file Endianness.h.