Files | Defines | Functions

# Byteordering

Architecture-dependent handling of byte-ordering. More...

## Files
file | byteordering.c

| Byte-order handling implementation (license: GPLv2 or LGPLv2.1).
file | byteordering.h

| Byte-order handling header (license: GPLv2 or LGPLv2.1).
## Defines
#define | HTOL16(val)
| Converts a 16-bit integer from host byte order to little-endian byte order.
#define | HTOL32(val)
| Converts a 32-bit integer from host byte order to little-endian byte order.
#define | LTOH16(val)
| Converts a 16-bit integer from little-endian byte order to host byte order.
#define | LTOH32(val)
| Converts a 32-bit integer from little-endian byte order to host byte order.
## Functions
uint16_t | read16 (const uint8_t *p)
| Reads a 16-bit integer from memory in little-endian byte order.
uint32_t | read32 (const uint8_t *p)
| Reads a 32-bit integer from memory in little-endian byte order.
void | write16 (uint8_t *p, uint16_t i)
| Writes a 16-bit integer into memory in little-endian byte order.
void | write32 (uint8_t *p, uint32_t i)
| Writes a 32-bit integer into memory in little-endian byte order.
uint16_t | htol16 (uint16_t h)
| Converts a 16-bit integer from host byte order to little-endian byte order.
uint32_t | htol32 (uint32_t h)
| Converts a 32-bit integer from host byte order to little-endian byte order.
uint16_t | ltoh16 (uint16_t l)
| Converts a 16-bit integer from little-endian byte order to host byte order.
uint32_t | ltoh32 (uint32_t l)
| Converts a 32-bit integer from little-endian byte order to host byte order.

## Detailed Description

Architecture-dependent handling of byte-ordering.

## Define Documentation

#define HTOL16 | ( |  | val | ) |

Converts a 16-bit integer from host byte order to little-endian byte order.

Use this macro for compile time constants only. For variable values use the function htol16() instead. This saves code size.

Parameters:

  `[in]` | val | A 16-bit integer in host byte order.

Returns:
  The given 16-bit integer converted to little-endian byte order.

#define HTOL32 | ( |  | val | ) |

Converts a 32-bit integer from host byte order to little-endian byte order.

Use this macro for compile time constants only. For variable values use the function htol32() instead. This saves code size.

Parameters:

  `[in]` | val | A 32-bit integer in host byte order.

Returns:
  The given 32-bit integer converted to little-endian byte order.

#define LTOH16 | ( |  | val | ) |

Converts a 16-bit integer from little-endian byte order to host byte order.

Use this macro for compile time constants only. For variable values use the function ltoh16() instead. This saves code size.

Parameters:

  `[in]` | val | A 16-bit integer in little-endian byte order.

Returns:
  The given 16-bit integer converted to host byte order.

#define LTOH32 | ( |  | val | ) |

Converts a 32-bit integer from little-endian byte order to host byte order.

Use this macro for compile time constants only. For variable values use the function ltoh32() instead. This saves code size.

Parameters:

  `[in]` | val | A 32-bit integer in little-endian byte order.

Returns:
  The given 32-bit integer converted to host byte order.

## Function Documentation

uint16_t htol16 | ( | uint16_t | h | ) |

Converts a 16-bit integer from host byte order to little-endian byte order.

Use this function on variable values instead of the macro HTOL16(). This saves code size.

Parameters:

  `[in]` | h | A 16-bit integer in host byte order.

Returns:
  The given 16-bit integer converted to little-endian byte order.

uint32_t htol32 | ( | uint32_t | h | ) |

Converts a 32-bit integer from host byte order to little-endian byte order.

Use this function on variable values instead of the macro HTOL32(). This saves code size.

Parameters:

  `[in]` | h | A 32-bit integer in host byte order.

Returns:
  The given 32-bit integer converted to little-endian byte order.

uint16_t ltoh16 | ( | uint16_t | l | ) |

Converts a 16-bit integer from little-endian byte order to host byte order.

Use this function on variable values instead of the macro LTOH16(). This saves code size.

Parameters:

  `[in]` | l | A 16-bit integer in little-endian byte order.

Returns:
  The given 16-bit integer converted to host byte order.

uint32_t ltoh32 | ( | uint32_t | l | ) |

Converts a 32-bit integer from little-endian byte order to host byte order.

Use this function on variable values instead of the macro LTOH32(). This saves code size.

Parameters:

  `[in]` | l | A 32-bit integer in little-endian byte order.

Returns:
  The given 32-bit integer converted to host byte order.

uint16_t read16 | ( | const uint8_t * | p | ) |

Reads a 16-bit integer from memory in little-endian byte order.

Parameters:

  `[in]` | p | Pointer from where to read the integer.

Returns:
  The 16-bit integer read from memory.

uint32_t read32 | ( | const uint8_t * | p | ) |

Reads a 32-bit integer from memory in little-endian byte order.

Parameters:

  `[in]` | p | Pointer from where to read the integer.

Returns:
  The 32-bit integer read from memory.

void write16 | ( | uint8_t * | p,
|  | uint16_t | i |
| ) |  |  |

Writes a 16-bit integer into memory in little-endian byte order.

Parameters:

  `[in]` | p | Pointer where to write the integer to.
  `[in]` | i | The 16-bit integer to write.

void write32 | ( | uint8_t * | p,
|  | uint32_t | i |
| ) |  |  |

Writes a 32-bit integer into memory in little-endian byte order.

Parameters:

  `[in]` | p | Pointer where to write the integer to.
  `[in]` | i | The 32-bit integer to write.