![]() |
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>
#include "FreeRTOS.h"
#include "queue.h"
#include "task.h"
#include "timers.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_ADDEND_INTERFACE |
#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_CLOCK_TICK_FREQ_HZ (1000000000 / PTP_INCREMENT_NSEC) |
Rated clock tick frequency. | |
#define | FLEXPTP_FREERTOS (1) |
#define | FLEXPTP_NON_LINUX_OS (1) |
flexPTP task priority | |
#define | FLEXPTP_TASK_PRIORITY (configMAX_PRIORITIES / 2) |
#define | FLEXPTP_TASK_STACK_SIZE (2048) |
flexPTP task stack size | |
#define | PTP_HEARTBEAT_TICKRATE_MS (62) |
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)) |
#define | FLEXPTP_MS_TO_TICKS(ms) ((ms + (PTP_HEARTBEAT_TICKRATE_MS - 1)) / PTP_HEARTBEAT_TICKRATE_MS) |
Interval conversion between milliseconds and ticks. | |
#define | FLEXPTP_RANDOM_TAGGED_MESSAGE_TTL_TICKS (20) |
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 38 of file ptp_defs.h.
#define FLEXPTP_FREERTOS (1) |
Definition at line 86 of file ptp_defs.h.
#define FLEXPTP_htonl | ( | a | ) |
Definition at line 222 of file ptp_defs.h.
#define FLEXPTP_htons | ( | a | ) |
Definition at line 230 of file ptp_defs.h.
#define FLEXPTP_MS_TO_TICKS | ( | ms | ) | ((ms + (PTP_HEARTBEAT_TICKRATE_MS - 1)) / PTP_HEARTBEAT_TICKRATE_MS) |
Interval conversion between milliseconds and ticks.
Definition at line 238 of file ptp_defs.h.
#define FLEXPTP_NON_LINUX_OS (1) |
flexPTP task priority
Definition at line 115 of file ptp_defs.h.
#define FLEXPTP_ntohl | ( | a | ) | FLEXPTP_htonl((a)) |
Definition at line 228 of file ptp_defs.h.
#define FLEXPTP_ntohs | ( | a | ) | FLEXPTP_htons((a)) |
Definition at line 234 of file ptp_defs.h.
#define FLEXPTP_RANDOM_TAGGED_MESSAGE_TTL_TICKS (20) |
Definition at line 240 of file ptp_defs.h.
#define FLEXPTP_TASK_PRIORITY (configMAX_PRIORITIES / 2) |
Definition at line 117 of file ptp_defs.h.
#define FLEXPTP_TASK_STACK_SIZE (2048) |
flexPTP task stack size
Definition at line 124 of file ptp_defs.h.
#define PTP_ACCURACY_LIMIT_NS (100) |
Limit of the LOCKED state.
Definition at line 136 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 78 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 77 of file ptp_defs.h.
#define PTP_ADDEND_INTERFACE |
Definition at line 72 of file ptp_defs.h.
#define PTP_ANNOUNCE_BODY_LENGTH (20) |
Length of the Announce body.
Definition at line 51 of file ptp_defs.h.
#define PTP_ANNOUNCE_RECEIPT_TIMEOUT (3) |
Number of tolerated consecutive lost Announce messages.
Definition at line 156 of file ptp_defs.h.
#define PTP_BEST_CLOCK_CLASS (PTP_CC_DEFAULT) |
Best clock class of this device.
Definition at line 174 of file ptp_defs.h.
#define PTP_BMCA_LISTENING_TIMEOUT_MS (3000) |
BMCA LISTENING state timeout.
Definition at line 148 of file ptp_defs.h.
#define PTP_CLOCK_PRIORITY1 (128) |
Clock priority1.
Definition at line 164 of file ptp_defs.h.
#define PTP_CLOCK_PRIORITY2 (128) |
Clock priority2.
Definition at line 168 of file ptp_defs.h.
#define PTP_CLOCK_TICK_FREQ_HZ (1000000000 / PTP_INCREMENT_NSEC) |
Rated clock tick frequency.
Definition at line 81 of file ptp_defs.h.
#define PTP_COLOR_BGREEN "\x1b[92m" |
Bright green.
Definition at line 207 of file ptp_defs.h.
#define PTP_COLOR_BLUE "\x1b[34m" |
Blue.
Definition at line 210 of file ptp_defs.h.
#define PTP_COLOR_BMAGENTA "\x1b[95m" |
Bright magenta.
Definition at line 212 of file ptp_defs.h.
#define PTP_COLOR_BRED "\x1b[91m" |
Bright red.
Definition at line 205 of file ptp_defs.h.
#define PTP_COLOR_BYELLOW "\x1b[93m" |
Bright yellow.
Definition at line 209 of file ptp_defs.h.
#define PTP_COLOR_CYAN "\x1b[36m" |
Cyan.
Definition at line 213 of file ptp_defs.h.
#define PTP_COLOR_GREEN "\x1b[32m" |
Green.
Definition at line 206 of file ptp_defs.h.
#define PTP_COLOR_MAGENTA "\x1b[35m" |
Magenta.
Definition at line 211 of file ptp_defs.h.
#define PTP_COLOR_RED "\x1b[31m" |
#define PTP_COLOR_RESET "\x1b[0m" |
Reset colors.
Definition at line 214 of file ptp_defs.h.
#define PTP_COLOR_YELLOW "\x1b[33m" |
Yellow.
Definition at line 208 of file ptp_defs.h.
#define PTP_DEFAULT_COARSE_TRIGGER_NS (20000000) |
Coarse correction kick-in threshold.
Definition at line 144 of file ptp_defs.h.
#define PTP_DEFAULT_SERVO_OFFSET (0) |
Default servo offset in nanoseconds.
Definition at line 140 of file ptp_defs.h.
#define PTP_ENABLE_MASTER_OPERATION (0) |
By default, disable Master operation mode.
Definition at line 160 of file ptp_defs.h.
#define PTP_ETHERTYPE (0x88F7) |
PTP EtherType.
Definition at line 37 of file ptp_defs.h.
#define PTP_FALLBACK_UTC_OFFSET (37) |
UTC offset caused by the accumulated leap seconds.
Definition at line 186 of file ptp_defs.h.
#define PTP_HEADER_LENGTH (34) |
Length of the PTP header.
Definition at line 48 of file ptp_defs.h.
#define PTP_HEARTBEAT_TICKRATE_MS (62) |
Heartbeat ticking period.
Definition at line 128 of file ptp_defs.h.
#define PTP_IGMP_DEFAULT_STR ("224.0.1.129") |
PTP default IGMP group.
Definition at line 22 of file ptp_defs.h.
#define PTP_IGMP_PEER_DELAY_STR ("224.0.0.107") |
PTP Peer-Delay IGMP group.
Definition at line 23 of file ptp_defs.h.
#define PTP_MASTER_QUALIFICATION_TIMEOUT (4) |
Number of Announce intervals.
Definition at line 152 of file ptp_defs.h.
#define PTP_MAX_PROFILE_NAME_LENGTH (7) |
Maximum profile name length.
Definition at line 65 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 66 of file ptp_defs.h.
#define PTP_PCKT_PDELAY_RESERVED_END (10) |
Reserved area at the end of the message.
Definition at line 57 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 61 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 55 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 56 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 54 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 58 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 59 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 60 of file ptp_defs.h.
#define PTP_PCKT_SIZE_SYNC (PTP_HEADER_LENGTH + PTP_TIMESTAMP_LENGTH) |
Size of a Sync message.
Definition at line 53 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 196 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 192 of file ptp_defs.h.
#define PTP_PORT_EVENT (319) |
PTP event message port.
Definition at line 45 of file ptp_defs.h.
#define PTP_PORT_GENERAL (320) |
PTP general message port.
Definition at line 46 of file ptp_defs.h.
#define PTP_PORT_ID (1) |
PTP port ID on the device.
Definition at line 132 of file ptp_defs.h.
#define PTP_PORT_ID_LENGTH (10) |
Length of the port identification field.
Definition at line 50 of file ptp_defs.h.
#define PTP_TIME_SOURCE (PTP_TSRC_INTERNAL_OSCILLATOR) |
Time source of this device.
Definition at line 182 of file ptp_defs.h.
#define PTP_TIMESTAMP_LENGTH (10) |
Length of a single timestamp.
Definition at line 49 of file ptp_defs.h.
#define PTP_WORST_ACCURACY (PTP_CA_UNKNOWN) |
Worst accuracy of this device.
Definition at line 178 of file ptp_defs.h.
typedef ip4_addr ip4_addr_t |
Definition at line 31 of file ptp_defs.h.
typedef ip4_addr ip_addr_t |
Definition at line 30 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.