EthTrcv

文档信息 Document Information

版本历史 Version History

日期(Date)

作者(Author)

版本(Version)

状态(Status)

说明(Description)

2025/3/3

miao.wang

V0.1

发布(Release)

首次发布(First release)

2025/04/04

miao.wang

V1.0

发布(Release)

正式发布(Official release)

参考文档 References

编号(Number)

分类(Classification)

标题(Title)

版本(Version)

1

Autosar

AUTOSAR_SWS_EthernetTransceiverDriver.pdf

R23-11

2

Autosar

AUTOSAR_SWS_ECUStateManager.pdf

R23-11

3

Autosar

AUTOSAR_SWS_EthernetInterface.pdf

R23-11

术语与简写 Terms and Abbreviations

术语 Terms

None

简写 Abbreviations

简写(Abbreviation)

全称(Full name)

解释(Explanation)

EC

Ethernet controller

以太网控制器

ET

Ethernet transceiver

以太网收发器

Eth

Ethernet Controller Driver

以太网控制器驱动

EthIf

Ethernet Interface

以太网接口

EthTrcv

Ethernet Transceiver Driver

以太网收发器驱动

MCG

Module Configuration Generator

模块配置生成器

MII

Media Independent Interface

媒体独立接口

PLCA

Physical Layer Collision Avoidance

物理层碰撞避免

P2P

Point-to-Point

链路层协议

TO

Transmit Opportunity

发送机会

简介 Introduction

在AUTOSAR分层软件体系结构中,EthTrcv属于微控制器抽象层, 它是一个以太网收发器的驱动模块。

In the AUTOSAR layered software architecture, EthTrcv belongs to the Microcontroller Abstraction Layer, and it is a driver module for the Ethernet transceiver.

EthTrcv模块的主要任务是向上层(以太网接口)提供独立于硬件的接口,因为包括多个相同的收发器,

The main task of the EthTrcv module is to provide a hardware-independent interface to the upper layer (Ethernet Interface). Since multiple identical transceivers are included,

所以对于所有的收发器来说,接口应该统一,这样上层(以太网接口)可以以统一的方式访问底层总线系统。

the interface shall be unified for all transceivers, so that the upper layer (Ethernet Interface) can access the underlying bus system in a unified manner.

../../../_images/image12.png

EthTrcv模块层次图 (EthTrcv Module Layer Diagram)

功能描述 Functional Description

模式设置功能 Mode Setting Function

以设置收发器的状态为例,上层EthIf调用设置收发器状态的API,EthTrcv通过对芯片的寄存器的值进行修改,从而到达修改收发器状态的目的。

Taking setting the state of the transceiver as an example: the upper layer EthIf calls the API for setting the transceiver state, and EthTrcv modifies the value of the chip’s register, so as to achieve the purpose of modifying the transceiver state.

唤醒检测功能 Wakeup Detection Function

以太网收发器驱动程序应支持唤醒取决于配置参数EthTrcvWakeUpSupport,要么根本不支持(ETHTRCV_WAKEUP_NOT_SUPPORTED),或通过中断(ETHTRCV_WAKEUP_BY_INTERRUPT),或通过轮询(ETHTRCV_WAKEUP_BY_POLLING)。

The Ethernet Transceiver Driver shall support wakeup depending on the configuration parameter EthTrcvWakeUpSupport: it either does not support wakeup at all (ETHTRCV_WAKEUP_NOT_SUPPORTED), or supports it via interrupt (ETHTRCV_WAKEUP_BY_INTERRUPT),or supports it via polling (ETHTRCV_WAKEUP_BY_POLLING).

如果以太网收发器驱动程序检测到唤醒,它会将收发器硬件提供的唤醒原因映射到EcuM定义的唤醒事件。

If the Ethernet Transceiver Driver detects a wakeup, it maps the wakeup reason provided by the transceiver hardware to the wakeup event defined by EcuM.

以太网收发器驱动程序将支持以下场景:

The Ethernet Transceiver Driver shall support the following scenarios:

1.休眠的ECU 和休眠的总线 -> 通过EthTrcv_Init唤醒检测(在开机期间调用)

1.Dormant ECU and dormant bus -> Wakeup detection via EthTrcv_Init (called during power-on)

2.唤醒的ECU 和休眠的总线 -> 通过EthTrcv_MainFunction或唤醒中断处理程序唤醒检测(由EcuM中的CheckWakeup检查)

2.Awake ECU and dormant bus -> Wakeup detection via EthTrcv_MainFunction or wakeup interrupt handler (checked by CheckWakeup in EcuM)

特性 Features

不支持变体功能 Variant function is not supported

集成 Integration

文件列表 File List

