RA Flexible Software Package Documentation  Release v5.7.0

 
PTP (r_ptp)

Functions

fsp_err_t R_PTP_Open (ptp_ctrl_t *const p_ctrl, ptp_cfg_t const *const p_cfg)
 
fsp_err_t R_PTP_MacAddrSet (ptp_ctrl_t *const p_ctrl, uint8_t const *const p_mac_addr)
 
fsp_err_t R_PTP_IpAddrSet (ptp_ctrl_t *const p_ctrl, uint32_t ip_addr)
 
fsp_err_t R_PTP_LocalClockIdSet (ptp_ctrl_t *const p_ctrl, uint8_t const *const p_clock_id)
 
fsp_err_t R_PTP_MasterClockIdSet (ptp_ctrl_t *const p_ctrl, uint8_t const *const p_clock_id, uint16_t port_id)
 
fsp_err_t R_PTP_MessageFlagsSet (ptp_ctrl_t *const p_ctrl, ptp_message_type_t message_type, ptp_message_flags_t flags)
 
fsp_err_t R_PTP_CurrentUtcOffsetSet (ptp_ctrl_t *const p_ctrl, uint16_t offset)
 
fsp_err_t R_PTP_PortStateSet (ptp_ctrl_t *const p_ctrl, uint32_t state)
 
fsp_err_t R_PTP_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 R_PTP_LocalClockValueSet (ptp_ctrl_t *const p_ctrl, ptp_time_t const *const p_time)
 
fsp_err_t R_PTP_LocalClockValueGet (ptp_ctrl_t *const p_ctrl, ptp_time_t *const p_time)
 
fsp_err_t R_PTP_PulseTimerCommonConfig (ptp_ctrl_t *const p_ctrl, ptp_pulse_timer_common_cfg_t *const p_timer_cfg)
 
fsp_err_t R_PTP_PulseTimerEnable (ptp_ctrl_t *const p_ctrl, uint32_t channel, ptp_pulse_timer_cfg_t *const p_timer_cfg)
 
fsp_err_t R_PTP_PulseTimerDisable (ptp_ctrl_t *const p_ctrl, uint32_t channel)
 
fsp_err_t R_PTP_Close (ptp_ctrl_t *const p_ctrl)
 
fsp_err_t R_PTP_BestMasterClock (ptp_message_t const *const p_announce1, ptp_message_t const *const p_announce2, int8_t *const p_comparison)
 

Detailed Description

Driver for the PTP peripheral on RA MCUs. This module implements the PTP Interface.

Overview

PTP allows for multiple devices on a network to synchronize their clocks with very high precision. The PTP peripheral generates and processes PTP messages automatically. In slave mode, it also corrects the local time in order to adjust for any offset from the master clock time.

Features

Configuration

Build Time Configurations for r_ptp

The following build time configurations are defined in fsp_cfg/r_ptp_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.

Configurations for Networking > PTP (r_ptp)

This module can be added to the Stacks tab via New Stack > Networking > PTP (r_ptp).

