![]() |
RA Flexible Software Package Documentation
Release v6.2.0
|
|
Interface for PTP functions.
The PTP interface provides the functionality for using PTP.
Data Structures | |
| struct | ptp_clock_properties_t |
| struct | ptp_time_t |
| struct | ptp_callback_args_t |
| struct | ptp_pulse_timer_common_cfg_t |
| struct | ptp_pulse_timer_cfg_t |
| struct | ptp_sync_state_cfg_t |
| struct | ptp_synfp_cfg_t |
| struct | ptp_synfp_cfg_t.ether |
| struct | ptp_synfp_cfg_t.ipv4 |
| struct | ptp_stca_cfg_t |
| struct | ptp_cfg_t |
| struct | ptp_api_t |
| struct | ptp_instance_t |
Typedefs | |
| typedef enum PTP_PACKED e_ptp_ctrl_field | ptp_ctrl_field_t |
| typedef ptp_message_sync_t | ptp_message_delay_req_t |
| typedef ptp_message_sync_t | ptp_message_follow_up_t |
| typedef ptp_message_pdelay_resp_t | ptp_message_delay_resp_t |
| typedef ptp_message_delay_resp_t | ptp_message_pdelay_resp_follow_up_t |
Enumerations | |
| enum | ptp_message_type_t |
| enum | ptp_port_state_t |
| enum | ptp_clock_delay_mechanism_t |
| enum | ptp_frame_format_t |
| enum | ptp_frame_filter_mode_t |
| enum | ptp_stca_clock_freq_t |
| enum | ptp_stca_clock_sel_t |
| enum | ptp_message_interval_t |
| enum | ptp_clock_correction_mode_t |
| enum | ptp_event_t |
| enum | ptp_ethernet_phy_interface_t |
Variables | |
| enum PTP_PACKED | e_ptp_ctrl_field |
| struct ptp_clock_properties_t |
Clock properties used in the best master clock algorithm (BMCA) in order to determine the grandmaster clock.
In master mode, these properties will be advertised in announce messages.
Note: The final property used in BMCA is the clock ID. This is usually configured at runtime because it is often based on the hardware address.
| struct ptp_time_t |
| struct ptp_message_flags_t |
Flags field in PTP message header.
| struct ptp_message_header_t |
Commom PTP Message Header.
| Data Fields | ||
|---|---|---|
| uint8_t | message_type: 4 | The message type. |
| uint8_t | sdoid_major: 4 | Standard Organization ID Major. |
| uint8_t | version: 4 | PTP Version. |
| uint8_t | minor_version: 4 | PTP Minor Version. |
| uint16_t | message_length | The total message length (Including the header). |
| uint8_t | domain | The clock domain. |
| uint8_t | sdoid_minor: 8 | Standard Organization ID minor. |
| ptp_message_flags_t | flags | Flags set in the message. |
| uint64_t | correction_field | Correction Field that is updated when a message passes through a transparent clock. |
| uint32_t | reserved | |
| uint8_t | clock_id[8] | Clock ID that the message was sent from. |
| uint16_t | source_port_id | Port ID that the message was sent from. |
| uint16_t | sequence_id | Sequence ID of the message. |
| ptp_ctrl_field_t | control_field | Control field (Message specifc). |
| uint8_t | log_message_interval | Logbase2 of the message period. |
| struct ptp_message_sync_t |
Sync Message Type (0x00).
| Data Fields | ||
|---|---|---|
| ptp_time_t | origin_timestamp | Timestamp when the message was transmitted. |
| struct ptp_message_pdelay_req_t |
PDelay_req Message Type (0x02).
| Data Fields | ||
|---|---|---|
| ptp_time_t | origin_timestamp | Timestamp when the message was transmitted. |
| uint8_t | reserved[10] | |
| struct ptp_message_pdelay_resp_t |
PDelay_resp Message Type (0x03).
| Data Fields | ||
|---|---|---|
| ptp_time_t | origin_timestamp | Timestamp when the message was transmitted. |
| uint8_t | source_port_identity[10] | Clock ID + sourcePortId. |
| struct ptp_message_announce_t |
Announce Message Type (0x0B).
| Data Fields | ||
|---|---|---|
| ptp_time_t | origin_timestamp | Timestamp when the message was transmitted. |
| uint16_t | current_utc_offset | Offset from UTC in seconds. |
| uint8_t | reserved | |
| ptp_clock_properties_t | clock_properties | Clock properties used in Best Master Clock Algorithm. |
| uint8_t | clock_id[8] | Clock ID that the message was sent from. |
| uint16_t | steps_removed | The number of boundary clocks between the clock and the grand master clock. |
| uint8_t | time_source | The source of time (Eg. INTERNAL_OSC). |
| struct ptp_message_signaling_t |
| struct ptp_message_management_t |
Management Message Type (0x0D).
| struct ptp_message_t |
Complete PTP Message.
| Data Fields | ||
|---|---|---|
| ptp_message_header_t | header | Header of the message. |
| union ptp_message_t | __unnamed__ | |
| struct ptp_callback_args_t |
Arguments passed to p_ptp_callback.
| Data Fields | ||
|---|---|---|
| ptp_event_t | event | Event that caused the callback. |
| ptp_message_t const * | p_message | The message received (PTP message fields will be little endian). |
| uint8_t const * | p_tlv_data | Start of TLV data (TLV data will be big endian). |
| uint16_t | tlv_data_size | Total bytes of TLV data. |
| uint32_t | pulse_timer_channel | Channel of the pulse timer that caused ptp_event_t::PTP_EVENT_PULSE_TIMER_MINT_RISING_EDGE. |
| void * | p_context | Context value set in the configuration. |
| struct ptp_pulse_timer_common_cfg_t |
Structure for configuring the IPLS IRQ settings that are common to all pulse timer channels.
| struct ptp_pulse_timer_cfg_t |
Structure for configuring a pulse timer channel.
| Data Fields | ||
|---|---|---|
| ptp_time_t | start_time | The exact time when the timer will start. |
| uint32_t | period | The period of the timer in nanoseconds. |
| uint32_t | pulse | The pulse width of the timer in nanoseconds. |
| ptp_enable_t | mint_rising_irq | Enable MINT rising edge IRQ. |
| ptp_enable_t | ipls_rising_event | Enable IPLS rising edge ELC event. |
| ptp_enable_t | ipls_falling_event | Enable IPLS falling edge ELC event. |
| ptp_enable_t | ipls_rising_event_auto_clear | Enable IPLS rising edge ELC event. |
| ptp_enable_t | ipls_falling_event_auto_clear | Enable IPLS falling edge ELC event. |
| ptp_enable_t | ipls_irq_source | Enable using this channel as a source for the IPLS IRQ. |
| struct ptp_sync_state_cfg_t |
Configuration settings for determining when the PTP clock is synchronized.
| struct ptp_synfp_cfg_t |
Configuration settings for the SYNFP.
| Data Fields | ||
|---|---|---|
| ptp_ethernet_phy_interface_t | ethernet_phy_interface | The type of interface used to communicate with the PHY. |
| ptp_frame_format_t | frame_format | Frame format used to transport PTP messages. |
| ptp_frame_filter_mode_t | frame_filter | Frame filter mode. |
| uint8_t | clock_domain | Clock domain that the clock operates in. |
| ptp_enable_t | clock_domain_filter | Filter out messages from other clock domains. |
| ptp_message_interval_t | announce_interval | Interval for transmitting announce messages. |
| ptp_message_interval_t | sync_interval | Interval for transmitting sync messages. |
| ptp_message_interval_t | delay_req_interval | Interval for transmitting delay_req messages. |
| uint32_t | message_timeout | Timeout in milliseconds for receiving PTP messages. |
| ptp_clock_properties_t | clock_properties | Clock properties used in annonce messages. |
| uint8_t | timesource | TimeSource field used in announce messages. |
| uint8_t * | p_multicast_addr_filter | Filter for multicast packets. |
| struct ptp_synfp_cfg_t | ether |
Valid if frame_format is set to Ethernet II or IEEE 802.3. |
| struct ptp_synfp_cfg_t | ipv4 |
Valid if frame_format is set to IPV4_UDP. |
| struct ptp_synfp_cfg_t.ether |
| struct ptp_synfp_cfg_t.ipv4 |
Valid if frame_format is set to IPV4_UDP.
| struct ptp_stca_cfg_t |
Configuration settings for the STCA.
| Data Fields | ||
|---|---|---|
| ptp_stca_clock_freq_t | clock_freq | Select the clock frequency of the STCA. |
| ptp_stca_clock_sel_t | clock_sel | Select the input clock to the STCA. |
| ptp_clock_correction_mode_t | clock_correction_mode | Select the clock correction mode. |
| uint8_t | gradient_worst10_interval | Select the interval for the gradient worst10 acquisition. |
| ptp_sync_state_cfg_t | sync_threshold | Configure the synchronization threshold. |
| ptp_sync_state_cfg_t | sync_loss_threshold | Configure the SYnchronization lost threshold. |
| struct ptp_cfg_t |
User configuration structure, used in open function
Data Fields | |
| ptp_synfp_cfg_t | synfp |
| Configuration settings for the SYNFP. | |
| ptp_stca_cfg_t | stca |
| Configuration settings for the STCA. | |
| edmac_instance_t * | p_edmac_instance |
| Pointer to PTP edmac instance. | |
| uint16_t | buffer_size |
| The maximum Ethernet packet size that can be transmitted or received. | |
| uint8_t ** | p_rx_buffers |
| Pointer to list of buffers used to receive PTP packets. | |
| uint8_t ** | p_tx_buffers |
| Pointer to list of buffers used to transmit PTP packets. | |
| IRQn_Type | mint_irq |
| Interrupt number for PTP event IRQ. | |
| IRQn_Type | ipls_irq |
| Interrupt number for PTP timer IRQ. | |
| uint8_t | mint_ipl |
| Interrupt priority of the PTP event IRQ. | |
| uint8_t | ipls_ipl |
| Interrupt priority of the PTP timer IRQ. | |
| void(* | p_callback )(ptp_callback_args_t *p_args) |
| void(* ptp_cfg_t::p_callback) (ptp_callback_args_t *p_args) |
Callback for handling received PTP events.
| struct ptp_api_t |
Timer API structure. General timer functions implemented at the HAL layer follow this API.
Data Fields | |
| fsp_err_t(* | open )(ptp_ctrl_t *const p_ctrl, ptp_cfg_t const *const p_cfg) |
| fsp_err_t(* | macAddrSet )(ptp_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) |
| fsp_err_t(* | ipAddrSet )(ptp_ctrl_t *const p_ctrl, uint32_t ip_addr) |
| fsp_err_t(* | localClockIdSet )(ptp_ctrl_t *const p_ctrl, uint8_t const *const p_clock_id) |
| fsp_err_t(* | masterClockIdSet )(ptp_ctrl_t *const p_ctrl, uint8_t const *const p_clock_id, uint16_t port_id) |
| fsp_err_t(* | messageFlagsSet )(ptp_ctrl_t *const p_ctrl, ptp_message_type_t message_type, ptp_message_flags_t flags) |
| fsp_err_t(* | currentUtcOffsetSet )(ptp_ctrl_t *const p_ctrl, uint16_t offset) |
| fsp_err_t(* | portStateSet )(ptp_ctrl_t *const p_ctrl, uint32_t state) |
| fsp_err_t(* | messageSend )(ptp_ctrl_t *const p_ctrl, ptp_message_t const *const p_message, uint8_t const *const p_tlv_data, uint16_t tlv_data_size) |
| fsp_err_t(* | localClockValueSet )(ptp_ctrl_t *const p_ctrl, ptp_time_t const *const p_time) |
| fsp_err_t(* | localClockValueGet )(ptp_ctrl_t *const p_ctrl, ptp_time_t *const p_time) |
| fsp_err_t(* | pulseTimerCommonConfig )(ptp_ctrl_t *const p_ctrl, ptp_pulse_timer_common_cfg_t *p_timer_cfg) |
| fsp_err_t(* | pulseTimerEnable )(ptp_ctrl_t *const p_ctrl, uint32_t channel, ptp_pulse_timer_cfg_t *const p_timer_cfg) |
| fsp_err_t(* | pulseTimerDisable )(ptp_ctrl_t *const p_ctrl, uint32_t channel) |
| fsp_err_t(* | close )(ptp_ctrl_t *const p_ctrl) |
Initial configuration.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | p_cfg | Pointer to pin configuration structure. |
| fsp_err_t(* ptp_api_t::macAddrSet) (ptp_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr) |
Set the MAC address for the PTP.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | p_hw_addr | Pointer to the 6 byte MAC address. |
| fsp_err_t(* ptp_api_t::ipAddrSet) (ptp_ctrl_t *const p_ctrl, uint32_t ip_addr) |
Set the IP address for the PTP.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | ip_addr | 32 bit IPv4 address of the PTP. |
| fsp_err_t(* ptp_api_t::localClockIdSet) (ptp_ctrl_t *const p_ctrl, uint8_t const *const p_clock_id) |
Set the local clock ID (Usually based off of the PTP MAC address).
| [in] | p_ctrl | Pointer to control structure. |
| [in] | p_clock_id | Pointer to 8 byte clock ID. |
| fsp_err_t(* ptp_api_t::masterClockIdSet) (ptp_ctrl_t *const p_ctrl, uint8_t const *const p_clock_id, uint16_t port_id) |
Set the master clock ID (Usually obtained from previously received announce message).
| [in] | p_ctrl | Pointer to control structure. |
| [in] | p_clock_id | Pointer to 8 byte clock ID. |
| [in] | port_id | The port on the master clock. |
| fsp_err_t(* ptp_api_t::messageFlagsSet) (ptp_ctrl_t *const p_ctrl, ptp_message_type_t message_type, ptp_message_flags_t flags) |
Set the flags field for the given message type.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | message_type | The message type. |
| [in] | flags | Flags to set. |
| fsp_err_t(* ptp_api_t::currentUtcOffsetSet) (ptp_ctrl_t *const p_ctrl, uint16_t offset) |
Sets the offsetFromMaster field in announce messages.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | offset | New currentUtcOffset value. |
| fsp_err_t(* ptp_api_t::portStateSet) (ptp_ctrl_t *const p_ctrl, uint32_t state) |
Transition to a new clock state.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | state | The state to transition into. |
| fsp_err_t(* ptp_api_t::messageSend) (ptp_ctrl_t *const p_ctrl, ptp_message_t const *const p_message, uint8_t const *const p_tlv_data, uint16_t tlv_data_size) |
Send a PTP message. Appropriate fields in the PTP message will be endian swapped. The application must ensure that the TLV data is in big endian format.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | p_message | Pointer to a PTP message. |
| [in] | p_tlv_data | Pointer to TLV data that is appended to the end of the PTP message. |
| [in] | tlv_data_size | Size of the TLV data in bytes. |
| fsp_err_t(* ptp_api_t::localClockValueSet) (ptp_ctrl_t *const p_ctrl, ptp_time_t const *const p_time) |
Set the local clock value.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | p_time | Pointer to the new time setting. |
| fsp_err_t(* ptp_api_t::localClockValueGet) (ptp_ctrl_t *const p_ctrl, ptp_time_t *const p_time) |
Get the local clock value.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | p_time | Pointer to store the current time setting. |
| fsp_err_t(* ptp_api_t::pulseTimerCommonConfig) (ptp_ctrl_t *const p_ctrl, ptp_pulse_timer_common_cfg_t *p_timer_cfg) |
Configuration that is common to all of the pulse timers.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | p_timer_cfg | Pointer to the pulse timer common configuration. |
| fsp_err_t(* ptp_api_t::pulseTimerEnable) (ptp_ctrl_t *const p_ctrl, uint32_t channel, ptp_pulse_timer_cfg_t *const p_timer_cfg) |
Setup a pulse timer.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | channel | The pulse timer channel to setup. |
| [in] | p_timer_cfg | Pointer to the pulse timer configuration. |
| fsp_err_t(* ptp_api_t::pulseTimerDisable) (ptp_ctrl_t *const p_ctrl, uint32_t channel) |
Stop a pulse timer.
| [in] | p_ctrl | Pointer to control structure. |
| [in] | channel | The pulse timer channel to stop. |
| fsp_err_t(* ptp_api_t::close) (ptp_ctrl_t *const p_ctrl) |
Stop PTP operation.
| [in] | p_ctrl | Pointer to control structure. |
| struct ptp_instance_t |
This structure encompasses everything that is needed to use an instance of this interface.
| Data Fields | ||
|---|---|---|
| ptp_ctrl_t * | p_ctrl | Pointer to the control structure for this instance. |
| ptp_cfg_t const * | p_cfg | Pointer to the configuration structure for this instance. |
| ptp_api_t const * | p_api | Pointer to the API structure for this instance. |
| typedef enum PTP_PACKED e_ptp_ctrl_field ptp_ctrl_field_t |
The control field for PTP message header.
Delay_req Message Type (0x01).
Follow_up Message Type (0x08).
Delay_resp Message Type (0x09).
PDelay_resp_follow_up Message Type (0x0A).
| enum ptp_message_type_t |
Standard PTP message types.
| enum ptp_port_state_t |
Possible states that the PTP instance can be in.
| Enumerator | |
|---|---|
| PTP_PORT_STATE_GENERATE_ANNOUNCE | Generate Announce Messages. |
| PTP_PORT_STATE_GENERATE_SYNC | Generate Sync Messages. |
| PTP_PORT_STATE_GENERATE_DELAY_REQ | Generate Delay_req Messages. |
| PTP_PORT_STATE_GENERATE_PDELAY_REQ | Generate PDelay_req Messages. |
| PTP_PORT_STATE_RECEIVE_ANNOUNCE | Receive Announce Messages from ptp_cfg_t::p_callback. |
| PTP_PORT_STATE_RECEIVE_SYNC | Receive Sync Messages from ptp_cfg_t::p_callback. |
| PTP_PORT_STATE_RECEIVE_FOLLOW_UP | Receive Follow_up Messages from ptp_cfg_t::p_callback. |
| PTP_PORT_STATE_RECEIVE_DELAY_REQ | Receive Delay_req Messages from ptp_cfg_t::p_callback. |
| PTP_PORT_STATE_RECEIVE_DELAY_RESP | Receive Delay_resp Messages from ptp_cfg_t::p_callback. |
| PTP_PORT_STATE_RECEIVE_PDELAY_REQ | Receive PDelay_req Messages from ptp_cfg_t::p_callback. |
| PTP_PORT_STATE_RECEIVE_PDELAY_RESP | Receive PDelay_resp Messages from ptp_cfg_t::p_callback. |
| PTP_PORT_STATE_RECEIVE_PDELAY_RESP_FOLLOW_UP | Receive PDelay_resp_follow_up Messages from ptp_cfg_t::p_callback. |
| PTP_PORT_STATE_RECEIVE_MANAGEMENT | Receive Management Messages from ptp_cfg_t::p_callback. |
| PTP_PORT_STATE_RECEIVE_SIGNALING | Receive Signaling Messages from ptp_cfg_t::p_callback. |
| PTP_PORT_STATE_PROCESS_SYNC | Enable Sync Message processing. |
| PTP_PORT_STATE_PROCESS_FOLLOW_UP | Enable Follow_up Message processing. |
| PTP_PORT_STATE_PROCESS_DELAY_REQ | Enable Delay_req Message processing. |
| PTP_PORT_STATE_PROCESS_DELAY_RESP | Enable Delay_resp Message processing. |
| PTP_PORT_STATE_PROCESS_PDELAY_REQ | Enable PDelay_req Message processing. |
| PTP_PORT_STATE_PROCESS_PDELAY_RESP | Enable PDelay_resp Message processing. |
| PTP_PORT_STATE_PROCESS_PDELAY_RESP_FOLLOW_UP | Enable PDelay_resp_follow_up Message processing. |
| PTP_PORT_STATE_PASSIVE | Configure the PTP instance to only receive Announce, Management, and Signaling Messages. |
| PTP_PORT_STATE_E2E_MASTER | Configure the PTP instance to operate as a E2E Master. |
| PTP_PORT_STATE_E2E_SLAVE | Configure the PTP instance to operate as a E2E Slave. |
| PTP_PORT_STATE_P2P_MASTER | Configure the PTP instance to operate as a P2P Master. |
| PTP_PORT_STATE_P2P_SLAVE | Configure the PTP instance to operate as a P2P Slave. |
| PTP_PORT_STATE_RECEIVE_ALL | Configure the PTP instance to receive all messages. |
| PTP_PORT_STATE_DISABLE | Disable all PTP message generation, processing, and reception. |
| enum ptp_frame_format_t |
Frame formats that PTP messages can be encapsulated in.
Filter PTP messages based on destination MAC address. Messages that pass the filter will be transferred to the ETHERC EDMAC.
| enum ptp_stca_clock_sel_t |
STCA input clock selection.
Message interval for transmitting PTP messages.
| enum ptp_event_t |
PTP events provided by ptp_cfg_t::p_callback.
| enum PTP_PACKED e_ptp_ctrl_field |
The control field for PTP message header.