静态文件 Static Files

文件(File)

描述(Description)

EthTrcv.h

声明EthTrcv模块的全部外部接口(除了回调函数),以及配置文件中的全局变量。(Declares all external interfaces of the EthTrcv module (except callback functions) and global variables in the configuration file.)

EthTrcv.c

作为EthTrcv模块的核心文件,实现EthTrcv模块全部对外接口,以及实现EthTrcv模块功能所必须的local函数,local宏定义,local变量定义。(Serves as the core file of the EthTrcv module; implements all external interfaces of the EthTrcv module, as well as local functions, local macros, and local variable definitions necessary for implementing the functions of the EthTrcv module.)

EthTrcv_Types.h

定义EthTrcv模块外部/内部类型,包括AUTOSAR标准定义的类型。(Defines external/internal types of the EthTrcv module, including types defined by the AUTOSAR standard.)

EthTrcv_Internal.h

声明EthTrcv模块内部功能所必须的local函数,local宏定义,local变量。(Declares local functions, local macros, and local variables necessary for the internal functions of the EthTrcv module.)

EthTrcv_Internal.c

实现EthTrcv模块内部功能所必须的local函数,local宏定义,local变量。(Implements local functions, local macros, and local variables necessary for the internal functions of the EthTrcv module.)

EthTrcv_DetError.h

声明EthTrcv模块DET错误检测功能的函数接口。(Declares the function interfaces for the DET error detection function of the EthTrcv module.)

EthTrcv_DetError.c

实现EthTrcv模块DET错误检测功能的函数接口。(Implements the function interfaces for the DET error detection function of the EthTrcv module.)

EthTrcv_Cbk.h

包含EthTrcv模块全部回调函数的声明。(Contains declarations of all callback functions of the EthTrcv module.)

EthTrcv_MemMap.h

声明EthTrcv模块内存布局。(Declares the memory layout of the EthTrcv module.)

动态文件 Dynamic Files

文件(File)

描述(Description)

EthTrcv_CfgTypes.h

定义PB/PC配置参数结构体类型,以及内部运行时结构体类型。(Defines the structure types of PB/PC configuration parameters and internal runtime structure types.)

EthTrcv_Cfg.h

定义EthTrcv模块PC配置的宏定义。(Defines the macros for the PC configuration of the EthTrcv module.)

EthTrcv_Cfg.c

定义EthTrcv模块PC配置的结构体参数。(Defines the structure parameters for the PC configuration of the EthTrcv module.)

EthTrcv_PBcfg.h

定义EthTrcv模块PB配置的宏定义。(Defines the macros for the PB configuration of the EthTrcv module.)

EthTrcv_PBcfg.c

定义EthTrcv模块PB配置的结构体参数。(Defines the structure parameters for the PB configuration of the EthTrcv module.)

错误处理 Error Handling

开发错误 Development Errors

Error code

Value[hex]

Description

ETHTRCV_E_INV_TRCV_IDX

0x01

Invalid transceiver index

ETHTRCV_E_UNINIT

0x02

EthTrcv module was not initialized

ETHTRCV_E_PARAM_POINTER

0x03

Invalid pointer in parameter list

ETHTRCV_E_NOT_SUPPORTED

0x04

Functionality is not supported

产品错误 Product Errors

None

运行时错误 Runtime Errors

Error code

Value[hex]

Description

ETHTRCV_E_MDI_COMMUNICATION

0x04

Failure or incorrect communication mode

接口描述 Interface Description

类型定义 Type Definitions

None

提供的服务 Services

EthTrcv_Init

void EthTrcv_Init(const EthTrcv_ConfigType *CfgPtr)

Initializes the Ethernet Transceiver Driver.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

CfgPtr

Points to the implementation specific structure.

Return type

void

EthTrcv_SetTransceiverMode

Std_ReturnType EthTrcv_SetTransceiverMode(uint8 TrcvIdx, Eth_ModeType TrcvMode)

Enables / disables the indexed transceiver.

Sync/Async

FALSE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Transceiver Driver.

[in]

TrcvMode

ETH_MODE_DOWN: disable the transceiver. ETH_MODE_ACTIVE: enable the transceiver. ETH_MODE_ACTIVE_WITH_WAKEUP_REQUEST: enable the transceiver and request to trigger a wake-up on the network, if the used PHY support such a feature. E.g. used for PHYs compliant to OA TC10.

Return type

Std_ReturnType

EthTrcv_GetTransceiverMode

Std_ReturnType EthTrcv_GetTransceiverMode(uint8 TrcvIdx, Eth_ModeType *TrcvModePtr)

Obtains the state of the indexed transceiver.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Transceiver Driver.