ConfigurationOptionsDefaultDescription
Clock Properties
Priority 1Value must in the range [0,255].128 Priority1 field advertised in generated announce packets.
ClassValue must in the range [0,255].248 Class field advertised in generated announce packets.
AccuracyValue must in the range [0,255].0xFE Accuracy field advertised in generated announce packets.
VarianceValue must in the range [0,65535].0xFFFF Variance field advertised in generated announce packets.
Priority 2Value must in the range [0,255].128 Priority2 field advertised in generated announce packets.
Time SourceValue must in the range [0,255].160 Time Source field advertised in generated announce packets.
Ethernet
Multicast Filter MAC addressMust be a valid MAC address01:1B:19:00:00:00 In Multicast Filtered mode, only multicast addresses that match this address are received by the ETHERC EDMAC.
Primary Destination MAC addressMust be a valid MAC address01:1B:19:00:00:00 The destination MAC address for primary PTP messages.
PDelay Destination MAC addressMust be a valid MAC address01:80:C2:00:00:0E The destination MAC address for PDelay messages.
IP
Primary Destination IP addressMust be a valid IP address224.0.1.129 The destination IPv4 address for primary messages.
PDelay Destination IP addressMust be a valid IP address224.0.0.107 The destination IPv4 address for PDelay messages.
Event Message TOSValue must in the range [0,255].0 The IP packet TOS for event messages.
General Message TOSValue must in the range [0,255].0 The IP packet TOS for general messages.
Primary Message TTLValue must in the range [0,255].1 The IP packet TTL for primary messages.
PDelay Message TTLValue must in the range [0,255].1 The IP packet TTL for p_delay messages.
Event PortValue must in the range [0,65535].319 The UDP port for event messages.
General PortValue must in the range [0,65535].320 The UDP port for general messages.
Synchronization Detection
Threshold (Nanoseconds)Value must be greater than 0.1000000 The minimum offsetFromMaster value required in order to synchronize with the master clock.
CountValue must in the range [0,15].5 The number of times the calculated offsetFromMaster value must be less than the threshold in order to synchronize with the master clock.
Synchronization Lost Detection
Threshold (Nanoseconds)Value must be greater than 0.10000000 The minimum offsetFromMaster value required in order to lose synchronization with the master clock.
CountValue must in the range [0,15].5 The number of times the calculated offsetFromMaster value must be greater than the threshold in order to lose synchronization with the master.
Interrupts
CallbackName must be a valid C symbolptp0_user_callback Called when a STCA/SYNFP event occurs, a PTP message is received, or if a Pulse Timer event occurs.
MINT Interrupt priorityMCU Specific OptionsSelect the EPTPC MINT interrupt priority.
Pulse Timer Interrupt priorityMCU Specific OptionsSelect the EPTPC IPLS priority.
NameName must be a valid C symbolg_ptp0 Module name.
Ethernet PHY Interface Type
  • MII
  • RMII
RMII The interface type used to communicate with the Ethernet PHY.
Frame Filter
  • Extended Promiscuous Mode
  • Unicast and Multicast
  • Unicast and Multicast Filtered
  • Unicast
Unicast Selects how packets are filtered based on their destination MAC address. Packets that pass the filter are transferred to the ETHERC EDMAC.
Frame Format
  • Ethernet II
  • Ethernet II | IPv4 | UDP
  • IEEE802.3 | LLC | SNAP
  • IEEE802.3 | LLC | SNAP | IPv4 | UDP
Ethernet II The format of the frames that encapsulate the PTP messages.
Clock DomainValue must in the range [0,255].0 The PTP clock will only respond to clocks in its domain.
Clock Domain Filter
  • Enable
  • Disable
Enable Filter out PTP messages from other clock domains.
Buffer SizeValue must in the range [64,1536].1536 The maximum Ethernet packet size that can be transmitted or received by the application from the EDMAC.
Number of transmit buffersValue must in the range [1,16].4 The number of transmit buffers in the packet queue.
Number of receive buffersValue must in the range [1,16].4 The number of receive buffers in the packet queue.
Announce message interval.MCU Specific OptionsThe period of time between generated announce messages.
Sync message interval.MCU Specific OptionsThe period of time between generated sync messages.
Delay_req message interval.MCU Specific OptionsThe period of time between generated delay_req messages.
Message timeoutValue must be greater than 0.4000 The time in milliseconds needed to generate timeout events after not receiving a sync or delay_resp message.
Clock Source
  • PCLKA / 1
  • PCLKA / 2
  • PCLKA / 3
  • PCLKA / 4
  • PCLKA / 5
  • PCLKA / 6
  • REF50CK0
PCLKA / 6 The STCA clock source must be 20Mhz, 25Mhz, 50Mhz, or 100Mhz. When REF50CK0 is selected, the STCA frequency is 25Mhz.
Clock Correction Mode
  • Clock Correction Mode 1
  • Clock Correction Mode 2
