RZ Flexible Software Package Documentation  Release v4.2.0

 
HSR/PRP Switch (r_hpsw)

Functions

fsp_err_t R_HPSW_Open (ether_switch_ctrl_t *const p_ctrl, ether_switch_cfg_t const *const p_cfg)
 
fsp_err_t R_HPSW_Close (ether_switch_ctrl_t *const p_ctrl)
 
fsp_err_t R_HPSW_EnableSet (ether_switch_ctrl_t *const p_ctrl, hpsw_cfg_t const *const p_cfg, bool enable)
 
fsp_err_t R_HPSW_StatusGet (ether_switch_ctrl_t *const p_ctrl, hpsw_status_t *const p_status)
 
fsp_err_t R_HPSW_CounterGet (ether_switch_ctrl_t *const p_ctrl, uint32_t port, hpsw_counter_t *const p_counter)
 
fsp_err_t R_HPSW_CounterClear (ether_switch_ctrl_t *const p_ctrl)
 
fsp_err_t R_HPSW_PtpDataGet (ether_switch_ctrl_t *const p_ctrl, hpsw_ptp_dataset_t *const p_dataset)
 

Detailed Description

Provides API for using Ethernet Switch. This module implements the Ethernet Switch Interface.

Overview

With the HSR/PRP Switch function, this LSI enables to build the network topology such as line type without external switching hub.

Features

Configuration

Build Time Configurations for r_hpsw

The following build time configurations are defined in fsp_cfg/r_hpsw_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 > HSR/PRP Switch (r_hpsw)

This module can be added to the Stacks tab via New Stack > Networking > HSR/PRP Switch (r_hpsw).

ConfigurationOptionsDefaultDescription
NameName must be a valid C symbolg_hpsw0 Module name.
Channel00 Select the HPSW module channel number.
Operating Profile
  • No profile
  • PRP
  • HSR
No profile Select the operating profile.

Usage Notes

Then use this modules, set to start the Adjustable Clock on the application.

Limitations

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

Examples

Basic Example

This is a basic example of minimal use of the HPSW in an application.

