CanTrcv

文档信息 Document Information

历史版本 Version History

日期(Date)

作者(Author)

版本(Version)

状态(Status)

说明(Description)

2025/4/2

Zhijia.Zou

V0.1

发布(Release)

首次发布(First release)

2025/04/04

Zhijia.Zou

V1.0

发布(Release)

正式发布(Official release)

参考文档 Reference Document

编号(Number)

分类(Classification)

标题(Title)

版本(Version)

1

Autosar

AUTOSAR_SWS_CanTransceiverDriver.pdf

R23-11

2

Autosar

AUTOSAR_SRS_CAN.pdf

R23-11

术语与简写 Terms and Abbreviations

术语 Terms

None

简写 Abbreviations

None

简介 Introduction

CanTrcv功能介绍 CanTrcv Function Introduction

CAN收发器驱动程序模块负责处理ECU上的CAN收发器硬件芯片,并将CAN总线上使用的信号电平调整为微控制器可以识别的逻辑(数字)信号电平。此外,收发器还能检测到电气故障,如线路问题、地面偏移或长主导信号的传输。

The CAN Transceiver Driver module is responsible for handling the CAN transceiver hardware chip on the ECU and adjusting the signal level used on the CAN bus to a logic (digital) signal level recognizable by the microcontroller. In addition, the transceiver can detect electrical faults, such as line problems, ground offsets, or the transmission of long dominant signals.

根据CAN收发器与微控制器的接口,驱动程序模块可以标记由外部端口pin记录的探测错误或由SPI总线记录的检测错误;特定CAN收发器支持电源控制,并通过CAN总线唤醒。有些CAN收发器具备特定功能,如系统基础芯片(SBC),它除了CAN基本功能之外,还实现了电源控制和高级监控,并通过SPI总线和MCU进行访问。部分网络唤醒是CAN系统中的一种状态,其中一些节点处于低功耗模式,而其他节点正在通信。这减少了整个网络的功耗。在低功耗模式下,节点被预先定义的唤醒帧唤醒。支持选择性唤醒的收发器除了普通收发器提供的唤醒模式(Wakeup Pattern)外,还可以通过唤醒帧(Wakeup Frame)来唤醒。

According to the interface between the CAN transceiver and the microcontroller, the driver module can flag detection errors recorded by external port pins or detection errors recorded by the SPI bus; specific CAN transceivers support power control and can wake up through the CAN bus. Some CAN transceivers have specific functions, such as System Basis Chips (SBCs), which, in addition to the basic CAN functions, also implement power control and advanced monitoring, and are accessed by the MCU through the SPI bus. Partial network wakeup is a state in the CAN system where some nodes are in low-power mode while other nodes are communicating. This reduces the power consumption of the entire network. In low-power mode, nodes are woken up by pre-defined Wakeup Frame. Transceivers that support selective wakeup can be woken up by Wakeup Frame in addition to the Wakeup Pattern provided by ordinary transceivers.

CanTrcv功能实现 CanTrcv Function Implementation

CAN收发器驱动程序的目标是指定适合CAN收发器设备的接口和行为和抽象CAN收发器硬件;它为上层提供了一个独立于硬件的接口;它通过使用MCAL层的API接口访问CAN收发器硬件,从ECU布局中抽象出来。

The goal of the CAN Transceiver Driver is to specify interfaces and behaviors suitable for CAN transceiver devices and abstract the CAN transceiver hardware; it provides a hardware-independent interface for the upper layer; it accesses the CAN transceiver hardware by using the API interface of the MCAL layer, abstracting away from the ECU layout.

CanTrcv在访问到硬件,发现唤醒事件之后,也可以通过回调接口通知到上层CanIf/EcuM从而使BSW能处理这些唤醒事件。

After the CanTrcv accesses the hardware and detects a wakeup event, it can also notify the upper-layer CanIf/EcuM through a callback interface, so that the BSW can handle these wakeup events.

偏差 Deviations

None

扩展 Extensions

None

集成 Integration

文件列表 File List

文件结构图 File Structure Diagram

../../../_images/CanTrcv%E6%96%87%E4%BB%B6%E7%BB%93%E6%9E%84%E5%9B%BE.png

静态文件 Static Files

文件(File)

说明(Description)

CanTrcv.c

包含需要使用的宏定义,内部变量,内部函数,全局函数。(Contains macro definitions, internal variables, internal functions, and global functions that need to be used.)

CanTrcv_Driver.c