Clock Correction Mode 1 Clock correction mode 1 corrects the local clock using the current offsetFromMaster value. Clock correction mode 2 calculates a clock gradient in order to continuously correct the local clock.
Gradient Worst10 IntervalValue must in the range [0,255].32 The number of sync messages to use when calculating the worst10 gradient values (Only applies to clock correction mode 2).

Clock Configuration

The STCA input clock can be the following clock sources:

The STCA input clock is restricted to the following frequencies:

When REF50CK0 is selected, the input clock frequency is 25 Mhz.

Pin Configuration

The PTP module requires the Ethernet (r_ether) instance in order to initialize the Ethernet PHY. This means that the ETHERC pins must be configured.

Usage Notes

PTP Port State

The current PTP port state determines which messages need to be generated and processed by the PTP peripheral. It is the application's responsibility to determine what the current state of the PTP port should be.

The following messages can be generated by the PTP peripheral:

The following messages can be processed by the PTP peripheral:

The application must receive the following messages in order to determine the current state of its PTP port:

The following messages can only be sent manually:

The PTP API defines the following states:

State Generated Messages Processed Messages Received Messages
Disabled N/A N/A N/A
Passive N/A N/A Announce, Signaling, Management
E2E/P2P Slave Delay_req/(PDelay_req, PDelay_resp) Sync, Follow_up, Delay_resp/(PDelay_req, PDelay_resp) Announce, Signaling, Management
E2E/P2P Master Announce, Sync, Delay_resp/(PDelay_req, PDelay_resp) delay_req/(PDelay_req, PDelay_resp) Announce, Signaling, Management

Pulse Timers

Pulse Timers are configurable timers used to generate interrupts and ELC events. Each pulse timer has a configurable start time, pulse, and period. At the start of each timer period, a rising edge occurs. After the pulse time has elapsed, a falling edge occurs. ELC events and IRQs can be generated on rising and/or falling edges for each Pulse Timer. There are two types of interrupts generated by each Pulse Timer; MINT and IPLS.

ELC Events

Pulse timers may be configured to generate the following ELC events:

Note
1. n = [0,5] corresponds to the channel of the pulse timer.

MINT Interrupts

MINT IRQs are only generated on the rising edge of a Pulse Timer channel. The callback will provide the channel number of the pulse timer that caused the interrupt.

IPLS Interrupts

Each Pulse Timer channel can be configured as a source for generating IPLS IRQs. All of the pulse timers that are selected as IPLS sources are OR'd together and rising and falling edge IRQs can be generated from the resulting signal. Below is an example of a resulting signal from two IPLS sources. Unlike MINT interrupts, IPLS interrupts do not provide any information about which Pulse Timer caused the IRQ because the IRQs from all the Pulse Timers are OR'd together.

r_ptp_pulse_timer_ipls.svg
IPLS IRQ Generation

Ethernet Frame Filter

The PTP driver can filter Ethernet frames that are received by Ethernet (r_ether). There are four different filtering modes:

Limitations

Developers should be aware of the following limitations when using the PTP:

Examples

Slave Mode

This is a basic example of minimal use of PTP in slave mode.

