pt1588-SH7216 1
IEEE1588v2 Implementation for Renesas SH7216 Demo
|
Handle sending and receiving of PTP messages. More...
Go to the source code of this file.
Defines | |
#define | set08(x, y) (*(x) = (y)) |
Set the 8-bits at address x in big-endian to the UInteger8 or Integer8 variable y. | |
#define | set16(x, y) (*(x) = ((y) >> 8), *((x) + 1) = (y)) |
Set the 16-bits at address x in big-endian to the UInteger16 or Integer16 variable y. | |
#define | set32(x, y) |
Set the 32-bits at address x in big-endian to the UInteger32 or Integer32 variable y. | |
#define | set64(x, y) (memcpy((x), &(y), 8)) |
Set the 64-bits at address x in big-endian to the UInteger64 or Integer64 variable y. | |
#define | get4h(x, y) ((x) = (*(y) >> 4) & 0x0F) |
Set the variable x to the upper 4-bits in the 8-bit value in big-endian at address y. | |
#define | get4l(x, y) ((x) = (*(y)) & 0x0F) |
Set the variable x to the lower 4-bits in the 8-bit value in big-endian at address y. | |
#define | get08(x, y) ((x) = *(y)) |
Set the UInteger8 or Integer8 variable x to the upper 4-bits in the 8-bit value in big-endian at address y. | |
#define | get16(x, y) (memcpy(&(x), (y), 2)) |
Set the UInteger16 or Integer16 variable x to the 16-bit value in big-endian at address y. | |
#define | get32(x, y) (memcpy(&(x), (y), 4)) |
Set the UInteger32 or Integer32 variable x to the 32-bit value in big-endian at address y. | |
#define | get64(x, y) (memcpy(&(x), (y), 8)) |
Set the UInteger64 or Integer64 variable x to the 64-bit value in big-endian at address y. | |
Functions | |
void | sendAnnounceMsg (PTPState *ptp) |
Send Announce message over the network as a multicast PTP general message. | |
void | sendSyncMsg (PTPState *ptp) |
Send Sync message over the network as a multicast PTP event message. | |
void | sendFollowUpMsg (PTPState *ptp) |
Send Follow_Up message over the network as a multicast PTP general message. | |
void | sendDelayReqMsg (PTPState *ptp) |
Send Delay_Req message over the network as a multicast PTP event message. | |
void | sendDelayRespMsg (PTPState *ptp, DelayReqMsg *msg) |
Send Delay_Resp message over the network as a multicast PTP general message. | |
void | sendManagementMsg (PTPState *ptp, ManagementMsg *msg) |
Send Management message being sent over the network as a multicast PTP general message. | |
void | getSyncEventEgressTimestamp (PTPState *ptp) |
Attempt to provide an accurate timestamp for Sync message egress. | |
Boolean | getSyncEventIngressTimestamp (PTPState *ptp, UInteger16 seqId) |
Attempt to provide an accurate timestamp for Sync message ingress. | |
void | getDelayEventEgressTimestamp (PTPState *ptp) |
Attempt to provide an accurate timestamp for Delay_Req message egress. | |
Boolean | getDelayEventIngressTimestamp (PTPState *ptp, UInteger16 seqId) |
Attempt to provide an accurate timestamp for Delay_Req message ingress. | |
void | readHeader (Header *header) |
Fill the provided Header data structure with data from the message. | |
void | readAnnounceMsg (AnnounceMsg *msg) |
Fill the provided AnnounceMsg data structure with data from an Announce message. | |
void | readSyncMsg (SyncMsg *msg) |
Fill the provided SyncMsg data structure with data from a Sync message. | |
void | readFollowUpMsg (FollowUpMsg *msg) |
Fill the provided FollowUpMsg data structure with data from a Follow_Up message. | |
void | readDelayReqMsg (DelayReqMsg *msg) |
Fill the provided DelayReqMsg data structure with data from a Delay_Req message. | |
void | readDelayRespMsg (DelayRespMsg *msg) |
Fill the provided DelayRespMsg data structure with data from a Delay_Resp message. | |
void | readManagementMsg (ManagementMsg *msg) |
Fill the provided ManagementMsg data structure with data from a Management message. | |
void | clearIngressTimestamp () |
In SLAVE mode, the Delay_Req messages from other SLAVE clocks may be timestamped in hardware, even though they are ignored in software. | |
Variables | |
struct uip_udp_conn * | ptp_event_conn |
uIP connection to send event messages. | |
struct uip_udp_conn * | ptp_general_conn |
uIP connection to send general messages. |
#define get08 | ( | x, | |
y | |||
) | ((x) = *(y)) |
#define get16 | ( | x, | |
y | |||
) | (memcpy(&(x), (y), 2)) |
#define get32 | ( | x, | |
y | |||
) | (memcpy(&(x), (y), 4)) |
#define get4h | ( | x, | |
y | |||
) | ((x) = (*(y) >> 4) & 0x0F) |
#define get4l | ( | x, | |
y | |||
) | ((x) = (*(y)) & 0x0F) |
#define get64 | ( | x, | |
y | |||
) | (memcpy(&(x), (y), 8)) |
#define set08 | ( | x, | |
y | |||
) | (*(x) = (y)) |
#define set16 | ( | x, | |
y | |||
) | (*(x) = ((y) >> 8), *((x) + 1) = (y)) |
#define set32 | ( | x, | |
y | |||
) |
#define set64 | ( | x, | |
y | |||
) | (memcpy((x), &(y), 8)) |
void clearIngressTimestamp | ( | ) |
In SLAVE mode, the Delay_Req messages from other SLAVE clocks may be timestamped in hardware, even though they are ignored in software.
Clear receive timestamp.
Nothing is done because it is assumed that messages are received in the same order in software that they are timestamped in hardware, so ingressTimestamp is overwritten when the next message is processed.
void getDelayEventEgressTimestamp | ( | PTPState * | ptp | ) |
Attempt to provide an accurate timestamp for Delay_Req message egress.
Set PTPState.delayEventEgressTimestamp to the timestamp at which the latest Delay_Req message was sent.
Boolean getDelayEventIngressTimestamp | ( | PTPState * | ptp, |
UInteger16 | seqId | ||
) |
Attempt to provide an accurate timestamp for Delay_Req message ingress.
Set PTPState.delayEventIngressTimestamp to the timestamp at which the latest Delay_Req message was received.
void getSyncEventEgressTimestamp | ( | PTPState * | ptp | ) |
Attempt to provide an accurate timestamp for Sync message egress.
Set PTPState.syncEventEgressTimestamp to the timestamp at which the latest Sync message was sent.
Boolean getSyncEventIngressTimestamp | ( | PTPState * | ptp, |
UInteger16 | seqId | ||
) |
Attempt to provide an accurate timestamp for Sync message ingress.
Set PTPState.syncEventIngressTimestamp to the timestamp at which the latest Sync message was received.
void readAnnounceMsg | ( | AnnounceMsg * | msg | ) |
Fill the provided AnnounceMsg data structure with data from an Announce message.
Parse received Announce message into provided AnnounceMsg data structure, but do not update PTP state (13.5).
void readDelayReqMsg | ( | DelayReqMsg * | msg | ) |
Fill the provided DelayReqMsg data structure with data from a Delay_Req message.
Parse received Delay_Req message into provided DelayReqMsg data structure, but do not update PTP state (13.6).
void readDelayRespMsg | ( | DelayRespMsg * | msg | ) |
Fill the provided DelayRespMsg data structure with data from a Delay_Resp message.
Parse received Delay_Resp message into provided DelayRespMsg data structure, but do not update PTP state (13.8).
void readFollowUpMsg | ( | FollowUpMsg * | msg | ) |
Fill the provided FollowUpMsg data structure with data from a Follow_Up message.
Parse received Follow_Up message into provided FollowUpMsg data structure, but do not update PTP state (13.7).
void readHeader | ( | Header * | header | ) |
void readManagementMsg | ( | ManagementMsg * | msg | ) |
Fill the provided ManagementMsg data structure with data from a Management message.
Parse received Management message into provided ManagementMsg data structure, but do not update PTP state (15.1).
void readSyncMsg | ( | SyncMsg * | msg | ) |
void sendAnnounceMsg | ( | PTPState * | ptp | ) |
Send Announce message over the network as a multicast PTP general message.
Send an Announce message over the network, with content of message as specified in 13.5.
This implementation uses current data from the PTPState ptp and the current time to fill the buffer location uip_appdata with the Announce message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.
void sendDelayReqMsg | ( | PTPState * | ptp | ) |
Send Delay_Req message over the network as a multicast PTP event message.
Send a Delay_Req message over the network, with content of message as specified in 13.6.
This implementation uses current data from the PTPState ptp to fill the buffer location uip_appdata with the Delay_Req message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.
void sendDelayRespMsg | ( | PTPState * | ptp, |
DelayReqMsg * | msg | ||
) |
Send Delay_Resp message over the network as a multicast PTP general message.
Send a Delay_Resp message over the network, with content of message as specified in 13.8.
This implementation uses current data from the PTPState ptp and the DelayReqMsg msg for which this message is a response to fill the buffer location uip_appdata with the Delay_Resp message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.
void sendFollowUpMsg | ( | PTPState * | ptp | ) |
Send Follow_Up message over the network as a multicast PTP general message.
Send a Follow_Up message over the network, with content of message as specified in 13.7.
This implementation uses current data from the PTPState ptp to fill the buffer location uip_appdata with the Follow_Up message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.
void sendManagementMsg | ( | PTPState * | ptp, |
ManagementMsg * | msg | ||
) |
Send Management message being sent over the network as a multicast PTP general message.
Send a Management message over the network, with content of message as specified in 15.4.
This implementation uses current data from the PTPState ptp and the ManagementMsg msg which is being sent to fill the buffer location uip_appdata with the Management message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.
void sendSyncMsg | ( | PTPState * | ptp | ) |
Send Sync message over the network as a multicast PTP event message.
Send a Sync message over the network, with content of message as specified in 13.6.
This implementation uses current data from the PTPState ptp and the current time to fill the buffer location uip_appdata with the Sync message. Once the message is correctly in the buffer, the uIP protocol stack is called to send the message.
struct uip_udp_conn* ptp_event_conn |
uIP connection to send event messages.
struct uip_udp_conn* ptp_general_conn |
uIP connection to send general messages.