包含需要使用的关于硬件的宏定义,内部变量,内部函数。(Contains macro definitions related to hardware, internal variables, and internal functions that need to be used.)

CanTrcv_Driver.h

包含需要使用的关于硬件的宏定义,类型定义,内部函数声明。(Contains macro definitions related to hardware, type definitions, and internal function declarations that need to be used.)

CanTrcv_Types.h

包含需要使用的类型定义。(Contains type definitions that need to be used.)

CanTrcv.h

包含需要使用的宏定义,类型定义,配置结构体声明,外部函数声明。(Contains macro definitions, type definitions, configuration structure declarations, and external function declarations that need to be used.)

动态文件 Dynamic Files

文件(File)

说明(Description)

CanTrcv_Cfg.h

生成CanTrcv模块配置相关的宏定义。(Generates macro definitions related to the CanTrcv module configuration.)

CanTrcv_Cfg.c

生成CanTrcv模块配置相关的结构体。(Generates structures related to the CanTrcv module configuration.)

CanTrcv_MemMap.h

CanTrcv模块的内存映射。(Memory mapping of the CanTrcv module.)

错误处理 Error Handling

开发错误 Development Errors

Error code

Value[hex]

Description

CANTRCV_E_INVALID_TRANSCEIVER

0x01

API called with wrong parameter for the CAN transceiver

CANTRCV_E_PARAM_POINTER

0x02

API called with null pointer parameter

CANTRCV_E_UNINIT

0x0B

API service used without initialization

CANTRCV_E_TRCV_NOT_STANDBY

0x15

API service called in wrong transceiver operation mode (STANDBY expected)

CANTRCV_E_TRCV_NOT_NORMAL

0x16

API service called in wrong transceiver operation mode (NORMAL expected)

CANTRCV_E_PARAM_TRCV_WAKEUP_MODE

0x17

API service called with invalid parameter for Trcv WakeupMode

CANTRCV_E_PARAM_TRCV_OPMODE

0x18

API service called with invalid parameter for Op Mode

CANTRCV_E_BAUDRATE_NOT_SUPPORTED

0x19

Configured baud rate is not supported by the transceiver

CANTRCV_E_INIT_FAILED

0x1A

Module initialization has failed, e.g. CanTrcv_Init() called with an invalid pointer in postbuild.

运行时错误 Runtime Errors

Error code

Value[hex]

Description

CANTRCV_E_NO_TRCV_CONTROL

0x1A

No/incorrect communication to transceiver.

类型定义 Type Definitions

Type Name

Type

Description

CanTrcv_ConfigType

struct CanTrcv_Config_T

描述配置参数结构体类型定义(Description:Configuration parameter structure type definition)

CanTrcv_PNActivationType

struct CanTrcv_PNActivationTypeTag

部分唤醒功能开关(Partial wakeup function switch)

CanTrcv_TrcvFlagStateType

struct CanTrcv_TrcvFlagStateTypeTag

CanTrcv硬件是否置位(Whether the CanTrcv hardware flag is set)

CanTrcv模块接口描述 CanTrcv Module Interface Description

CanTrcv_Init

void CanTrcv_Init(const CanTrcv_ConfigType *ConfigPtr)

This function initializes the CanTrcv module.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

ConfigPtr

Pointer to selected configuration structure

Return type

void

CanTrcv_SetOpMode

Std_ReturnType CanTrcv_SetOpMode(uint8 Transceiver, CanTrcv_TrcvModeType OpMode)

This function sets the mode of the Transceiver to the value OpMode.

Sync/Async

TRUE

Reentrancy

Reentrant for different transceivers

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

[in]

OpMode

This parameter contains the desired operating mode.

Return type

Std_ReturnType

CanTrcv_GetOpMode

Std_ReturnType CanTrcv_GetOpMode(uint8 Transceiver, CanTrcv_TrcvModeType *OpMode)

This function gets the mode of the Transceiver and returns it in OpMode.

Sync/Async

TRUE

Reentrancy

Reentrant

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

[out]

OpMode

Pointer to operation mode of the bus the API is applied to.

Return type

Std_ReturnType

CanTrcv_GetBusWuReason

Std_ReturnType CanTrcv_GetBusWuReason(uint8 Transceiver, P2VAR(CanTrcv_TrcvWakeupReasonType, AUTOMATIC, CANTRCV_APPL_DATA) reason)

This function gets the wakeup reason for the Transceiver and returns it in parameter Reason.