volatile bool g_first_announce_message_received = false;
volatile bool g_sync_acquired = false;
void slave_mode_basic_example (void)
{
/* The PTP Instance must be opened before R_ETHER is opened. */
fsp_err_t err = R_PTP_Open(&g_ptp_ctrl, &g_ptp_cfg);
assert(FSP_SUCCESS == err);
/* Configure the PTP MAC address. */
err = R_PTP_MacAddrSet(&g_ptp_ctrl, g_ptp_mac_address);
assert(FSP_SUCCESS == err);
/* Configure the PTP Local Clock ID (Usually generated from MAC address). */
err = R_PTP_LocalClockIdSet(&g_ptp_ctrl, g_ptp_clock_id);
assert(FSP_SUCCESS == err);
/* Open the r_ether_api instance. */
err = R_ETHER_Open(&g_ether_ctrl, &g_ether_cfg);
assert(FSP_SUCCESS == err);
/* Wait for the link to be established. */
do
{
err = R_ETHER_LinkProcess(&g_ether_ctrl);
} while (FSP_SUCCESS != err);
/* Set the PTP instance to passive state and listen for announce message. */
assert(FSP_SUCCESS == err);
/* Wait for the first announce message (This will provide the master clock ID). */
uint32_t timeout = EXAMPLE_TIMEOUT;
while (!g_first_announce_message_received && --timeout)
{
}
assert(0U != timeout);
/* When a master clock is found, change to the slave state to start synchronizing
* the local clock to the master clock. */
assert(FSP_SUCCESS == err);
/* Wait for local clock to be synchronized with the master clock. */
timeout = EXAMPLE_TIMEOUT;
while (!g_sync_acquired && --timeout)
{
}
assert(0U != timeout);
/* The local clock is now synchronized with the grand master clock. */
}
/* Callback called whenever a PTP event occurs. */
void g_ptp_slave_callback_example (ptp_callback_args_t * p_args)
{
switch (p_args->event)
{
{
/* The offsetFromMaster value is now within the configured threshold to be
* synchronized with the master clock.
*/
g_sync_acquired = true;
break;
}
{
static ptp_message_t g_current_master_announce_message;
switch (p_args->p_message->header.message_type)
{
{
int8_t comparison = 0;
if (!g_first_announce_message_received)
{
/* If this is the first announce packet, immediately switch to this master clock. */
comparison = 1;
g_first_announce_message_received = true;
}
else
{
/*
* Run the "Best Master Clock Algorithm" to determine if the clock defined in this announce
* packet is better than the current master clock.
*/
fsp_err_t err = R_PTP_BestMasterClock(&g_current_master_announce_message,
p_args->p_message,
&comparison);
assert(FSP_SUCCESS == err);
}
if (1 == comparison)
{
/* Save the message as the new master announce message. */
g_current_master_announce_message = *p_args->p_message;
/* Set the master clock ID and sourcePortID in the PTP instance so that it
* synchronizes with the new best master clock.
*/
fsp_err_t err = R_PTP_MasterClockIdSet(&g_ptp_ctrl,
g_current_master_announce_message.header.clock_id,
g_current_master_announce_message.header.source_port_id);
assert(FSP_SUCCESS == err);
}
break;
}
default:
{
break;
}
}
break;
}
default:
{
break;
}
}
}

Master Mode

This is a basic example of minimal use of PTP in master mode.

#define PTP_EXAMPLE_CURRENT_UTC_OFFSET (37)
void master_mode_basic_example (void)
{
/* The PTP Instance must be opened before R_ETHER is opened. */
fsp_err_t err = R_PTP_Open(&g_ptp_ctrl, &g_ptp_cfg);
assert(FSP_SUCCESS == err);
/* Configure the PTP MAC address. */
err = R_PTP_MacAddrSet(&g_ptp_ctrl, g_ptp_mac_address);
assert(FSP_SUCCESS == err);
/* Configure the PTP Local Clock ID (Usually generated from MAC address). */
err = R_PTP_LocalClockIdSet(&g_ptp_ctrl, g_ptp_clock_id);
assert(FSP_SUCCESS == err);
/* Get the current time from an external time source (Eg. RTC). */
ptp_time_t current_time;
get_current_time_example(&current_time);
/* Set the PTP local time to the current time. */
err = R_PTP_LocalClockValueSet(&g_ptp_ctrl, &current_time);
assert(FSP_SUCCESS == err);
/* Set the currentUtcOffset field in announce messages. */
err = R_PTP_CurrentUtcOffsetSet(&g_ptp_ctrl, PTP_EXAMPLE_CURRENT_UTC_OFFSET);
assert(FSP_SUCCESS == err);
/* Set message flags in announce messages to indicate that the current UTC offset is valid and that the PTP timescale is used. */
flags.value = 0;
flags.value_b.currentUtcOffsetValid = 1;
flags.value_b.ptpTimescale = 1;
assert(FSP_SUCCESS == err);
/* Open the r_ether_api instance. */
err = R_ETHER_Open(&g_ether_ctrl, &g_ether_cfg);
assert(FSP_SUCCESS == err);
/* Wait for the link to be established. */
do
{
err = R_ETHER_LinkProcess(&g_ether_ctrl);
} while (FSP_SUCCESS != err);
/* Set the PTP instance to passive state and listen for announce message. */
assert(FSP_SUCCESS == err);
/*
* The master clock is now operational and will automatically generate announce and sync messages
* as well as respond to delay_req messages.
*/
}