[out]

TrcvModePtr

ETH_MODE_DOWN: the transceiver is disabled. ETH_MODE_ACTIVE: the transceiver is enable.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

success.

E_NOT_OK

transceiver could not be initialized.

EthTrcv_GetBusWuReason

Std_ReturnType EthTrcv_GetBusWuReason(uint8 TrcvIdx, EthTrcv_WakeupReasonType *WakeupReasonPtr)

This function returns the least recent wakeup reasons.

Sync/Async

TRUE

Reentrancy

Reentrant

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

[out]

WakeupReasonPtr

Pointer to structure of least recent wakeup event, which was detected by the Ethernet PHY.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

PHY wake up reason request has been accepted.

E_NOT_OK

PHY wake up reason request has not been accepted.

EthTrcv_CheckWakeup

Std_ReturnType EthTrcv_CheckWakeup(uint8 TrcvIdx)

Service is called by EthIf in case a wake-up interrupt is detected.

Sync/Async

TRUE

Reentrancy

Reentrant

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Transceiver Driver.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The function has been successfully executed.

E_NOT_OK

The function could not be successfully executed.

EthTrcv_StartAutoNegotiation

Std_ReturnType EthTrcv_StartAutoNegotiation(uint8 TrcvIdx)

Restarts the negotiation of the transmission parameters used by the indexed transceiver.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

success.

E_NOT_OK

transceiver could not be initialized.

EthTrcv_TransceiverLinkStateRequest

Std_ReturnType EthTrcv_TransceiverLinkStateRequest(uint8 TrcvIdx, EthTrcv_LinkStateType LinkState)

Request the given link state for the given transceiver.

Sync/Async

FALSE

Reentrancy

Reentrant for different TrcvIdx. Non reentrant for the same TrcvIdx.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Transceiver Driver.

[in]

LinkState

The link state of a physical connection.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

EthTrcv_GetLinkState

Std_ReturnType EthTrcv_GetLinkState(uint8 TrcvIdx, EthTrcv_LinkStateType *LinkStatePtr)

Obtains the link state of the indexed transceiver.

Sync/Async

TRUE

Reentrancy

Non Reentrant.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Transceiver Driver.

[out]

LinkStatePtr

ETHTRCV_LINK_STATE_DOWN: transceiver is disconnected. ETHTRCV_LINK_STATE_ACTIVE: transceiver is connected.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

success.

E_NOT_OK

transceiver could not be initialized.

EthTrcv_GetBaudRate

Std_ReturnType EthTrcv_GetBaudRate(uint8 TrcvIdx, EthTrcv_BaudRateType *BaudRatePtr)

Obtains the baud rate of the indexed transceiver.

Sync/Async

TRUE

Reentrancy

Non Reentrant.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

[out]

BaudRatePtr

ETHTRCV_BAUD_RATE_10MBIT: 10MBit connection. ETHTRCV_BAUD_RATE_100MBIT: 100MBit connection. ETHTRCV_BAUD_RATE_1000MBIT: 1000MBit connection. ETHTRCV_BAUD_RATE_2500MBIT: 2500MBit connection.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

success.

E_NOT_OK

transceiver could not be initialized.

EthTrcv_GetDuplexMode

Std_ReturnType EthTrcv_GetDuplexMode(uint8 TrcvIdx, EthTrcv_DuplexModeType *DuplexModePtr)

Obtains the duplex mode of the indexed transceiver.

Sync/Async

TRUE

Reentrancy

Non Reentrant.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

[out]

DuplexModePtr

ETHTRCV_DUPLEX_MODE_HALF: half duplex connections. ETHTRCV_DUPLEX_MODE_FULL: full duplex connection.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

success.

E_NOT_OK

transceiver could not be initialized.

EthTrcv_SetPhyTestMode

Std_ReturnType EthTrcv_SetPhyTestMode(uint8 TrcvIdx, EthTrcv_PhyTestModeType Mode)

Activates a given test mode.

Sync/Async

TRUE

Reentrancy

Reentrant for different TrcvIdx. Non reentrant for the same TrcvIdx.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

[in]

Mode

Test mode to be activated.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

EthTrcv_SetPhyLoopbackMode

Std_ReturnType EthTrcv_SetPhyLoopbackMode(uint8 TrcvIdx, EthTrcv_PhyLoopbackModeType Mode)

Activates a given loopback mode.

Sync/Async

TRUE

Reentrancy

Reentrant for different TrcvIdx. Non reentrant for the same TrcvIdx.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

[in]

Mode

Loopback mode to be activated.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

EthTrcv_GetPhySignalQuality

Std_ReturnType EthTrcv_GetPhySignalQuality(uint8 TrcvIdx, uint32 *SignalQualityPtr)

