HPM SDK
HPMicro Software Development Kit
hpm_enet_drv.h File Reference
#include "hpm_common.h"
#include "hpm_enet_regs.h"
#include "hpm_soc_feature.h"
#include "hpm_enet_soc_drv.h"

Go to the source code of this file.

Data Structures

struct  enet_buff_config_t
 enet buffer config struct More...
 
struct  enet_mac_config_t
 enet mac config struct More...
 
struct  enet_tx_desc_t
 transmission descriptor struct More...
 
struct  enet_rx_desc_t
 reception descriptor struct More...
 
struct  enet_frame_t
 enet frame struct More...
 
struct  enet_rx_frame_info_t
 enet reception frame info struct More...
 
struct  enet_tx_control_config_t
 enet control config struct for transmission More...
 
struct  enet_desc_t
 enet description struct More...
 
struct  enet_ptp_ts_system_t
 PTP system timestamp struct. More...
 
struct  enet_ptp_ts_update_t
 PTP update timestamp struct. More...
 
struct  enet_ptp_ts_target_t
 PTP target timestamp struct. More...
 
struct  enet_ptp_config_t
 PTP config strcut. More...
 
struct  enet_pps_cmd_config_t
 PTP PPS command output config strcut. More...
 
struct  enet_ptp_ts_auxi_snapshot_t
 PTP auxiliary timestamp struct. More...
 
struct  enet_ptp_auxi_snapshot_status_t
 PTP auxiliary snapshot status struct. More...
 
struct  enet_int_config_t
 Enet interrupt config struct. More...
 

Macros

#define ENET_HEADER   (14U)
 
#define ENET_VLAN_TAG   (4U)
 
#define ENET_CRC   (4U)
 
#define ENET_MIN_PAYLOAD   (46U)
 
#define ENET_MAX_PAYLOAD   (1500U)
 
#define ENET_MAX_FRAME_SIZE   (1526U)
 
#define ENET_JUMBO_FRAME_PAYLOAD   (9000U)
 
#define ENET_MAC   (6)
 
#define ENET_ERROR   (0)
 
#define ENET_SUCCESS   (1)
 
#define ENET_ADJ_FREQ_BASE_ADDEND   (0x80000000UL)
 
#define ENET_ONE_SEC_IN_NANOSEC   (1000000000UL)
 
#define ENET_PPS_CMD_MASK   (0x07UL)
 
#define ENET_PPS_CMD_OFS_FAC   (3U)
 
#define ENET_RETRY_CNT   (10000UL)
 
#define ENET_RETRY_DMA_INIT_CNT   (10000000UL)
 
#define ENET_MAX_BUFF_SIZE   ((ENET_MAX_FRAME_SIZE + (ENET_SOC_DMA_BUS_WIDTH_IN_BYTES - 1)) & ~(ENET_SOC_DMA_BUS_WIDTH_IN_BYTES - 1))
 
#define ENET_DMATxDesc_TBS2   ((uint32_t)0x1FFF0000)
 
#define ENET_DMATxDesc_TBS1   ((uint32_t)0x00001FFF)
 

Enumerations

enum  enet_interrupt_enable_t { enet_normal_int_sum_en = ENET_DMA_INTR_EN_NIE_MASK , enet_aboarmal_int_sum_en = ENET_DMA_INTR_EN_AIE_MASK , enet_receive_int_en = ENET_DMA_INTR_EN_RIE_MASK , enet_transmit_int_en = ENET_DMA_INTR_EN_TIE_MASK }
 interrupt enable type More...
 
enum  enet_interrupt_mask_t { enet_lpi_int_mask = ENET_INTR_MASK_LPIIM_MASK , enet_rgsmii_int_mask = ENET_INTR_MASK_RGSMIIIM_MASK }
 interrupt mask type More...
 
enum  enet_pbl_t {
  enet_pbl_1 = 1 , enet_pbl_2 = 2 , enet_pbl_4 = 4 , enet_pbl_8 = 8 ,
  enet_pbl_16 = 16 , enet_pbl_32 = 32
}
 Programmable burst length selections. More...
 
enum  enet_cic_insertion_control_t { enet_cic_disable = 0 , enet_cic_ip = 1 , enet_cic_ip_no_pseudoheader = 2 , enet_cic_ip_pseudoheader = 3 }
 Checksum insertion control selections. More...
 