Send PTP Messages

This is a basic example of how to send PTP messages.

#define PTP_MANAGEMENT_ACTION_GET (0U)
#define PTP_TLV_TYPE_MANAGEMENT (1U)
#define PTP_TLV_MANAGEMENT_ID_CLOCK_DESCRIPTION (1U)
static uint32_t g_transmit_complete = 0U;
void send_message_example (void)
{
static ptp_message_t message;
static uint8_t p_tlv_data[6];
memset(&message, 0, sizeof(ptp_message_t));
/* Fill in the required fields for the message header (Note that appropriate fields will be endian swapped). */
message.header.version = 2;
/* The message length is the total number of bytes in the PTP message (Including the message header). */
message.header.message_length = (uint16_t) (sizeof(ptp_message_header_t) +
sizeof(p_tlv_data));
memcpy(message.header.clock_id, g_ptp_clock_id, sizeof(g_ptp_clock_id));
message.header.control_field = PTP_CTRL_FIELD_MANAGEMENT;
/* Fill in the required fields for the management message. */
memcpy(message.management.target_clock_id, g_target_clock_id, sizeof(g_target_clock_id));
message.management.target_port_id = 1;
message.management.starting_boundary_hops = 1;
message.management.boundary_hops = 1;
message.management.action = PTP_MANAGEMENT_ACTION_GET;
/*
* Fill in TLV data (Note that TLV data is big endian).
*
* Type (Management)
*/
p_tlv_data[0] = 0;
p_tlv_data[1] = PTP_TLV_TYPE_MANAGEMENT;
/* Length */
p_tlv_data[2] = 0;
p_tlv_data[3] = 2;
/* Management ID (Clock Description) */
p_tlv_data[4] = 0;
p_tlv_data[5] = PTP_TLV_MANAGEMENT_ID_CLOCK_DESCRIPTION;
/* Send the message. */
fsp_err_t err = R_PTP_MessageSend(&g_ptp_ctrl, &message, p_tlv_data, sizeof(p_tlv_data));
assert(FSP_SUCCESS == err);
uint32_t timeout = EXAMPLE_TIMEOUT;
while (0U == g_transmit_complete && --timeout)
{
}
}
/* Callback called whenever a PTP event occurs. */
void g_ptp_send_message_callback_example (ptp_callback_args_t * p_args)
{
switch (p_args->event)
{
{
g_transmit_complete = 1U;
break;
}
{
switch (p_args->p_message->header.message_type)
{
{
/* Handle the response message. */
break;
}
default:
{
break;
}
}
}
default:
{
break;
}
}
}

Data Structures

struct  ptp_instance_ctrl_t
 

Data Structure Documentation

◆ ptp_instance_ctrl_t

struct ptp_instance_ctrl_t

PTP instance control block.

Data Fields
uint32_t open Marks if the instance has been opened.
uint32_t tx_buffer_write_index Index into the descriptor list to write the next packet.
uint32_t tx_buffer_complete_index Index into the descriptor list of the last transmitted packet.
uint32_t rx_buffer_index Index into the descriptor of the last received packet.
uint32_t tslatr Keep track of whether tslatr was set.
ptp_cfg_t const * p_cfg Pointer to the configuration structure.