Obtains the current signal quality of the link of the indexed transceiver.

Sync/Async

TRUE

Reentrancy

Reentrant for different TrcvIdx. Non reentrant for the same TrcvIdx.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

[out]

SignalQualityPtr

Pointer to the memory where the signal quality shall be stored.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

EthTrcv_SetPhyTxMode

Std_ReturnType EthTrcv_SetPhyTxMode(uint8 TrcvIdx, EthTrcv_PhyTxModeType Mode)

Activates a given transmission mode.

Sync/Async

TRUE

Reentrancy

Reentrant for different TrcvIdx. Non reentrant for the same TrcvIdx.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

[in]

Mode

Transmission mode to be activated.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

EthTrcv_RunCableDiagnostic

Std_ReturnType EthTrcv_RunCableDiagnostic(uint8 TrcvIdx)

Trigger the cable diagnostics for the given Ethernet transceiver.

Sync/Async

FALSE

Reentrancy

Reentrant for different TrcvIdx. Non reentrant for the same TrcvIdx.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the Ethernet transceiver within the context of the Ethernet Transceiver Driver.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The trigger has been accepted.

E_NOT_OK

The trigger has not been accepted.

EthTrcv_GetCableDiagnosticsResult

Std_ReturnType EthTrcv_GetCableDiagnosticsResult(uint8 TrcvIdx, EthTrcv_CableDiagResultType *ResultPtr)

Retrieves the cable diagnostics result of a given transceiver.

Sync/Async

TRUE

Reentrancy

Reentrant for different TrcvIdx. Non reentrant for the same TrcvIdx.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

[out]

ResultPtr

Pointer to the location where the cable diagnostics result shall be stored.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

EthTrcv_GetPhyIdentifier

Std_ReturnType EthTrcv_GetPhyIdentifier(uint8 TrcvIdx, uint32 *OrgUniqueIdPtr, uint8 *ModelNrPtr, uint8 *RevisionNrPtr)

Obtains the PHY identifier of the Ethernet Transceiver according to IEEE 802.3-2015 chapter 22.2.4.3.1 PHY Identifer.

Sync/Async

TRUE

Reentrancy

Reentrant for different TrcvIdx. Non reentrant for the same TrcvIdx.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

[out]

OrgUniqueIdPtr

Pointer to the memory where the Organizationally Unique Identifier shall be stored.

[out]

ModelNrPtr

Pointer to the memory where the Manufacturer’s Model Number shall be stored.

[out]

RevisionNrPtr

Pointer to the memory where the Revision Number shall be stored.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

EthTrcv_GetMacMethod

Std_ReturnType EthTrcv_GetMacMethod(uint8 *TrcvIdx, EthTrcv_MacMethodType *MacModePtr)

Obtains the media access mode of the transceiver when EthTrcvDuplexMode is configured as ETHTRCV_DUPLEX_MODE_HALF.

Sync/Async

TRUE

Reentrancy

Non Reentrant.

Parameters

Dir

Name

Description

[in]

TrcvIdx

Index of the transceiver within the context of the Ethernet Transceiver Driver.

[out]

MacModePtr

ETHTRCV_MAC_TYPE_CSMA_CD: Carrier-sense multiple access with collicion detection. ETHTRCV_MAC_TYPE_PLCA: Physical layer collision avoidance.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

success.

E_NOT_OK

MacType could not be returned.

EthTrcv_GetVersionInfo

void EthTrcv_GetVersionInfo(Std_VersionInfoType *VersionInfoPtr)

Returns the version information of this module.

Sync/Async

TRUE

Reentrancy

Reentrant.

Parameters

Dir

Name

Description

[out]

VersionInfoPtr

Version information of this module.

Return type

void

EthTrcv_MainFunction

void EthTrcv_MainFunction(void)

Used for polling state changes and wakeup reasons. Calls EthIf_TrcvModeIndication when the transceiver mode changed. Stores wakeup events if EthTrcvWakeUpSupport is set to ETHTRCV_WAKEUP_BY_POLLING.

Sync/Async

TRUE

Reentrancy

Non Reentrant.

Return type

void

配置 Configuration

EthTrcv模块全局通用配置

Global General Configuration of the EthTrcv Module

../../../_images/image22.png

EthTrcvGeneral

  1. 收发器是否应支持唤醒,取决于配置项EthTrcvWakeUpSupport。

  1. Whether the transceiver shall support wakeup depends on the configuration item EthTrcvWakeUpSupport.

EthTrcv模块收发器配置

Transceiver Configuration of the EthTrcv Module

../../../_images/image32.png

EthTrcvConfig