enum  enet_vlan_insertion_control_t { enet_vlic_disable = 0 , enet_vlic_remove_vlan_tag = 1 , enet_vlic_insert_vlan_tag = 2 , enet_vlic_replace_vlan_tag = 3 }
 VLAN insertion control selections. More...
 
enum  enet_saic_insertion_replacement_control_t {
  enet_saic_disable = 0 , enet_saic_insert_mac0 = 1 , enet_saic_replace_mac0 = 2 , enet_saic_insert_mac1 = 5 ,
  enet_saic_replace_mac1 = 6
}
 SA insertion or replacement control selections for any selective frames. More...
 
enum  enet_sarc_insertion_replacement_control_t {
  enet_sarc_disable = 0 , enet_sarc_insert_mac0 = 2 , enet_sarc_replace_mac0 = 3 , enet_sarc_insert_mac1 = 6 ,
  enet_sarc_replace_mac1 = 7
}
 SA insertion or replacement control selections for all transmit frames. More...
 
enum  enet_phy_op_t { enet_phy_op_read = 0 , enet_phy_op_write }
 PHY operation selections. More...
 
enum  enet_gmii_status_t { enet_gmii_idle = 0 , enet_gmii_busy }
 PHY status. More...
 
enum  enet_csr_clk_range_t {
  enet_csr_60m_to_100m_mdc_csr_div_42 = 0 , enet_csr_100m_to_150m_mdc_csr_div_62 , enet_csr_20m_to_35m_mdc_csr_div_16 , enet_csr_35m_to_60m_mdc_csr_div_26 ,
  enet_csr_150m_to_250m_mdc_csr_div_102 , enet_csr_250m_to_300m_mdc_csr_div_124 , enet_csr_60m_to_100m_mdc_csr_div_4 = 8 , enet_csr_60m_to_100m_mdc_csr_div_6 ,
  enet_csr_60m_to_100m_mdc_csr_div_8 , enet_csr_60m_to_100m_mdc_csr_div_10 , enet_csr_60m_to_100m_mdc_csr_div_12 , enet_csr_60m_to_100m_mdc_csr_div_14 ,
  enet_csr_60m_to_100m_mdc_csr_div_16 , enet_csr_60m_to_100m_mdc_csr_div_18
}
 CSR clock range and MDC clock selections. More...
 
enum  enet_inf_type_t { enet_inf_mii = 0 , enet_inf_rmii = 4 , enet_inf_rgmii = 1 }
 enet interface selections More...
 
enum  enet_line_speed_t { enet_line_speed_1000mbps = 0 , enet_line_speed_10mbps = 2 , enet_line_speed_100mbps = 3 }
 enet line speed More...
 
enum  enet_duplex_mode_t { enet_half_duplex = 0 , enet_full_duplex }
 enet duplex mode More...
 
enum  enet_ptp_time_update_method_t { enet_ptp_time_coarse_update = 0 , enet_ptp_time_fine_update }
 enet timestamp update methods More...
 
enum  enet_ptp_version_t { enet_ptp_v1 = 0 , enet_ptp_v2 }
 PTP versions. More...
 
enum  enet_ptp_frame_type_t { enet_ptp_frame_ipv4 = 0 , enet_ptp_frame_ipv6 , enet_ptp_frame_ethernet }
 PTP frame types. More...
 
enum  enet_ts_ss_ptp_msg_t {
  enet_ts_ss_ptp_msg_0 = 0 , enet_ts_ss_ptp_msg_1 = 1 , enet_ts_ss_ptp_msg_2 = 3 , enet_ts_ss_ptp_msg_3 = 4 ,
  enet_ts_ss_ptp_msg_4 = 5 , enet_ts_ss_ptp_msg_5 = 7 , enet_ts_ss_ptp_msg_6 = 8 , enet_ts_ss_ptp_msg_7 = 12
}
 PTP message type for snapshots. More...
 
enum  enet_ts_rollover_control_t { enet_ts_bin_rollover_control = 0 , enet_ts_dig_rollover_control }
 PTP timer rollover modes. More...
 
enum  enet_pps_idx_t { enet_pps_0 = -1 , enet_pps_1 = 0 , enet_pps_2 = 1 , enet_pps_3 = 2 }
 PPS indexes. More...
 