void hpsw_basic_example (void)
{
fsp_err_t err = FSP_SUCCESS;
hpsw_cfg_t hpsw_cfg = {0};
hpsw_counter_t hpsw_counter = {0};
hpsw_ptp_dataset_t hpsw_ptp_dataset = {0};
hpsw_status_t hpsw_status = {0};
// Configure Adjustable Clock
hpsw_cfg.clk_select = HPSW_CLOCK_PTP;
hpsw_cfg.time_val = 0x1;
// Configure PTP TC
hpsw_cfg.ptp_tc_profile = HPSW_PTP_TC_DEFAULT;
hpsw_cfg.ptp_tc_profile_val = 0x1;
hpsw_cfg.ptp_tc_default_data_1 = HPSW_EXAMPLE_TC_DEFAULT_DATA_1;
hpsw_cfg.ptp_tc_default_data_2 = HPSW_EXAMPLE_TC_DEFAULT_DATA_2;
hpsw_cfg.ptp_tc_clock_id_val = 0x1;
// Configure PTP OC
hpsw_cfg.ptp_oc_profile = HPSW_PTP_OC_DEFAULT;
hpsw_cfg.ptp_oc_dis_offset_correction = 0x1;
hpsw_cfg.ptp_oc_profile_val = 0x1;
hpsw_cfg.ptp_oc_default_data_1 = HPSW_EXAMPLE_OC_DEFAULT_DATA_1;
hpsw_cfg.ptp_oc_default_data_2 = HPSW_EXAMPLE_OC_DEFAULT_DATA_2;
hpsw_cfg.ptp_oc_clock_id_val = 0x1;
// Configure HSR/PRP
hpsw_cfg.mac1 = HPSW_EXAMPLE_MAC_1;
hpsw_cfg.mac2 = HPSW_EXAMPLE_MAC_2;
/* Open the hpsw instance with initial configuration. */
err = R_HPSW_Open(&g_hpsw0_ctrl, &g_hpsw0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* Enable HSR/PRP switch. */
err = R_HPSW_EnableSet(&g_hpsw0_ctrl, &hpsw_cfg, HPSW_EXAMPLE_ENABLE);
assert(FSP_SUCCESS == err);
/* Enable the transmission and reception of Ethernet frames. */
err = R_GMAC_B_Open(&g_ether0_ctrl, &g_ether0_cfg);
assert(FSP_SUCCESS == err);
/* Get port counter values. */
err = R_HPSW_CounterGet(&g_hpsw0_ctrl, HPSW_EXAMPLE_PORT, &hpsw_counter);
assert(FSP_SUCCESS == err);
/* Clear counter values. */
err = R_HPSW_CounterClear(&g_hpsw0_ctrl);
assert(FSP_SUCCESS == err);
/* Get current dataset. */
err = R_HPSW_PtpDataGet(&g_hpsw0_ctrl, &hpsw_ptp_dataset);
assert(FSP_SUCCESS == err);
/* Get port status. */
err = R_HPSW_StatusGet(&g_hpsw0_ctrl, &hpsw_status);
assert(FSP_SUCCESS == err);
/* Disable HSR/PRP switch. */
err = R_HPSW_EnableSet(&g_hpsw0_ctrl, &hpsw_cfg, HPSW_EXAMPLE_DISABLE);
assert(FSP_SUCCESS == err);
/* Close the hpsw instance. */
err = R_HPSW_Close(&g_hpsw0_ctrl);
assert(FSP_SUCCESS == err);
}

Classes

struct  st_hpsw_cfg
 
struct  st_hpsw_status
 
struct  st_hpsw_counter
 
struct  st_hpsw_ptp_dataset
 
struct  st_hpsw_extend_cfg
 
struct  st_hpsw_instance_ctrl
 

Typedefs

typedef struct st_hpsw_cfg hpsw_cfg_t
 
typedef struct st_hpsw_status hpsw_status_t
 
typedef struct st_hpsw_counter hpsw_counter_t
 
typedef struct st_hpsw_ptp_dataset hpsw_ptp_dataset_t
 
typedef struct st_hpsw_extend_cfg hpsw_extend_cfg_t
 
typedef struct st_hpsw_instance_ctrl hpsw_instance_ctrl_t
 

Enumerations

enum  hpsw_c_clock_t
 
enum  hpsw_port_timeout_t
 
enum  hpsw_port_link_t
 
enum  hpsw_clock_select_t
 
enum  hpsw_mode_t
 
enum  hpsw_ptp_tc_profile_t
 
enum  hpsw_ptp_tc_layer_t
 
enum  hpsw_ptp_tc_delay_mechanism_t
 
enum  hpsw_ptp_tc_delay_e2e_uni_t
 
enum  hpsw_ptp_oc_profile_t
 
enum  hpsw_ptp_oc_layer_t
 
enum  hpsw_ptp_oc_master_slave_only_t
 
enum  hpsw_ptp_oc_delay_mechanism_t
 
enum  hpsw_ptp_oc_delay_e2e_uni_t
 

Class Documentation

◆ RZT::st_hpsw_cfg

struct RZT::st_hpsw_cfg

HPSW configuration data for loading into registers by R_HPSW_Enable()

Class Members
uint32_t time_val Time Adjustment Valid.
uint32_t offset_val Offset Adjustment Valid.
uint32_t drift_val Drift Adjustment Valid.
uint32_t servo_val Servo Parameters Valid.
hpsw_clock_select_t clk_select Source for Clock Adjustments.
uint32_t clock_time_adj_value_H Clock time adjustment value (High)
uint32_t clock_time_adj_value_L Clock time adjustment value (Low)
hpsw_ptp_tc_profile_t ptp_tc_profile Profile.
uint32_t ptp_tc_twostep Twostep for PDelay.
hpsw_ptp_tc_layer_t ptp_tc_layer Layer.
hpsw_ptp_tc_delay_mechanism_t ptp_tc_delay_mechanism Delay Mechanism.
hpsw_ptp_tc_delay_e2e_uni_t ptp_tc_delay_E2E_uni Delay E2E uni-cast.
uint32_t ptp_tc_profile_val Profile valid.
uint32_t ptp_tc_vlan_val VLAN valid.
uint32_t ptp_tc_ip_val IP valid.
uint32_t ptp_tc_dscp_val DSCP valid.
uint32_t ptp_tc_clock_id_val Clock Identity Valid.
uint32_t ptp_tc_domain_num_val Domain Number Valid.
uint32_t ptp_tc_default_data_1 Default data 1.
uint32_t ptp_tc_default_data_2 Default data 2.
hpsw_ptp_oc_profile_t ptp_oc_profile Profile.
uint32_t ptp_oc_twostep Twostep for PDelay.
uint32_t ptp_oc_signaling Signaling.
hpsw_ptp_oc_layer_t ptp_oc_layer Layer.
hpsw_ptp_oc_master_slave_only_t ptp_oc_master_slave Master or slave select.
uint32_t ptp_oc_dis_offset_correction Disable offset correction.
uint32_t ptp_oc_allow_uni_slave Only allow uni-cast slaves previously added to the uni-cast dataset.
hpsw_ptp_oc_delay_mechanism_t ptp_oc_delay_mechanism Delay Mechanism.
hpsw_ptp_oc_delay_e2e_uni_t ptp_oc_delay_E2E_uni Delay E2E uni-cast.
uint32_t ptp_oc_profile_val Profile valid.
uint32_t ptp_oc_vlan_val VLAN valid.
uint32_t ptp_oc_ip_val IP valid.
uint32_t ptp_oc_dscp_val DSCP valid.
uint32_t ptp_oc_clock_id_val Clock ID valid.
uint32_t ptp_oc_domain_num_val Domain number valid.
uint32_t ptp_oc_clock_qualiry_val Clock quality valid.
uint32_t ptp_oc_priority1_val Priority1 valid.
uint32_t ptp_oc_priority2_val Priority2 valid.
uint32_t ptp_oc_gm_id_val Grand master short ID valid.
uint32_t ptp_oc_gm_time_inac_val Grand master time Inaccuracy valid.
uint32_t ptp_oc_max_steps_rem_val Max steps removed valid.
uint32_t ptp_oc_local_priority_val Local priority valid.
uint32_t ptp_oc_default_data_1 Default data 1.
uint32_t ptp_oc_default_data_2 Default data 2.
uint8_t ptp_oc_priority1 Priority1.
uint8_t ptp_oc_priority2 Priority2.
uint32_t delay_mechanism_val Delay mechanism valid.
uint32_t msg_interval_val Message intervals valid.
uint32_t asymmetry_val Asymmetry valid.
uint32_t max_pdelay_val Maximum peer delay valid.
uint32_t local_priority_val Local priority valid.
uint32_t ptp_oc_announce_interval Signed announce log interval.
uint32_t ptp_oc_announce_timeout Announce timeout.
uint32_t vlan_val Vlan valid.
uint32_t vlan Vlan.
uint32_t vlan_enable Enable vlan.
uint32_t mac1 MAC 1.
uint32_t mac2 MAC 2.

◆ RZT::st_hpsw_status

struct RZT::st_hpsw_status

HPSW port status

Class Members
hpsw_port_timeout_t timeout_port_A Port A timeout.
hpsw_port_timeout_t timeout_port_B Port B timeout.
hpsw_port_link_t link_port_A Port A link status.
hpsw_port_link_t link_port_B Port B link status.
hpsw_port_link_t link_port_C Port C link status.

◆ RZT::st_hpsw_counter

struct RZT::st_hpsw_counter

HPSW send/receive frame counter

Class Members
uint32_t TX_counter TX counter.
uint32_t TX_error_counter TX error counter.
uint32_t RX_counter RX counter.
uint32_t RX_error_counter RX error counter.

◆ RZT::st_hpsw_ptp_dataset

struct RZT::st_hpsw_ptp_dataset

HPSW data set

Class Members
uint32_t ptp_tc_default_data_1 Default data 1.
uint32_t ptp_tc_default_data_2 Default data 2.
uint32_t ptp_tc_default_data_3 Default data 3.
uint32_t ptp_tc_default_data_4 Default data 4.
uint32_t ptp_tc_port_data_1 Port data 1.
uint32_t ptp_tc_port_data_2 Port data 2.
uint32_t ptp_tc_port_data_3 Port data 3.
uint32_t ptp_tc_port_data_4 Port data 4.
uint32_t ptp_tc_port_data_5 Port data 5.
uint32_t ptp_tc_port_data_6 Port data 6.
uint32_t ptp_oc_default_data_1 Default data 1.
uint32_t ptp_oc_default_data_2 Default data 2.
uint32_t ptp_oc_default_data_3 Default data 3.
uint32_t ptp_oc_default_data_4 Default data 4.
uint32_t ptp_oc_default_data_5 Default data 5.
uint32_t ptp_oc_default_data_6 Default data 6.
uint32_t ptp_oc_default_data_7 Default data 7.
uint32_t ptp_oc_port_data_1 Port data 1.
uint32_t ptp_oc_port_data_2 Port data 2.
uint32_t ptp_oc_port_data_3 Port data 3.
uint32_t ptp_oc_port_data_4 Port data 4.
uint32_t ptp_oc_port_data_5 Port data 5.
uint32_t ptp_oc_port_data_6 Port data 6.
uint32_t ptp_oc_port_data_7 Port data 7.
uint32_t ptp_oc_port_data_8 Port data 8.
uint32_t ptp_oc_current_data_1 Current data 1.
uint32_t ptp_oc_current_data_2 Current data 2.
uint32_t ptp_oc_current_data_3 Current data 3.
uint32_t ptp_oc_current_data_4 Current data 4.
uint32_t ptp_oc_current_data_5 Current data 5.
uint32_t ptp_oc_parent_data_1 Parent data 1.
uint32_t ptp_oc_parent_data_2 Parent data 2.
uint32_t ptp_oc_parent_data_3 Parent data 3.
uint32_t ptp_oc_parent_data_4 Parent data 4.
uint32_t ptp_oc_parent_data_5 Parent data 5.
uint32_t ptp_oc_parent_data_6 Parent data 6.
uint32_t ptp_oc_parent_data_7 Parent data 7.
uint32_t ptp_oc_parent_data_8 Parent data 8.
uint32_t ptp_oc_parent_data_9 Parent data 9.
uint32_t ptp_oc_time_propertie_data_1 Time properties data 1.
uint32_t ptp_oc_time_propertie_data_2 Time properties data 2.
uint32_t ptp_oc_time_propertie_data_3 Time properties data 3.
uint32_t ptp_oc_time_propertie_data_4 Time properties data 4.
uint32_t ptp_oc_time_propertie_data_5 Time properties data 5.
uint32_t ptp_oc_time_propertie_data_6 Time properties data 6.
uint32_t ptp_oc_time_propertie_data_7 Time properties data 7.
uint32_t ptp_oc_time_propertie_data_8 Time properties data 8.
uint32_t ptp_oc_time_propertie_data_9 Time properties data 9.

◆ RZT::st_hpsw_extend_cfg

struct RZT::st_hpsw_extend_cfg

Extend Configuration parameters.

Class Members
hpsw_mode_t mode HPSW Operating Profile.

◆ RZT::st_hpsw_instance_ctrl

struct RZT::st_hpsw_instance_ctrl

HPSW control block. DO NOT INITIALIZE. Initialization occurs when hpsw_instance_ctrl_t::open is called.

Class Members
uint32_t open Used to determine if the channel is configured.
ether_switch_cfg_t const * p_hpsw_cfg Pointer to initial configurations.
R_HPSW_INI_Type * p_hpsw_ini_reg Pointer to HPSW init registers.
R_HPSW_Type * p_hpsw_reg Pointer to HPSW registers.

Typedef Documentation

◆ hpsw_cfg_t

typedef struct st_hpsw_cfg hpsw_cfg_t

HPSW configuration data for loading into registers by R_HPSW_Enable() Please refer to the struct st_hpsw_cfg.

◆ hpsw_status_t

typedef struct st_hpsw_status hpsw_status_t

HPSW port status Please refer to the struct st_hpsw_status.

◆ hpsw_counter_t

HPSW send/receive frame counter Please refer to the struct st_hpsw_counter.

◆ hpsw_ptp_dataset_t

HPSW data set Please refer to the struct st_hpsw_ptp_dataset.

◆ hpsw_extend_cfg_t

Extend Configuration parameters. Please refer to the struct st_hpsw_extend_cfg.

◆ hpsw_instance_ctrl_t

HPSW control block. DO NOT INITIALIZE. Initialization occurs when hpsw_instance_ctrl_t::open is called. Please refer to the struct st_hpsw_instance_ctrl.

Enumeration Type Documentation

◆ hpsw_c_clock_t

C clock select

Enumerator
HPSW_c_clock_0_MBPS 

0

HPSW_c_clock_10_MBPS 

10Mbit/s(2.5MHz)

HPSW_c_clock_100_MBPS 

100Mbit/s(25MHz)

HPSW_c_clock_1000_MBPS 

1000Mbit/s(125MHz)

◆ hpsw_port_timeout_t

port timeout

Enumerator
HPSW_PORT_NOT_TIMEOUT 

Not port timeout occured.

HPSW_PORT_TIMEOUT 

Port timeout occured.

◆ hpsw_port_link_t

port link

Enumerator
HPSW_PORT_UNLINK 

Port unlink.

HPSW_PORT_LINK 

Port link.

◆ hpsw_clock_select_t

clock select

Enumerator
HPSW_CLOCK_NONE 

NONE.

HPSW_CLOCK_TOD 

TOD.

HPSW_CLOCK_LRIG 

LRIG.

HPSW_CLOCK_PPS 

PPS.

HPSW_CLOCK_PTP 

PTP.

HPSW_CLOCK_RTC 

RTC.

HPSW_CLOCK_DCF 

DCF.

HPSW_CLOCK_NTP 

NTP.

HPSW_CLOCK_REGS 

REGS.

HPSW_CLOCK_EXT 

EXT.

◆ hpsw_mode_t

mode select

Enumerator
HPSW_MODE_NONE 

None.

HPSW_MODE_PRP 

PRP.

HPSW_MODE_HSR 

HSR.

◆ hpsw_ptp_tc_profile_t

ptp tc profile

Enumerator
HPSW_PTP_TC_DEFAULT 

Default profile.

HPSW_PTP_TC_ELECTRIC 

Electric power profile.

HPSW_PTP_TC_UTILITY 

Utility profile.

HPSW_PTP_TC_TSN 

TSN Profile.

◆ hpsw_ptp_tc_layer_t

ptp tc layer

Enumerator
HPSW_PTP_TC_LAYER_802 

802.3

HPSW_PTP_TC_LAYER_IPv4 

IPv4.

◆ hpsw_ptp_tc_delay_mechanism_t

ptp tc delay mechanism

Enumerator
HPSW_PTP_TC_DELAY_P2P 

P2P.

HPSW_PTP_TC_DELAY_E2E 

E2E.

◆ hpsw_ptp_tc_delay_e2e_uni_t

ptp tc E2E unicast or multicast

Enumerator
HPSW_PTP_TC_DELAY_E2E_MULTI 

Muliticast.

HPSW_PTP_TC_DELAY_E2E_UNI 

Unicast.

◆ hpsw_ptp_oc_profile_t

ptp oc profile

Enumerator
HPSW_PTP_OC_DEFAULT 

Default profile.

HPSW_PTP_OC_ELECTRIC 

Electric power profile.

HPSW_PTP_OC_UTILITY 

Utility profile.

HPSW_PTP_OC_TSN 

TSN Profile.

HPSW_PTP_OC_ITU_G8265_1 

ITU G8265.1 Profile.

HPSW_PTP_OC_ITU_G8275_1 

ITU G8275.1 Profile.

HPSW_PTP_OC_ITU_G8275_2 

ITU G8275.2 Profile.

◆ hpsw_ptp_oc_layer_t

ptp oc layer

Enumerator
HPSW_PTP_OC_LAYER_802 

802.3

HPSW_PTP_OC_LAYER_IPv4 

IPv4.

HPSW_PTP_OC_LAYER_IPv6 

IPv6.

◆ hpsw_ptp_oc_master_slave_only_t

ptp oc master or slave select

Enumerator
HPSW_PTP_OC_MASTER_SLAVE 

Master and slave.

HPSW_PTP_OC_SLAVE 

Slave only.

HPSW_PTP_OC_MASTER 

Master only.

◆ hpsw_ptp_oc_delay_mechanism_t

ptp oc delay mechanism

Enumerator
HPSW_PTP_OC_DELAY_P2P 

P2P.

HPSW_PTP_OC_DELAY_E2E 

E2E.

◆ hpsw_ptp_oc_delay_e2e_uni_t

ptp oc E2E unicast or multicast

Enumerator
HPSW_PTP_OC_DELAY_E2E_MULTI 

Muliticast.

HPSW_PTP_OC_DELAY_E2E_UNI 

Unicast.

Function Documentation

◆ R_HPSW_Open()

fsp_err_t R_HPSW_Open ( ether_switch_ctrl_t *const  p_ctrl,
ether_switch_cfg_t const *const  p_cfg 
)

Initializes the HPSW module instance. Implements ether_switch_api_t::open.

Return values
FSP_SUCCESSHPSW configuration set successfully.
FSP_ERR_ASSERTIONPointer to HPSW control block or configuration structure is NULL.
FSP_ERR_ALREADY_OPENR_HPSW_Open has already been called for this p_ctrl.

◆ R_HPSW_Close()

fsp_err_t R_HPSW_Close ( ether_switch_ctrl_t *const  p_ctrl)

Close driver data. Implements ether_switch_api_t::close.

Return values
FSP_SUCCESSHPSW closed.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENThe instance control structure is not opened.

◆ R_HPSW_EnableSet()

fsp_err_t R_HPSW_EnableSet ( ether_switch_ctrl_t *const  p_ctrl,
hpsw_cfg_t const *const  p_cfg,
bool  enable 
)

Set the converter speed and duplex after initilaize. Speed 1000Mbps is valid for only RGMII.

Return values
FSP_SUCCESSSpeed adn duplex seetings successfully changed.
FSP_ERR_ASSERTIONp_ctrl was NULL.
FSP_ERR_NOT_OPENThe instance control structure is not opened.

◆ R_HPSW_StatusGet()

fsp_err_t R_HPSW_StatusGet ( ether_switch_ctrl_t *const  p_ctrl,
hpsw_status_t *const  p_status 
)

Retrieves the current state and counter value stores them in p_status.

Return values
FSP_SUCCESSCurrent status and counter value provided in p_status.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe instance control structure is not opened.

◆ R_HPSW_CounterGet()

fsp_err_t R_HPSW_CounterGet ( ether_switch_ctrl_t *const  p_ctrl,
uint32_t  port,
hpsw_counter_t *const  p_counter 
)

Retrieves the current state and counter value stores them in p_status.

Return values
FSP_SUCCESSCurrent status and counter value provided in p_status.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe instance control structure is not opened.

◆ R_HPSW_CounterClear()

fsp_err_t R_HPSW_CounterClear ( ether_switch_ctrl_t *const  p_ctrl)

Retrieves the current state and counter value stores them in p_status.

Return values
FSP_SUCCESSCurrent status and counter value provided in p_status.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe instance control structure is not opened.

◆ R_HPSW_PtpDataGet()

fsp_err_t R_HPSW_PtpDataGet ( ether_switch_ctrl_t *const  p_ctrl,
hpsw_ptp_dataset_t *const  p_dataset 
)

Retrieves the current state and counter value stores them in p_status.

Return values
FSP_SUCCESSCurrent status and counter value provided in p_status.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe instance control structure is not opened.
FSP_ERR_TIMEOUTRead data set wait timeout.