flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
Loading...
Searching...
No Matches
format_utils.h File Reference

This module defines format conversion functions between network and host byte order and conversion functions between PTP logarithmic interval designator and time duration value. More...

#include <stdint.h>

Go to the source code of this file.

Functions

uint16_t ptp_logi2ms (int8_t logi)
 
int8_t ptp_ms2logi (uint16_t ms)
 
uint64_t FLEXPTP_ntohll (uint64_t in)
 
uint64_t FLEXPTP_htonll (uint64_t in)
 

Detailed Description

This module defines format conversion functions between network and host byte order and conversion functions between PTP logarithmic interval designator and time duration value.

Definition in file format_utils.h.

Function Documentation

◆ FLEXPTP_htonll()

uint64_t FLEXPTP_htonll ( uint64_t  in)

Function to swap byte order, convert LE representation to BE. The naming complies with other flexPTP host->network conversion function namings.

Parameters
invalue in BE representation
Returns
value in LE representation

Definition at line 35 of file format_utils.c.

◆ FLEXPTP_ntohll()

uint64_t FLEXPTP_ntohll ( uint64_t  in)

Function to swap byte order, convert BE representation to LE. The naming complies with other flexPTP network->host conversion function namings.

Parameters
invalue in BE representation
Returns
value in LE representation

Definition at line 30 of file format_utils.c.

◆ ptp_logi2ms()

uint16_t ptp_logi2ms ( int8_t  logi)

Convert logarithmic interval designator code to a milliseconds value. Input must be in the inclusive range of [-6, 3].

The function emulates the execution of the following computation: 2^(n) * 1000

Parameters
logiPTP-defined logarithmic interval code
Returns
closest defined period in milliseconds

Definition at line 14 of file format_utils.c.

◆ ptp_ms2logi()

int8_t ptp_ms2logi ( uint16_t  ms)

Convert millisecond period value to PTP-defined logarithmic interval designator code. Input must be a value from the following set: (15, 31, 62, 125, 250, 500, 1000, 2000, 4000, 8000).

This function mimics the following computation: round(log2(T/1000))

Parameters
msperiod in milliseconds. Values of above valid input set must be respected.
Returns
PTP-defined logarithmic interval code

Definition at line 19 of file format_utils.c.