![]() |
flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
|
In here reside a multitude of fundamental PTP-related constants and definitions. More...
#include <stdint.h>
#include <flexptp_options.h>
Go to the source code of this file.
Macros | |
#define | PTP_IGMP_DEFAULT_STR ("224.0.1.129") |
PTP default IGMP group. | |
#define | PTP_IGMP_PEER_DELAY_STR ("224.0.0.107") |
PTP Peer-Delay IGMP group. | |
#define | PTP_ETHERTYPE (0x88F7) |
PTP EtherType. | |
#define | ETHERTYPE_PTP (PTP_ETHERTYPE) |
(for lwIP conformity) | |
#define | PTP_PORT_EVENT (319) |
PTP event message port. | |
#define | PTP_PORT_GENERAL (320) |
PTP general message port. | |
#define | PTP_HEADER_LENGTH (34) |
Length of the PTP header. | |
#define | PTP_TIMESTAMP_LENGTH (10) |
Length of a single timestamp. | |
#define | PTP_PORT_ID_LENGTH (10) |
Length of the port identification field. | |
#define | PTP_ANNOUNCE_BODY_LENGTH (20) |
Length of the Announce body. | |
#define | PTP_PCKT_SIZE_SYNC (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH) |
Size of a Sync message. | |
#define | PTP_PCKT_SIZE_FOLLOW_UP (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH) |
Size of a Follow_Up message. | |
#define | PTP_PCKT_SIZE_DELAY_REQ (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH) |
Size of a Delay_Req message. | |
#define | PTP_PCKT_SIZE_DELAY_RESP (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH + PTP_PORT_ID_LENGTH) |
Size of a Delay_Resp message. | |
#define | PTP_PCKT_PDELAY_RESERVED_END (10) |
Reserved area at the end of the message. | |
#define | PTP_PCKT_SIZE_PDELAY_REQ (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH + PTP_PCKT_PDELAY_RESERVED_END) |
Size of a PDelay_Req message. | |
#define | PTP_PCKT_SIZE_PDELAY_RESP (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH + PTP_PORT_ID_LENGTH) |
Size of a PDelay_Resp message. | |
#define | PTP_PCKT_SIZE_PDELAY_RESP_FOLLOW_UP (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH + PTP_PORT_ID_LENGTH) |
Size of a PDelay_Resp_Follow_Up message. | |
#define | PTP_PCKT_SIZE_ANNOUNCE (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH + PTP_ANNOUNCE_BODY_LENGTH) |
Size of an Announce message. | |
#define | PTP_MAX_PROFILE_NAME_LENGTH (7) |
Maximum profile name length. | |
#define | PTP_MAX_TLV_PRESET_NAME_LENGTH PTP_MAX_PROFILE_NAME_LENGTH |
Maximum TLV preset name length. | |
#define | PTP_CLOCK_TICK_FREQ_HZ (1000000000 / PTP_INCREMENT_NSEC) |
Rated clock tick frequency. | |
#define | PTP_ADDEND_INIT (((double)(0x100000000)) / (((double)(PTP_MAIN_OSCILLATOR_FREQ_HZ)) / ((double)(PTP_CLOCK_TICK_FREQ_HZ)))) |
Initial addend value. | |
#define | PTP_ADDEND_CORR_PER_PPB_F (((double)0x100000000) / ((double)PTP_INCREMENT_NSEC * PTP_MAIN_OSCILLATOR_FREQ_HZ)) |
Addend/ppb ratio. | |
#define | PTP_HEARTBEAT_TICKRATE_MS (125) |
Heartbeat ticking period. | |
#define | PTP_PORT_ID (1) |
PTP port ID on the device. | |
#define | PTP_ACCURACY_LIMIT_NS (100) |
Limit of the LOCKED state. | |
#define | PTP_DEFAULT_SERVO_OFFSET (0) |
Default servo offset in nanoseconds. | |
#define | PTP_DEFAULT_COARSE_TRIGGER_NS (20000000) |
Coarse correction kick-in threshold. | |
#define | PTP_BMCA_LISTENING_TIMEOUT_MS (3000) |
BMCA LISTENING state timeout. | |
#define | PTP_MASTER_QUALIFICATION_TIMEOUT (4) |
Number of Announce intervals. | |
#define | PTP_ANNOUNCE_RECEIPT_TIMEOUT (3) |
Number of tolerated consecutive lost Announce messages. | |
#define | PTP_ENABLE_MASTER_OPERATION (0) |
By default, disable Master operation mode. | |
#define | PTP_CLOCK_PRIORITY1 (128) |
Clock priority1. | |
#define | PTP_CLOCK_PRIORITY2 (128) |
Clock priority2. | |
#define | PTP_BEST_CLOCK_CLASS (PTP_CC_DEFAULT) |
Best clock class of this device. | |
#define | PTP_WORST_ACCURACY (PTP_CA_UNKNOWN) |
Worst accuracy of this device. | |
#define | PTP_TIME_SOURCE (PTP_TSRC_INTERNAL_OSCILLATOR) |
Time source of this device. | |
#define | PTP_FALLBACK_UTC_OFFSET (37) |
UTC offset caused by the accumulated leap seconds. | |
#define | PTP_PDELAY_SLAVE_QUALIFICATION (3) |
Number of consecutive PDelReq-PDelResp iterations after the SLAVE is considered stable. | |
#define | PTP_PDELAY_DROPOUT PTP_PDELAY_SLAVE_QUALIFICATION |
Maximum number of failed PDelReq-PDelResp cycles before the MASTER drops the SLAVE. | |
#define | PTP_COLOR_RED "\x1b[31m" |
< Define this to override PTP_COLOR_* macros | |
#define | PTP_COLOR_BRED "\x1b[91m" |
Bright red. | |
#define | PTP_COLOR_GREEN "\x1b[32m" |
Green. | |
#define | PTP_COLOR_BGREEN "\x1b[92m" |
Bright green. | |
#define | PTP_COLOR_YELLOW "\x1b[33m" |
Yellow. | |
#define | PTP_COLOR_BYELLOW "\x1b[93m" |
Bright yellow. | |
#define | PTP_COLOR_BLUE "\x1b[34m" |
Blue. | |
#define | PTP_COLOR_MAGENTA "\x1b[35m" |
Magenta. | |
#define | PTP_COLOR_BMAGENTA "\x1b[95m" |
Bright magenta. | |
#define | PTP_COLOR_CYAN "\x1b[36m" |
Cyan. | |
#define | PTP_COLOR_RESET "\x1b[0m" |
Reset colors. | |
#define | FLEXPTP_htonl(a) |
#define | FLEXPTP_ntohl(a) FLEXPTP_htonl((a)) |
#define | FLEXPTP_htons(a) |
#define | FLEXPTP_ntohs(a) FLEXPTP_htons((a)) |
Typedefs | |
typedef ip4_addr | ip_addr_t |
typedef ip4_addr | ip4_addr_t |
Variables | |
const ip_addr_t | PTP_IGMP_PRIMARY |
Primary IGMP address. | |
const ip_addr_t | PTP_IGMP_PEER_DELAY |
Peer_Delay IGMP address. | |
const uint8_t | PTP_ETHERNET_PRIMARY [6] |
PTP's L2 Primary Ethernet address. | |
const uint8_t | PTP_ETHERNET_PEER_DELAY [6] |
PTP's L2 Peer_Delay Ethernet address. | |
In here reside a multitude of fundamental PTP-related constants and definitions.
Definition in file ptp_defs.h.
#define ETHERTYPE_PTP (PTP_ETHERTYPE) |
(for lwIP conformity)
Definition at line 30 of file ptp_defs.h.
#define FLEXPTP_htonl | ( | a | ) |
Definition at line 163 of file ptp_defs.h.
#define FLEXPTP_htons | ( | a | ) |
Definition at line 171 of file ptp_defs.h.
#define FLEXPTP_ntohl | ( | a | ) | FLEXPTP_htonl((a)) |
Definition at line 169 of file ptp_defs.h.
#define FLEXPTP_ntohs | ( | a | ) | FLEXPTP_htons((a)) |
Definition at line 175 of file ptp_defs.h.
#define PTP_ACCURACY_LIMIT_NS (100) |
Limit of the LOCKED state.
Definition at line 77 of file ptp_defs.h.
#define PTP_ADDEND_CORR_PER_PPB_F (((double)0x100000000) / ((double)PTP_INCREMENT_NSEC * PTP_MAIN_OSCILLATOR_FREQ_HZ)) |
Addend/ppb ratio.
Definition at line 64 of file ptp_defs.h.
#define PTP_ADDEND_INIT (((double)(0x100000000)) / (((double)(PTP_MAIN_OSCILLATOR_FREQ_HZ)) / ((double)(PTP_CLOCK_TICK_FREQ_HZ)))) |
Initial addend value.
Definition at line 63 of file ptp_defs.h.
#define PTP_ANNOUNCE_BODY_LENGTH (20) |
Length of the Announce body.
Definition at line 43 of file ptp_defs.h.
#define PTP_ANNOUNCE_RECEIPT_TIMEOUT (3) |
Number of tolerated consecutive lost Announce messages.
Definition at line 97 of file ptp_defs.h.
#define PTP_BEST_CLOCK_CLASS (PTP_CC_DEFAULT) |
Best clock class of this device.
Definition at line 115 of file ptp_defs.h.
#define PTP_BMCA_LISTENING_TIMEOUT_MS (3000) |
BMCA LISTENING state timeout.
Definition at line 89 of file ptp_defs.h.
#define PTP_CLOCK_PRIORITY1 (128) |
Clock priority1.
Definition at line 105 of file ptp_defs.h.
#define PTP_CLOCK_PRIORITY2 (128) |
Clock priority2.
Definition at line 109 of file ptp_defs.h.
#define PTP_CLOCK_TICK_FREQ_HZ (1000000000 / PTP_INCREMENT_NSEC) |
Rated clock tick frequency.
Definition at line 62 of file ptp_defs.h.
#define PTP_COLOR_BGREEN "\x1b[92m" |
Bright green.
Definition at line 148 of file ptp_defs.h.
#define PTP_COLOR_BLUE "\x1b[34m" |
Blue.
Definition at line 151 of file ptp_defs.h.
#define PTP_COLOR_BMAGENTA "\x1b[95m" |
Bright magenta.
Definition at line 153 of file ptp_defs.h.
#define PTP_COLOR_BRED "\x1b[91m" |
Bright red.
Definition at line 146 of file ptp_defs.h.
#define PTP_COLOR_BYELLOW "\x1b[93m" |
Bright yellow.
Definition at line 150 of file ptp_defs.h.
#define PTP_COLOR_CYAN "\x1b[36m" |
Cyan.
Definition at line 154 of file ptp_defs.h.
#define PTP_COLOR_GREEN "\x1b[32m" |
Green.
Definition at line 147 of file ptp_defs.h.
#define PTP_COLOR_MAGENTA "\x1b[35m" |
Magenta.
Definition at line 152 of file ptp_defs.h.
#define PTP_COLOR_RED "\x1b[31m" |
#define PTP_COLOR_RESET "\x1b[0m" |
Reset colors.
Definition at line 155 of file ptp_defs.h.
#define PTP_COLOR_YELLOW "\x1b[33m" |
Yellow.
Definition at line 149 of file ptp_defs.h.
#define PTP_DEFAULT_COARSE_TRIGGER_NS (20000000) |
Coarse correction kick-in threshold.
Definition at line 85 of file ptp_defs.h.
#define PTP_DEFAULT_SERVO_OFFSET (0) |
Default servo offset in nanoseconds.
Definition at line 81 of file ptp_defs.h.
#define PTP_ENABLE_MASTER_OPERATION (0) |
By default, disable Master operation mode.
Definition at line 101 of file ptp_defs.h.
#define PTP_ETHERTYPE (0x88F7) |
PTP EtherType.
Definition at line 29 of file ptp_defs.h.
#define PTP_FALLBACK_UTC_OFFSET (37) |
UTC offset caused by the accumulated leap seconds.
Definition at line 127 of file ptp_defs.h.
#define PTP_HEADER_LENGTH (34) |
Length of the PTP header.
Definition at line 40 of file ptp_defs.h.
#define PTP_HEARTBEAT_TICKRATE_MS (125) |
Heartbeat ticking period.
Definition at line 69 of file ptp_defs.h.
#define PTP_IGMP_DEFAULT_STR ("224.0.1.129") |
PTP default IGMP group.
Definition at line 18 of file ptp_defs.h.
#define PTP_IGMP_PEER_DELAY_STR ("224.0.0.107") |
PTP Peer-Delay IGMP group.
Definition at line 19 of file ptp_defs.h.
#define PTP_MASTER_QUALIFICATION_TIMEOUT (4) |
Number of Announce intervals.
Definition at line 93 of file ptp_defs.h.
#define PTP_MAX_PROFILE_NAME_LENGTH (7) |
Maximum profile name length.
Definition at line 57 of file ptp_defs.h.
#define PTP_MAX_TLV_PRESET_NAME_LENGTH PTP_MAX_PROFILE_NAME_LENGTH |
Maximum TLV preset name length.
Definition at line 58 of file ptp_defs.h.
#define PTP_PCKT_PDELAY_RESERVED_END (10) |
Reserved area at the end of the message.
Definition at line 49 of file ptp_defs.h.
#define PTP_PCKT_SIZE_ANNOUNCE (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH + PTP_ANNOUNCE_BODY_LENGTH) |
Size of an Announce message.
Definition at line 53 of file ptp_defs.h.
#define PTP_PCKT_SIZE_DELAY_REQ (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH) |
Size of a Delay_Req message.
Definition at line 47 of file ptp_defs.h.
#define PTP_PCKT_SIZE_DELAY_RESP (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH + PTP_PORT_ID_LENGTH) |
Size of a Delay_Resp message.
Definition at line 48 of file ptp_defs.h.
#define PTP_PCKT_SIZE_FOLLOW_UP (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH) |
Size of a Follow_Up message.
Definition at line 46 of file ptp_defs.h.
#define PTP_PCKT_SIZE_PDELAY_REQ (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH + PTP_PCKT_PDELAY_RESERVED_END) |
Size of a PDelay_Req message.
Definition at line 50 of file ptp_defs.h.
#define PTP_PCKT_SIZE_PDELAY_RESP (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH + PTP_PORT_ID_LENGTH) |
Size of a PDelay_Resp message.
Definition at line 51 of file ptp_defs.h.
#define PTP_PCKT_SIZE_PDELAY_RESP_FOLLOW_UP (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH + PTP_PORT_ID_LENGTH) |
Size of a PDelay_Resp_Follow_Up message.
Definition at line 52 of file ptp_defs.h.
#define PTP_PCKT_SIZE_SYNC (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH) |
Size of a Sync message.
Definition at line 45 of file ptp_defs.h.
#define PTP_PDELAY_DROPOUT PTP_PDELAY_SLAVE_QUALIFICATION |
Maximum number of failed PDelReq-PDelResp cycles before the MASTER drops the SLAVE.
Definition at line 137 of file ptp_defs.h.
#define PTP_PDELAY_SLAVE_QUALIFICATION (3) |
Number of consecutive PDelReq-PDelResp iterations after the SLAVE is considered stable.
Definition at line 133 of file ptp_defs.h.
#define PTP_PORT_EVENT (319) |
PTP event message port.
Definition at line 37 of file ptp_defs.h.
#define PTP_PORT_GENERAL (320) |
PTP general message port.
Definition at line 38 of file ptp_defs.h.
#define PTP_PORT_ID (1) |
PTP port ID on the device.
Definition at line 73 of file ptp_defs.h.
#define PTP_PORT_ID_LENGTH (10) |
Length of the port identification field.
Definition at line 42 of file ptp_defs.h.
#define PTP_TIME_SOURCE (PTP_TSRC_INTERNAL_OSCILLATOR) |
Time source of this device.
Definition at line 123 of file ptp_defs.h.
#define PTP_TIMESTAMP_LENGTH (10) |
Length of a single timestamp.
Definition at line 41 of file ptp_defs.h.
#define PTP_WORST_ACCURACY (PTP_CA_UNKNOWN) |
Worst accuracy of this device.
Definition at line 119 of file ptp_defs.h.
typedef ip4_addr ip4_addr_t |
Definition at line 23 of file ptp_defs.h.
typedef ip4_addr ip_addr_t |
Definition at line 22 of file ptp_defs.h.
|
extern |
PTP's L2 Peer_Delay Ethernet address.
Definition at line 4 of file ptp_defs.c.
|
extern |
PTP's L2 Primary Ethernet address.
Definition at line 3 of file ptp_defs.c.
|
extern |
Peer_Delay IGMP address.
|
extern |
Primary IGMP address.