Function Documentation

◆ R_PTP_Open()

fsp_err_t R_PTP_Open ( ptp_ctrl_t *const  p_ctrl,
ptp_cfg_t const *const  p_cfg 
)

This function initializes PTP. Implements ptp_api_t::open.

This function performs the following tasks:

  • Performs parameter checking and processes error conditions.
  • Configures the peripheral registers acording to the configuration.
  • Initialize the control structure for use in other PTP Interface functions.
Return values
FSP_SUCCESSThe instance has been successfully configured.
FSP_ERR_ALREADY_OPENInstance was already initialized.
FSP_ERR_NOT_OPENThe EDMAC instance was not opened correctly.
FSP_ERR_ASSERTIONAn invalid argument was given in the configuration structure.

◆ R_PTP_MacAddrSet()

fsp_err_t R_PTP_MacAddrSet ( ptp_ctrl_t *const  p_ctrl,
uint8_t const *const  p_mac_addr 
)

This function sets the MAC address for the PTP instance. Implements ptp_api_t::macAddrSet.

Note
This function may only be called while the PTP instance is in ptp_port_state_t::PTP_PORT_STATE_DISABLE.
Return values
FSP_SUCCESSThe MAC address has been set.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL
FSP_ERR_INVALID_MODEThe instance is not in the correct state.

◆ R_PTP_IpAddrSet()

fsp_err_t R_PTP_IpAddrSet ( ptp_ctrl_t *const  p_ctrl,
uint32_t  ip_addr 
)

This function sets the IP address for the PTP instance. Implements ptp_api_t::ipAddrSet.

Note
This function may only be called while the PTP instance is in ptp_port_state_t::PTP_PORT_STATE_DISABLE.
Return values
FSP_SUCCESSThe IP address has been set.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL.
FSP_ERR_INVALID_MODEThe configured ptp_synfp_cfg_t::frame_format is not configured to use IP packets, or the instance is not in the correct state.

◆ R_PTP_LocalClockIdSet()

fsp_err_t R_PTP_LocalClockIdSet ( ptp_ctrl_t *const  p_ctrl,
uint8_t const *const  p_clock_id 
)

This function sets the local clock ID for the PTP instance. Implements ptp_api_t::localClockIdSet.

Note
This function may only be called while the PTP instance is in ptp_port_state_t::PTP_PORT_STATE_DISABLE.
Typically the clock ID is derived from the MAC address (E.g. {b1,b2,b3,0xFF,0xFE,b4,b5,b6}).
Return values
FSP_SUCCESSThe local clock ID has been set.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL
FSP_ERR_INVALID_MODEThe instance is not in the correct state.

◆ R_PTP_MasterClockIdSet()

fsp_err_t R_PTP_MasterClockIdSet ( ptp_ctrl_t *const  p_ctrl,
uint8_t const *const  p_clock_id,
uint16_t  port_id 
)

This function sets the master clock ID and port ID that the local clock will synchronize with. Implements ptp_api_t::masterClockIdSet.

Return values
FSP_SUCCESSThe master clock ID and port ID have been set.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL

◆ R_PTP_MessageFlagsSet()

fsp_err_t R_PTP_MessageFlagsSet ( ptp_ctrl_t *const  p_ctrl,
ptp_message_type_t  message_type,
ptp_message_flags_t  flags 
)

This function sets the flags field for the given message type. Implements ptp_api_t::messageFlagsSet.

Return values
FSP_SUCCESSThe master clock ID and port ID have been set.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL or invalid.

◆ R_PTP_CurrentUtcOffsetSet()

fsp_err_t R_PTP_CurrentUtcOffsetSet ( ptp_ctrl_t *const  p_ctrl,
uint16_t  offset 
)

This function sets the currentUtcOffset value in announce messages. ptp_api_t::currentUtcOffsetSet.

