See Network to Host Byte Order Conversion for detailed documentation.

License#

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

The licensor of this software is Silicon Laboratories Inc. Your use of this software is governed by the terms of Silicon Labs Master Software License Agreement (MSLA) available at www.silabs.com/about-us/legal/master-software-license-agreement. This software is distributed to you in Source Code format and is governed by the sections of the MSLA applicable to Source Code.

/***************************************************************************/
#ifndef __ENDIAN_H__
#define __ENDIAN_H__
#include <stdint.h>
// If this is being compiled on a Mac then we need to disable the defines
// from its own internal _endian.h file since they conflict with our
// defines. This allows us to compile the 3xx tools for Mac.
#ifdef __APPLE__
  #undef NTOHL
  #undef NTOHS
  #undef HTONL
  #undef HTONS
#endif

#if BIGENDIAN_CPU == false

  #ifndef NTOHS  // some platforms already define this
uint16_t NTOHS(uint16_t val);

  #endif

  #ifndef NTOHL  // some platforms already define this
uint32_t NTOHL(uint32_t val);

  #endif

#else // BIGENDIAN_CPU == true

  #ifndef NTOHS  // some platforms already define this
    #define NTOHS(val)  (val)
  #endif
  #ifndef NTOHL  // some platforms already define this
    #define NTOHL(val)  (val)
  #endif

#endif

// The HTON and NTOH operations are the same for sane architectures (eg. big
// and little endian) so define the inverse functions if they don't exist
#ifndef HTONL
  #define HTONL NTOHL
#endif
#ifndef HTONS
  #define HTONS NTOHS
#endif

/* Swap byte order, e.g. LE to BE or BE to LE.
 * This function is used when working with 802.15.4 frames on 8051 MCUs. */
uint32_t SwapEndiannessInt32u(uint32_t val);

#endif //__ENDIAN_H__

Macros#

#define
HTONL NTOHL
#define
HTONS NTOHS

Functions#

uint16_t
NTOHS(uint16_t val)

Converts a short (16-bit) value from network to host byte order.

uint32_t
NTOHL(uint32_t val)

Converts a long (32-bit) value from network to host byte order.

uint32_t
SwapEndiannessInt32u(uint32_t val)

Macro Definition Documentation#

HTONL#

#define HTONL
Value:
NTOHL

Definition at line 71 of file /mnt/raid/workspaces/ws.OJKVohJa4/overlay/gsdk/platform/base/hal/micro/endian.h

HTONS#

#define HTONS
Value:
NTOHS

Definition at line 74 of file /mnt/raid/workspaces/ws.OJKVohJa4/overlay/gsdk/platform/base/hal/micro/endian.h

Function Documentation#

NTOHS#

uint16_t NTOHS (uint16_t val)

Converts a short (16-bit) value from network to host byte order.

Parameters
N/Aval

Definition at line 45 of file /mnt/raid/workspaces/ws.OJKVohJa4/overlay/gsdk/platform/base/hal/micro/endian.h

NTOHL#

uint32_t NTOHL (uint32_t val)

Converts a long (32-bit) value from network to host byte order.

Parameters
N/Aval

Definition at line 53 of file /mnt/raid/workspaces/ws.OJKVohJa4/overlay/gsdk/platform/base/hal/micro/endian.h

SwapEndiannessInt32u#

uint32_t SwapEndiannessInt32u (uint32_t val)
Parameters
N/Aval

Definition at line 79 of file /mnt/raid/workspaces/ws.OJKVohJa4/overlay/gsdk/platform/base/hal/micro/endian.h