enum  enet_ptp_auxi_snapshot_trigger_idx_t { enet_ptp_auxi_snapshot_trigger_0 = ENET_TS_CTRL_ATSEN0_MASK , enet_ptp_auxi_snapshot_trigger_1 = ENET_TS_CTRL_ATSEN1_MASK , enet_ptp_auxi_snapshot_trigger_2 = ENET_TS_CTRL_ATSEN2_MASK , enet_ptp_auxi_snapshot_trigger_3 = ENET_TS_CTRL_ATSEN3_MASK }
 ptp auxiliary snapshot trigger indexes More...
 
enum  enet_pps_ctrl_t {
  enet_pps_ctrl_pps = 0 , enet_pps_ctrl_bin_2hz_digital_1hz , enet_pps_ctrl_bin_4hz_digital_2hz , enet_pps_ctrl_bin_8hz_digital_4hz ,
  enet_pps_ctrl_bin_16hz_digital_8hz , enet_pps_ctrl_bin_32hz_digital_16hz , enet_pps_ctrl_bin_64hz_digital_32hz , enet_pps_ctrl_bin_128hz_digital_64hz ,
  enet_pps_ctrl_bin_256hz_digital_128hz , enet_pps_ctrl_bin_512hz_digital_256hz , enet_pps_ctrl_bin_1024hz_digital_512hz , enet_pps_ctrl_bin_2048hz_digital_1024hz ,
  enet_pps_ctrl_bin_4096hz_digital_2048hz , enet_pps_ctrl_bin_8192hz_digital_4096hz , enet_pps_ctrl_bin_16384hz_digital_8192hz , enet_pps_ctrl_bin_32768hz_digital_16384hz
}
 PPS0 control for output frequency selections. More...
 
enum  enet_pps_cmd_t {
  enet_pps_cmd_no_command = 0 , enet_pps_cmd_start_single_pulse , enet_pps_cmd_start_pulse_train , enet_pps_cmd_cancel_start ,
  enet_pps_cmd_stop_pulse_train_at_time , enet_pps_cmd_stop_pulse_train_immediately , enet_pps_cmd_cancel_stop_pulse_train
}
 PPS0 commands. More...
 

Functions

void enet_get_default_tx_control_config (ENET_Type *ptr, enet_tx_control_config_t *config)
 Get a default control config for tranmission. More...
 
void enet_get_default_interrupt_config (ENET_Type *ptr, enet_int_config_t *config)
 Get a default interrupt config. More...
 
uint32_t enet_get_interrupt_status (ENET_Type *ptr)
 Get interrupt status. More...
 
void enet_mask_mmc_rx_interrupt_event (ENET_Type *ptr, uint32_t mask)
 Mask the specified mmc interrupt evenets of received frames. More...
 
void enet_mask_mmc_tx_interrupt_event (ENET_Type *ptr, uint32_t mask)
 Mask the specified mmc interrupt evenets of transmitted frames. More...
 
uint32_t enet_get_mmc_rx_interrupt_status (ENET_Type *ptr)
 Get a staus of mmc receive interrupt events. More...
 
uint32_t enet_get_mmc_tx_interrupt_status (ENET_Type *ptr)
 et a staus of mmc transmission interrupt events More...
 
hpm_stat_t enet_controller_init (ENET_Type *ptr, enet_inf_type_t inf_type, enet_desc_t *desc, enet_mac_config_t *cfg, enet_int_config_t *int_config)
 Initialize controller. More...
 
void enet_set_line_speed (ENET_Type *ptr, enet_line_speed_t speed)
 Set port line speed. More...
 
void enet_set_duplex_mode (ENET_Type *ptr, enet_duplex_mode_t mode)
 Set duplex mode. More...
 
uint16_t enet_read_phy (ENET_Type *ptr, uint32_t phy_addr, uint32_t addr)
 Read phy. More...
 
void enet_write_phy (ENET_Type *ptr, uint32_t phy_addr, uint32_t addr, uint32_t data)
 Write phy. More...
 
void enet_rx_resume (ENET_Type *ptr)
 Resume reception process. More...
 
uint32_t enet_check_received_frame (enet_rx_desc_t **parent_rx_desc_list_cur, enet_rx_frame_info_t *rx_frame_info)
 Check if there is a received frame. More...
 
enet_frame_t enet_get_received_frame (enet_rx_desc_t **parent_rx_desc_list_cur, enet_rx_frame_info_t *rx_frame_info)
 get a received frame More...
 
enet_frame_t enet_get_received_frame_interrupt (enet_rx_desc_t **parent_rx_desc_list_cur, enet_rx_frame_info_t *rx_frame_info, uint32_t rx_desc_count)
 get a received frame from interrupt More...
 