Sync/Async

TRUE

Reentrancy

Reentrant

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

[out]

reason

Pointer to wake up reason of the bus the API is applied to.

Return type

Std_ReturnType

CanTrcv_GetVersionInfo

void CanTrcv_GetVersionInfo(Std_VersionInfoType *versioninfo)

This function gets the version of the module and returns it in VersionInfo.

Sync/Async

TRUE

Reentrancy

Reentrant

Parameters

Dir

Name

Description

[out]

versioninfo

Pointer to version information of this module.

Return type

void

CanTrcv_SetWakeupMode

Std_ReturnType CanTrcv_SetWakeupMode(uint8 Transceiver, CanTrcv_TrcvWakeupModeType TrcvWakeupMode)

This function enables, disables or clears wake-up events of the Transceiver according to TrcvWakeupMode.

Sync/Async

TRUE

Reentrancy

Reentrant for different transceivers

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

[in]

TrcvWakeupMode

Requested transceiver wakeup reason.

Return type

Std_ReturnType

CanTrcv_MainFunction

void CanTrcv_MainFunction(void)

This is the main function of CanTrcv, which scans all busses for wake up events and perform these event.

Sync/Async

TRUE

Reentrancy

FALSE

Return type

void

CanTrcv_CheckWakeup

Std_ReturnType CanTrcv_CheckWakeup(uint8 Transceiver)

This function is called by underlying CANIF in case a wake up interrupt is detected.

Sync/Async

TRUE

Reentrancy

Reentrant

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

Return type

Std_ReturnType

CanTrcv_MainFunctionDiagnostics

void CanTrcv_MainFunctionDiagnostics(void)

This function reads the transceiver diagnostic status periodically and sets product/development accordingly.

Sync/Async

TRUE

Reentrancy

FALSE

Return type

void

CanTrcv_DeInit

void CanTrcv_DeInit(void)

This function de-initializes the CanTrcv module.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Return type

void

CanTrcv_GetTrcvSystemData

Std_ReturnType CanTrcv_GetTrcvSystemData(uint8 Transceiver, uint32 *TrcvSysData)

This function reads the transceiver configuration/status data and returns it through parameter TrcvSysData.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

[out]

TrcvSysData

Configuration/Status data of the transceiver.

Return type

Std_ReturnType

CanTrcv_ClearTrcvWufFlag

Std_ReturnType CanTrcv_ClearTrcvWufFlag(uint8 Transceiver)

This function clears the WUF flag in the transceiver hardware.

Sync/Async

TRUE

Reentrancy

Reentrant for different transceivers

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

Return type

Std_ReturnType

CanTrcv_ReadTrcvTimeoutFlag

Std_ReturnType CanTrcv_ReadTrcvTimeoutFlag(uint8 Transceiver, CanTrcv_TrcvFlagStateType *FlagState)

This function reads the status of the timeout flag from the transceiver hardware.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

[out]

FlagState

State of the timeout flag.

Return type

Std_ReturnType

CanTrcv_ClearTrcvTimeoutFlag

Std_ReturnType CanTrcv_ClearTrcvTimeoutFlag(uint8 Transceiver)

This function clears the status of the timeout flag in the transceiver hardware.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

Return type

Std_ReturnType

CanTrcv_ReadTrcvSilenceFlag

Std_ReturnType CanTrcv_ReadTrcvSilenceFlag(uint8 Transceiver, CanTrcv_TrcvFlagStateType *FlagState)

This function reads the status of the silence flag from the transceiver hardware.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

[inout]

FlagState

State of the silence flag.

Return type

Std_ReturnType

CanTrcv_CheckWakeFlag

Std_ReturnType CanTrcv_CheckWakeFlag(uint8 Transceiver)

This function requests to check the status of the wakeup flag from the transceiver hardware.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

Transceiver

CAN transceiver to which API call has to be applied.

Return type

Std_ReturnType

CanTrcv_SetPNActivationState

Std_ReturnType CanTrcv_SetPNActivationState(CanTrcv_PNActivationType ActivationState)

This function configures the wake-up of the transceiver for Standby and Sleep Mode.

Sync/Async

TRUE

Reentrancy

Non Reentrant

Parameters

Dir

Name

Description

[in]

ActivationState

PN_ENABLED: PN wakeup functionality in CanTrcv shall be enabled, PN_DISABLED: PN wakeup functionality in CanTrcv shall be disabled.+

Return type

Std_ReturnType