Return values
FSP_SUCCESSThe currentUtcOffset has been updated.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL or invalid.

◆ R_PTP_PortStateSet()

fsp_err_t R_PTP_PortStateSet ( ptp_ctrl_t *const  p_ctrl,
uint32_t  state 
)

This function changes the current state of the PTP instance. Implements ptp_api_t::portStateSet.

Return values
FSP_SUCCESSThe instance will transition to the new state.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL

◆ R_PTP_MessageSend()

fsp_err_t R_PTP_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 
)

This function sends a PTP message. ptp_api_t::messageSend.

Return values
FSP_SUCCESSThe packet has been written to the transmit descriptor.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL or invalid.
FSP_ERR_ETHER_ERROR_TRANSMIT_BUFFER_FULLThere is no space for the packet in the transmit queue.

◆ R_PTP_LocalClockValueSet()

fsp_err_t R_PTP_LocalClockValueSet ( ptp_ctrl_t *const  p_ctrl,
ptp_time_t const *const  p_time 
)

This function sets the local clock value. Implements ptp_api_t::localClockValueSet.

Return values
FSP_SUCCESSThe local clock value has been set.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL or invalid.

◆ R_PTP_LocalClockValueGet()

fsp_err_t R_PTP_LocalClockValueGet ( ptp_ctrl_t *const  p_ctrl,
ptp_time_t *const  p_time 
)

This function gets the local clock value. Implements ptp_api_t::localClockValueGet.

Return values
FSP_SUCCESSThe local clock value has been written in p_time.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL

◆ R_PTP_PulseTimerCommonConfig()

fsp_err_t R_PTP_PulseTimerCommonConfig ( ptp_ctrl_t *const  p_ctrl,
ptp_pulse_timer_common_cfg_t *const  p_timer_cfg 
)

This function configures IPLS IRQ settings that are common to all pulse timer channels. Implements ptp_api_t::pulseTimerCommonConfig.

Return values
FSP_SUCCESSThe pulse timer has been enabled.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL or invalid.

◆ R_PTP_PulseTimerEnable()

fsp_err_t R_PTP_PulseTimerEnable ( ptp_ctrl_t *const  p_ctrl,
uint32_t  channel,
ptp_pulse_timer_cfg_t *const  p_timer_cfg 
)

This function enables a pulse timer channel. Implements ptp_api_t::pulseTimerEnable.

Return values
FSP_SUCCESSThe pulse timer has been enabled.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL or invalid.
FSP_ERR_INVALID_ARGUMENTThe start time must be set to a value that is later than current time.

◆ R_PTP_PulseTimerDisable()

fsp_err_t R_PTP_PulseTimerDisable ( ptp_ctrl_t *const  p_ctrl,
uint32_t  channel 
)

This function disables a pulse timer channel. Implements ptp_api_t::pulseTimerDisable.

Return values
FSP_SUCCESSThe pulse timer has been disabled.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL or invalid.

◆ R_PTP_Close()

fsp_err_t R_PTP_Close ( ptp_ctrl_t *const  p_ctrl)

Disable the PTP instance. Implements ptp_api_t::close.

Return values
FSP_SUCCESSThe pulse timer has been disabled.
FSP_ERR_NOT_OPENThe instance has not been opened.
FSP_ERR_ASSERTIONAn argument was NULL or invalid.

◆ R_PTP_BestMasterClock()

fsp_err_t R_PTP_BestMasterClock ( ptp_message_t const *const  p_announce1,
ptp_message_t const *const  p_announce2,
int8_t *const  p_comparison 
)

This function compares two clocks to determine which one is the better master clock.

p_comparison:

  • Set to -1 if p_announce1 defines the best master clock.
  • Set to 1 if p_announce2 defines the best master clock.
  • Set to 0 if p_announce1 and p_announce2 define the same clock.
Return values
FSP_SUCCESSThe valid result has been written to p_use_announce_clock.
FSP_ERR_ASSERTIONAn argument was NULL.