uint32_t enet_prepare_transmission_descriptors (ENET_Type *ptr, enet_tx_desc_t **parent_tx_desc_list_cur, uint16_t frame_length, uint16_t tx_buff_size)
 prepare for the transmission descriptors (It will be deprecated.) More...
 
uint32_t enet_prepare_tx_desc (ENET_Type *ptr, enet_tx_desc_t **parent_tx_desc_list_cur, enet_tx_control_config_t *config, uint16_t frame_length, uint16_t tx_buff_size)
 prepare for the transmission descriptors More...
 
uint32_t enet_prepare_tx_desc_with_ts_record (ENET_Type *ptr, enet_tx_desc_t **parent_tx_desc_list_cur, enet_tx_control_config_t *config, uint16_t frame_length, uint16_t tx_buff_size, enet_ptp_ts_system_t *timestamp)
 prepare for the transmission descriptors with a timestamp record More...
 
void enet_dma_tx_desc_chain_init (ENET_Type *ptr, enet_desc_t *desc)
 Initialize DMA transmission descriptors in chain mode. More...
 
void enet_dma_rx_desc_chain_init (ENET_Type *ptr, enet_desc_t *desc)
 Initialize DMA reception descriptors in chain mode. More...
 
void enet_dma_flush (ENET_Type *ptr)
 Flush DMA. More...
 
void enet_init_ptp (ENET_Type *ptr, enet_ptp_config_t *config)
 Initialize a PTP timer. More...
 
void enet_set_ptp_timestamp (ENET_Type *ptr, enet_ptp_ts_update_t *timestamp)
 Set a timestamp to the PTP timer. More...
 
void enet_get_ptp_timestamp (ENET_Type *ptr, enet_ptp_ts_system_t *timestamp)
 Get a timestamp from the PTP timer. More...
 
void enet_update_ptp_timeoffset (ENET_Type *ptr, enet_ptp_ts_update_t *timeoffset)
 Update a timestamp to the PTP timer. More...
 
void enet_adjust_ptp_time_freq (ENET_Type *ptr, int32_t adj)
 Adjust the count frequency of the PTP timer. More...
 
void enet_set_ptp_version (ENET_Type *ptr, enet_ptp_version_t ptp_ver)
 Set the PTP version. More...
 
hpm_stat_t enet_enable_ptp_frame_type (ENET_Type *ptr, enet_ptp_frame_type_t ptp_frame_type, bool enable)
 Enable the specified ptp frame type for MAC process. More...
 
void enet_set_snapshot_ptp_message_type (ENET_Type *ptr, enet_ts_ss_ptp_msg_t ts_ss_ptp_msg)
 Set the ptp message type for snapshots. More...
 
void enet_set_pps0_control_output (ENET_Type *ptr, enet_pps_ctrl_t freq)
 Set the pps0 control output. More...
 
hpm_stat_t enet_set_ppsx_command (ENET_Type *ptr, enet_pps_cmd_t cmd, enet_pps_idx_t idx)
 Set a pps command for ppsx. More...
 
hpm_stat_t enet_set_ppsx_config (ENET_Type *ptr, enet_pps_cmd_config_t *cmd_cfg, enet_pps_idx_t idx)
 Set a pps config for ppsx. More...
 
void enet_mask_interrupt_event (ENET_Type *ptr, uint32_t mask)
 Mask Ethernet interrupt events. More...
 
void enet_unmask_interrupt_event (ENET_Type *ptr, uint32_t mask)
 Unmask ENET interrupt events. More...
 
void enet_enable_ptp_auxiliary_snapshot (ENET_Type *ptr, enet_ptp_auxi_snapshot_trigger_idx_t idx)
 Disable PTP auxiliary snapshot. More...
 
void enet_disable_ptp_auxiliary_snapshot (ENET_Type *ptr, enet_ptp_auxi_snapshot_trigger_idx_t idx)
 Enable PTP auxiliary snapshot. More...
 
void enet_get_ptp_auxi_timestamp (ENET_Type *ptr, enet_ptp_ts_auxi_snapshot_t *timestamp)
 Get PTP auxiliary timestamp. More...
 
void enet_get_ptp_auxi_snapshot_status (ENET_Type *ptr, enet_ptp_auxi_snapshot_status_t *status)
 Get PTP Auxiliary Snapshot Status. More...