【ETAS CP AUTOSAR基础软件】DET、Bfx、CRC、ComStack、rba_ArxmlGen模块详解

发布于:2024-06-16 ⋅ 阅读:(16) ⋅ 点赞:(0)

文章包含了AUTOSAR基础软件(BSW)中DET、Bfx、CRC、ComStack、rba_ArxmlGen模块相关的内容详解。本文从AUTOSAR规范解析,ISOLAR-AB配置以及模块相关代码分析三个维度来帮读者清晰的认识和了解DET、Bfx、CRC、ComStack、rba_ArxmlGen。文中涉及的SOLAR-AB配置以及模块相关代码都是依托于ETAS提供的工具链来配置与生成的,与AUTOSAR规范之间可能会有些许的出入,但总体的功能要点与处理流程都应该是一致的。

DET模块用于记录错误信息,Bfx和CRC提供了Bit操作和CRC计算的库例程,ComStack则包含了通信栈的一些类型定义,rba_ArxmlGen模块则不属于AUTOSAR规范,是ETAS用来帮助集成商生成协议栈基础软件配置工具。

目录

AUTOSAR规范解析

DET

Bfx

CRC

ComStack

rba_ArxmlGen

ISOLAR-AB配置 

DET

Bfx

CRC

ComStack

rba_ArxmlGen

代码解析

DET

Bfx 

CRC 

ComStack


AUTOSAR规范解析

DET

在4.2版本以前,DET全称为Development Error Tracer,开发错误追踪器,顾名思义是处理在开发集成过程中,错误的赋值或者越界使用等问题。比如你的参数是一个指针类型,看看是不是空指针,或者你的参数取值是否超过取值范围等等。但是从4.2版本之后,就更新成了Default Error Tracer,增加了模块需要对Runtime Error,Transient faults,Production errors,Extended production errors负责。现在的DET根据对错误的分类,提供不同的API供给集成商做错误处理。

基础软件中检测到的所有开发和运行时错误都将报告给DET(Default Error Tracer)模块.DET提供的API参数允许跟踪源和错误类型如下:

  • Module:错误发生的模块。
  • Function:错误发生的函数。
  • Type:错误类型。

此模块API背后的功能需要软件开发人员和软件集成商为其特定的应用和测试环境选择最优错误处理策略。它们可能是:

  • 在错误报告API中设置调试器断点
  • 统计报告的错误。
  • 恢复默认值来处理运行时错误。
  • 在RAM缓冲区中记录错误发生时的函数调用栈和传递的参数。
  • 通过通信接口将报告的错误发送到外部记录器。

DET模块提供初始化功能Det_Init函数,函数每次调用都将错误跟踪器(DET)设置为定义的初始状态。

为了支持开发和运行时中的调试和错误跟踪,默认错误跟踪器提供了通知接收到错误报告的功能:Error Hooks。所谓的错误挂钩是可配置的。错误挂钩将用于转发错误通知。如下图所示。

可以看出,挂钩函数跟Det_ReportError、Det_ReportTransientFault、Det_ReportRuntimeError这些错误报告的函数的入参是一致的。


Bfx

AUTOSAR例程库是AUTOSAR体系结构中系统服务的一部分,下图显示了AUTOSAR库在分层体系结构中的位置。可以看出,各层都可以使用AUTOSAR库提供的例程实现相关功能。

Bfx库提供可用于定点数BIT操作的可重入API,它们可以直接从BSW模块或SWC调用,不需要端口定义,这是一个纯函数调用。这些API可以帮助集成开发商对定点数(诸如一个32位的无符号数)中包含的Bit位进行操作,诸如设置32位无符号数中第8Bit为1。这往往在配置单片机寄存器的值时非常有用,因为往往寄存器映射的32/16位数会包含不同的位域来控制外设。


CRC

循环冗余码校验英文名称为Cyclical Redundancy Check,简称CRC。您可以简要的理解为它会根据您输入的一串数据和选择的CRC算法,计算出一个不同位宽的CRC值,可以用于校验数据传输或者保存后是否出现数据错误,诸如发送端计算CRC并与发送的数据一并传输到接收端,接收端收到数据之后计算CRC与收到的CRC进行比较,一致则可以初步判断数据传输是没有问题的。

AUTOSAR规范规定CRC库需要提供的计算例程:

  • CRC8: SAEJ1850
  • CRC8H2F: CRC8 0x2F polynomial
  • CRC16
  • CRC32
  • CRC32P4: CRC32 0xF4ACFB13 polynomial
  • CRC64: CRC-64-ECMA

对于所有例程(CRC8、CRC8H2F、CRC16、CRC32、CRC32P4和CRC64),可以使用以下计算方法来实现CRC计算:

  • 基于表的计算:执行速度快,需要预存CRC对应表,代码尺寸会大。
  • 运行时计算:执行速度较慢,代码尺寸小。
  • 硬件支持CRC计算(特定于设备):快速执行,更少的CPU时间,无代码尺寸问题。

所有例程都是可重入的,可以同时被多个应用程序使用。


ComStack

ComStack模块包含AUTOSAR通信栈的类型头文件(ComStack_Types.h)和ARXML(Com-Stack_Type.arxml)文件。它定义了在基础软件通信栈中的几个模块所使用的所有类型,以及与平台和编译器无关的所有基础软件模块的类型定义。
强烈建议这些通信栈类型文件在AUTOSAR联盟成员中是一致的,以保证类型的唯一性,并避免在从供应商A更改到供应商B时发生类型更改。

其中PduldType和PduLengthType的值应分别源自EcuCPduCollection容器的“PduldTypeEnum”和“PduLengthType”。不允许添加任何特定项目或供应商的项目扩展名到此模块生成的文件。任何扩展都将使AUTOSAR符合性失效。诚然,由于许多通信栈模块类型取决于当前的ECU,因此应根据每个ECU的特定ECU配置独立地生成此文件。

基于EcuC模块的配置,RTA-BSW代码生成器生成以下文件:

  • ComStack_Types.h
  • ComStask_Cfg.h

注意:请勿将ComStack模块与通信(COM)栈混淆。ComStack模块仅为通信栈提供定义类头文件。在基础软件“栈”特指了在AUTOSAR架构下纵向相关的基础软件模块集合,为客户提供特定的功能。


rba_ArxmlGen

这个模块并不是AUTOSAR规范里的模块,他在RTA-BSW中被定义实现。

Rba_ArxmlGen提供了一个ARXML生成器来抽象BSWMD或SWCD文件中通常定义的元素。这允许ISOLAR-AB可以通过ConfGen来根据导入的DBC文件生成Rba_ArxmlGen这个模块的配置,并最终生成对应基础软件模块对应的BSWMD或SWCD内容。
Rba ArxmlGen是一个BSW组件,它简化了ARXML文件的创建过程,特别是对干BSWMD(基本软件模块描述)和SWCD(软件组件描述)文件。该组件的用户可以通过以比直接提供 BSWMD 或 SWCD文件更抽象的方式(通过在ISOLAR-B进行配置)提供包含所需元素的ECUC值来在CodeGen阶段创建BSWMD或SWCD内容。这些ECUC值可以作为文件提供,也可以作为配置生成器的输出(可能是非持久化的)提供。该模块通常完全由RTA-BSW配置生成器生成。对于任何不支持的自动配置,该模块也可以由用户手动配置。

Rba_ArxmlGen可用于生成本地定义的元素,如:

  • data types (application and implementation data types)
  • calibration parameters
  • measurement variables
  • computation methods
  • executable entities

以下元素将在其他地方定义(通常在手动维护的ARXML文件中):

  • 与其他组件共享的application and implementation data types
  • BSW module entries
  • ECUC parameter definitions
  • ECUC values

ISOLAR-AB配置 

DET

DET包含的配置如下。

下面是Det涉及的几个重要参数。

  • DetForwardToDlt:当为真时,Det才会使用Dlt_DetForwardErrorTrace将错误发给Dlt。
  • DetRbCheckApiconsistency:RTE会生成一些DET模块已经提供的APIs,这会导致一些重复定义的问题,此配置项为Ture就会打开Det.h中Det模块提供的函数原型声明,这样在编译中如果不一致则会报错。
  • DetRbErrorBufferSize:DET保存提报的错误Buffer大小。
  • DetNotification:可以手动增加DetErrorHook。

Bfx

Bfx包含的配置如下。

下面时Bfx涉及的几个重要参数:

  • BfxRbOptimizationMcuExtract:可以在Bfx模块AUTOSAR规范解析时得知,这个模块主要用在配置芯片的功能寄存器,如果此配置为TRUE, 控制器的信息将从MCU.Based中抽取出来。
  • BfxRbOptimization:针对那种平台进行优化,可以选择TC27XX或者MPC57XX,上文选择的不优化。
  • BfxRbMemoryLocations:选择生成的Bit操作函数存储位置,NORMAL在normal flash,FAST在fast flash,SLOW在slow flash,INLINE生成内联函数,在每一处调用地都会生成对应操作代码。

CRC

CRC包含的配置如下。

可以看到,主要用于配置是否生成前文提到的各种CRC实现算法以及算法的实现方式,上图涉及的算法都以查表的方式进行实现(用空间换时间)。


ComStack

下面是ComStack包含的配置。

集成开发商需要配置的地方仅仅是ComStackRbArRelease,用于选择当前工程基于的AUTOSAR版本。


rba_ArxmlGen

下图为示例工程包含的rba_ArxmlGen配置,它们都是通过RTA-BSW Configuration Generation生成出来的,对应通信栈相关模块,帮助生成对应BSWMD或SWCD。

我们下边只针对CanIf模块对应的rba_ArxmlGen来说明一下生成的配置都有哪些。如下图所示,可以看到生成了这个模块包含的基本元素,包括:AppDataTypes、CompuMethods、DataConstraints、ImplDataTypes、Measurements。

下图为它们每一部分包含的信息。基本上对应了ISOLAR-A的SoftWare中Data Types和计算方法的内容。


代码解析

DET

DET模块包含的代码结构如下。

  •  Det_Cfg.h:包含了Det模块的相关配置,如下所示。
    /*
    ***********************************************************************************************************************
    * 
    * Product Info
    * Isolar version: ISOLAR-AB 4.0.2
    * Product release version: RTA-BSW 3.1.0
    * 
    ***********************************************************************************************************************
    */
    
    
    /********************************************************************************************************************/
    /*                                                                                                                  */
    /* TOOL-GENERATED SOURCECODE, DO NOT CHANGE                                                                         */
    /*                                                                                                                  */
    /********************************************************************************************************************/
    
    #ifndef DET_CFG_H
    #define DET_CFG_H
    
    #include "Det_Cfg_Version.h"
    /* Configuration status of GetVersionInfo API */
    #define DET_CFG_VERSIONINFO_SUPPORTED       FALSE
    /* Configuration status of Dlt forwarding */
    #define DET_CFG_FORWARDTODLT_SUPPORTED      FALSE
    /* Configuration status of API consistency check */
    #define DET_CFG_CHECK_API_CONSISTENCY       TRUE
    
    /* Configuration status of runtime error callout */
    #define DET_CFG_RUNTIMECALLOUT_SUPPORTED    FALSE
    
    /* Configuration status of transient fault callout */
    #define DET_CFG_TRANSIENTCALLOUT_SUPPORTED  FALSE
    
    /* Configuration status of Error Hooks */
    #define DET_CFG_HOOKCOUNT                   0
    
    /* Configuration status of Error Buffer */
    #define DET_CFG_ERRORBUFFER_ENABLED         TRUE
    #define DET_CFG_ERRORBUFFERAPI_SUPPORTED    FALSE
    #define DET_CFG_ERRORBUFFERSIZE             10
    
    #if (DET_CFG_HOOKCOUNT > 0)
    #define DET_START_SEC_ROM_CODE
    #include "Det_MemMap.h"
    #define DET_STOP_SEC_ROM_CODE
    #include "Det_MemMap.h"
    
    #define DET_CFG_CALLERRORHOOKS(ModuleId, InstanceId, ApiId, ErrorId) \
    do{ \
    }while (0)
    #endif /* #if  (DET_CFG_HOOKCOUNT > 0) */
    
    #endif	/* DET_CFG_H */
    
    
  • Det_Cfg_Version.h:包含了模块的版本信息。
    /*
    ***********************************************************************************************************************
    * 
    * Product Info
    * Isolar version: ISOLAR-AB 4.0.2
    * Product release version: RTA-BSW 3.1.0
    * 
    ***********************************************************************************************************************
    */
    
    
    /********************************************************************************************************************/
    /*                                                                                                                  */
    /* TOOL-GENERATED SOURCECODE, DO NOT CHANGE                                                                         */
    /*                                                                                                                  */
    /********************************************************************************************************************/
    
    #ifndef DET_CFG_VERSION_H
    #define DET_CFG_VERSION_H
    
    /**
     * @ingroup DET_VERSION_H
     *
     * Vendor Id refers to a unique ID assigned by Autosar to every Member of Autosar Consortium, used to indicate the vendor during the call of Det_ReportError()\n
     */
    #define     DET_VENDOR_ID                              6
    #define     DET_MODULE_ID                              15
    #define     DET_INSTANCE_ID                            0
    #define     DET_SW_MAJOR_VERSION                       3
    #define     DET_SW_MINOR_VERSION                       0
    #define     DET_SW_PATCH_VERSION                       0
    #define     DET_AR_RELEASE_MAJOR_VERSION               4
    #define     DET_AR_RELEASE_MINOR_VERSION               2
    #define     DET_AR_RELEASE_REVISION_VERSION            2
    
    #endif  /* DET_VERSION_H */
    
  • Det.c:包含了DET模块Det_Init、Det_Start、Det_ReportError、Det_ReportRuntimeError、Det_ReportTransientFault函数实体实现,下面贴一个Det_ReportError的实现代码,其余的模块主要通过此接口向DET上报错误。
    /*
     **************************************************************************************************
     * Det_ReportError
     * Service to report development errors.
     **************************************************************************************************
     */
    /* MR12 RULE 8.3 VIOLATION: The names of parameters in this function declaration are different from the names in a previous declaration.
     * But this can be ignored, since the parameter names differ in RTE generated files */
    Std_ReturnType Det_ReportError(uint16 ModuleId, uint8 InstanceId, uint8 ApiId, uint8 ErrorId)
    {
        /* Check if DET was initialized, otherwise exit direclty */
        if (!Det_Initialized_b)
        {
            DET_UNUSED_PARAM(ModuleId);
            DET_UNUSED_PARAM(InstanceId);
            DET_UNUSED_PARAM(ApiId);
            DET_UNUSED_PARAM(ErrorId);
        }
        else
        {
    #if (DET_CFG_HOOKCOUNT > 0)
            DET_CFG_CALLERRORHOOKS(ModuleId, InstanceId, ApiId, ErrorId);
    #endif /* #if (DET_CFG_HOOKCOUNT > 0) */
    
    #if (DET_CFG_ERRORBUFFER_ENABLED)
    
            /* Enter Interrupt Lock */
            SchM_Enter_Det_Monitoring();
    
            /* Check if there are free place in Det_ErrorEntryBuffer, then enter the new Development error in the buffer*/
            if (Det_BufferIndex_u16 < (DET_CFG_ERRORBUFFERSIZE))
            {
                Det_ErrorEntryBuffer[Det_BufferIndex_u16].ModuleId = ModuleId;
                Det_ErrorEntryBuffer[Det_BufferIndex_u16].InstanceId = InstanceId;
                Det_ErrorEntryBuffer[Det_BufferIndex_u16].ApiId = ApiId;
                Det_ErrorEntryBuffer[Det_BufferIndex_u16].ErrorId = ErrorId;
    
                Det_BufferIndex_u16++;
            }
            /* Exit Interrupt Lock */
            SchM_Exit_Det_Monitoring();
    #endif /* #if (DET_CFG_ERRORBUFFER_ENABLED) */
    
    #if (DET_CFG_FORWARDTODLT_SUPPORTED)
            Dlt_DetForwardErrorTrace(ModuleId, InstanceId, ApiId, ErrorId);
    #endif /* #if (DET_CFG_FORWARDTODLT_SUPPORTED) */
        }
        return E_OK;
    }

Bfx 

Bfx模块包含的代码结构如下。

  • Bfx_Cfg.h: Bfx模块相关配置信息。可以看到它为了QAC把函数名都用宏定义做了替换。
    /* Patch to speed up the run of QAC tool */
    #if (!defined(__QACDF__) || (defined(__QACDF__) && defined(SRVLIBS)))
    
    /* Inlining **********************************************************************************************************/
    
    #define Bfx_ClrBit_u16u8                         Bfx_Prv_ClrBit_u16u8_Inl
    #define Bfx_ClrBit_u32u8                         Bfx_Prv_ClrBit_u32u8_Inl
    #define Bfx_ClrBit_u8u8                          Bfx_Prv_ClrBit_u8u8_Inl
    #define Bfx_ClrBitMask_u16u16                    Bfx_Prv_ClrBitMask_u16u16_Inl
  • Bfx_Bit.c、Bfx_TstParityEven_u8_u8.c等:里边包含了如果如果Bit操作函数不是采用Inline方式,则在Bfx_Bit_Inl.h定义的inline函数基础上包了一层普通函数定义。
    /*** BFX_CFG_CLRBIT_U16U8_LOCATION ***/
    #if (BFX_CFG_CLRBIT_U16U8_LOCATION != BFX_CFG_LOCATION_INLINE)
        #if (BFX_CFG_CLRBIT_U16U8_LOCATION == BFX_CFG_LOCATION_NORMAL)
            #define BFX_START_SEC_CODE
        #elif (BFX_CFG_CLRBIT_U16U8_LOCATION == BFX_CFG_LOCATION_SLOW)
            #define BFX_START_SEC_CODE_SLOW
        #elif (BFX_CFG_CLRBIT_U16U8_LOCATION == BFX_CFG_LOCATION_FAST)
            #define BFX_START_SEC_CODE_FAST
        #else
            #define BFX_START_SEC_CODE
        #endif
        #include "Bfx_MemMap.h"
    
        void Bfx_ClrBit_u16u8(uint16* Data, uint8 BitPn)
        {
            Bfx_Prv_ClrBit_u16u8_Inl(Data, BitPn);
        }
    
        #if (BFX_CFG_CLRBIT_U16U8_LOCATION == BFX_CFG_LOCATION_NORMAL)
            #define BFX_STOP_SEC_CODE
        #elif (BFX_CFG_CLRBIT_U16U8_LOCATION == BFX_CFG_LOCATION_SLOW)
            #define BFX_STOP_SEC_CODE_SLOW
        #elif (BFX_CFG_CLRBIT_U16U8_LOCATION == BFX_CFG_LOCATION_FAST)
            #define BFX_STOP_SEC_CODE_FAST
        #else
            #define BFX_STOP_SEC_CODE
        #endif
        #include "Bfx_MemMap.h"
    /*** BFX_CFG_CLRBIT_U16U8_LOCATION ***/
    #endif
  • Bfx_Bit_Inl.h:包含了所有Bit操作内联函数的实现。
    /**
     **********************************************************************************************************************
     * Bfx_ClrBit_u16u8
     *
     * \brief Clears a bit in the variable Data to "0". The position of the cleared bit is described by the variable
     * BitPn. A priori, range [0,15] is valid for BitPn. Note, the given position is not monitored.
     *
     * \param   uint16*   Data    pointer to the 16-bit variable, which should be modified.
     * \param   uint8     BitPn   position which bit shall be cleared.
     * \return  void
     **********************************************************************************************************************
     */
    LOCAL_INLINE void Bfx_Prv_ClrBit_u16u8_Inl(uint16* Data, uint8 BitPn)
    {
    /* Additional typecast is required to remove the MISRA 12 warning */
        *Data &= ((uint16)(~(uint16)(1uL << BitPn)));
    }
  • Bfx_Types.h:Bfx用到的定义。
    
    
    #ifndef BFX_TYPES_H
    #define BFX_TYPES_H
    
    
    /*
     **********************************************************************************************************************
     * Hash defines, symbols
     **********************************************************************************************************************
     */
    
    #define BFX_MAXUINT8        (0xff)
    #define BFX_MAXUINT8_U      (0xffu)
    #define BFX_MINUINT8        (0x0)
    #define BFX_MAXSINT8        (0x7f)
    #define BFX_MINSINT8        (-(BFX_MAXSINT8) - 1)
    #define BFX_MAXUINT16       (0xffff)
    #define BFX_MAXUINT16_U     (0xffffu)
    #define BFX_MINUINT16       (0x0)
    #define BFX_MAXSINT16       (0x7fff)
    #define BFX_MINSINT16       (-(BFX_MAXSINT16) - 1)
    #define BFX_MAXUINT32       (0xffffffffL)
    #define BFX_MAXUINT32_U     (0xffffffffuL)
    #define BFX_MINUINT32       (0x0uL)
    #define BFX_MAXSINT32       (0x7fffffffL)
    #define BFX_MAXSINT32_U     (0x7fffffffuL)
    #define BFX_MINSINT32       (-(BFX_MAXSINT32)-1L)
    
    
    
    
    /* BFX_TYPES_H */
    #endif
    
  • Bfx.h:Bfx模块头文件,使用此模块的可以包含这个头文件。
    
    
    
    #ifndef BFX_H
    #define BFX_H
    
    
    /*
     **********************************************************************************************************************
     * Includes
     **********************************************************************************************************************
     */
    #include "Std_Types.h"
    #include "Bfx_Types.h"
    #include "Bfx_Cfg.h"
    
    /* Patch to speed up the run of QAC tool */
    #if (!defined(__QACDF__) || (defined(__QACDF__) && defined(SRVLIBS)))
    
    #include "Bfx_Bit_Inl.h"
    #if ((BFX_CFG_OPTIMIZATION == BFX_CFG_TCCOMMON) || (BFX_CFG_OPTIMIZATION == BFX_CFG_TC27XX))
        #include "rba_BfxTCCommon_Bit_Inl.h"
    #endif
    #if ((BFX_CFG_OPTIMIZATION == BFX_CFG_MPCCOMMON) || (BFX_CFG_OPTIMIZATION == BFX_CFG_MPCCUT2))
        #include "rba_BfxMPCCommon_Bit_Inl.h"
    #endif
    
    #endif
    
    
    /*
     **********************************************************************************************************************
     * Module Version Information
     **********************************************************************************************************************
     */
    #define BFX_MODULE_ID                   205
    #define BFX_VENDOR_ID                   6
    #define BFX_SW_MAJOR_VERSION            3
    #define BFX_SW_MINOR_VERSION            0
    #define BFX_SW_PATCH_VERSION            0
    #define BFX_AR_RELEASE_MAJOR_VERSION    4
    #define BFX_AR_RELEASE_MINOR_VERSION    2
    #define BFX_AR_RELEASE_REVISION_VERSION 2
    
    
    /*
     **********************************************************************************************************************
     * GetVersionInfo
     **********************************************************************************************************************
     */
    #if (BFX_VERSIONINFOAPI == STD_ON)
        #define BFX_START_SEC_CODE
        #include "Bfx_MemMap.h"
        extern void Bfx_GetVersionInfo(Std_VersionInfoType* versionInfo);
        #define BFX_STOP_SEC_CODE
        #include "Bfx_MemMap.h"
    #endif
    
    
    
    
    /* BFX_H */
    #endif
    

CRC 

CRC模块包含的代码结构如下。

  • Crc.c:CRC模块顶层函数实现。
    /*
    ***********************************************************************************************************************
    * 
    * Product Info
    * Isolar version: ISOLAR-AB 4.0.2
    * Product release version: RTA-BSW 3.1.0
    * 
    ***********************************************************************************************************************
    */
    
    
    
    /*
     **********************************************************************************************************************
     * Includes
     **********************************************************************************************************************
     */
    #include "Crc.h"
    
    /*
     ***********************************************************************************************************************
     * Crc common routines
     ***********************************************************************************************************************
     */
    
    #define CRC_START_SEC_CODE
    #include "Crc_MemMap.h"
    void Crc_GetVersionInfo(Std_VersionInfoType * const VersionInfo)
    {
         VersionInfo->vendorID         = ((uint16)CRC_VENDOR_ID);
         VersionInfo->moduleID         = ((uint16)CRC_MODULE_ID);
         VersionInfo->sw_major_version = ((uint8)CRC_SW_MAJOR_VERSION);
         VersionInfo->sw_minor_version = ((uint8)CRC_SW_MINOR_VERSION);
         VersionInfo->sw_patch_version = ((uint8)CRC_SW_PATCH_VERSION);
    }
    #define CRC_STOP_SEC_CODE
    #include "Crc_MemMap.h"
    
    
  •  Crc.h:CRC顶层头文件,使用CRC计算包含它即可,下面以CRC8举例。
    /*
    ***********************************************************************************************************************
    * 
    * Product Info
    * Isolar version: ISOLAR-AB 4.0.2
    * Product release version: RTA-BSW 3.1.0
    * 
    ***********************************************************************************************************************
    */
    
    
    
    #ifndef CRC_H
    #define CRC_H
    
    /*
    **********************************************************************************************************************
    * Includes
    **********************************************************************************************************************
    */
    #include "Std_Types.h"             /* AUTOSAR standard type definitions */
    
    #include "Crc_Cfg.h"               /* Configuration file */
    
    #include "Crc_8.h"                 /* CRC8 implementation */
    #include "Crc_8h2f.h"              /* CRC8H2f implementation */
    #include "Crc_16.h"                /* CRC16 implementation */
    #include "Crc_32.h"                /* CRC32 implementation */
    #include "Crc_32P4.h"                /* CRC32P4 implementation */
    
    /*
    **********************************************************************************************************************
    * Defines/Macros
    **********************************************************************************************************************
    */
    /* Version information parameters */
    #define CRC_VENDOR_ID                   6
    #define CRC_MODULE_ID                   201
    #define CRC_SW_MAJOR_VERSION            2
    #define CRC_SW_MINOR_VERSION            0
    #define CRC_SW_PATCH_VERSION            0
    #define CRC_AR_RELEASE_MAJOR_VERSION    4
    #define CRC_AR_RELEASE_MINOR_VERSION    2
    
    /*
    **********************************************************************************************************************
    * Type definitions
    **********************************************************************************************************************
    */
    
    
    /*
    **********************************************************************************************************************
    * Variables
    **********************************************************************************************************************
    */
    
    
    /*
    **********************************************************************************************************************
    * Extern declarations
    **********************************************************************************************************************
    */
    
    
    /*
     **********************************************************************************************************************
     * Prototypes
     **********************************************************************************************************************
    */
    #define CRC_START_SEC_CODE
    #include "Crc_MemMap.h"
        extern void Crc_GetVersionInfo(Std_VersionInfoType * const VersionInfo);
    #define CRC_STOP_SEC_CODE
    #include "Crc_MemMap.h"
    
    
    
    /* CRC_H */
    #endif
    
    
    

ComStack

ComStack模块包含的代码结构如下。

  • ComStack_Cfg.h: 通信栈用到的类型定义。
    /*
    ***********************************************************************************************************************
    * 
    * Product Info
    * Isolar version: ISOLAR-AB 4.0.2
    * Product release version: RTA-BSW 3.1.0
    * 
    ***********************************************************************************************************************
    */
    
     
    
    /*
    *******************************************************************************************************************
    * Based on AUTOSAR_SWS_CommunicationStackTypes.pdf; AR4.2; Rev 2 and BSW_CodingGuidelines_Cur_v.1.10.pdf
    *******************************************************************************************************************
    */
    
    /* TRACE[SWS_COMTYPE_00016]: protected against multiple inclusion. */
    #ifndef COMSTACK_CFG_H
    #define COMSTACK_CFG_H
    
    /*
    *******************************************************************************************************************
    * Types and Defines
    *******************************************************************************************************************
    */
    
    
    /* TRACE[SWS_COMTYPE_00005], TRACE[SWS_COMTYPE_00029] and TRACE[SWS_COMTYPE_00030]:
      Type of PDU ID. Allowed ranges: uint8/uint16 */
    typedef uint16    PduIdType;
    
    /* TRACE[SWS_COMTYPE_00008], TRACE[SWS_COMTYPE_00029] and TRACE[SWS_COMTYPE_00030]:
      Type of PDU Length. Allowed ranges: uint8/uint16/uint32 */
    typedef uint16    PduLengthType;
    
    #endif /* COMSTACK_CFG_H */
    
    
  • ComStack_Types.h:通信栈相关的宏定义,枚举量,结构体定义。
    /*
    ***********************************************************************************************************************
    * 
    * Product Info
    * Isolar version: ISOLAR-AB 4.0.2
    * Product release version: RTA-BSW 3.1.0
    * 
    ***********************************************************************************************************************
    */
    
     
    
    /*
    *****************************************************************************************************************
    * Based on AUTOSAR_SWS_CommunicationStackTypes.pdf; AR4.2; Rev 2 and BSW_CodingGuidelines_Cur_v.1.10.pdf
    *****************************************************************************************************************
    */
    
    /* TRACE[SWS_COMTYPE_00016]: protected against multiple inclusion. */
    #ifndef COMSTACK_TYPES_H
    #define COMSTACK_TYPES_H
    
    /*
    ******************************************************************************************************************
    * Includes
    ******************************************************************************************************************
    */
    
    /*TRACE[SWS_COMTYPE_00001]: include file structure */
    #include "Std_Types.h"                  /* Standard AUTOSAR types */
    #include "ComStack_Cfg.h"               /* ECU dependent part of ComStack Types */
    
    /*
    *******************************************************************************************************************
    * Types and Defines
    *******************************************************************************************************************
    */
    
    /* TRACE[Rule BSW_VersionInfo_002]: Module Vendor Identifier */
    /* TRACE[SRS_BSW_00374]  */
    #define COMTYPE_VENDOR_ID 0x0006u
    
    /* TRACE[Rule BSW_VersionInfo_003]: Module Identifier  */
    /* TRACE[SRS_BSW_00374]  */
    #define COMTYPE_MODULE_ID 0x00C4u
    
    /* TRACE[Rule BSW_VersionInfo_004]: Software Version Number and AUTOSAR Specification Version Number. */
    /* TRACE[SRS_BSW_00374]  */
    #define COMTYPE_SW_MAJOR_VERSION 0x01u
    #define COMTYPE_SW_MINOR_VERSION 0x00u
    #define COMTYPE_SW_PATCH_VERSION 0x00u
    #define COMTYPE_AR_RELEASE_MAJOR_VERSION 0x04u
    #define COMTYPE_AR_RELEASE_MINOR_VERSION 0x02u
    #define COMTYPE_AR_RELEASE_REVISION_VERSION 0x02u
    
    /* COMTYPE018 - General codes for NotifResultType */
    
    /* NotifResultType related below macros are provided to ensure backward compatibility to AR40,although not applicable
     as per AR422 specifcation. They shall be removed later, when ComStack package adapt to AR422 requirements in
    CommunicationStackTypes*/
    
    
    #define NTFRSLT_OK                     0x00u
    #define NTFRSLT_E_NOT_OK               0x01u
    #define NTFRSLT_E_TIMEOUT_A            0x02u
    #define NTFRSLT_E_TIMEOUT_BS           0x03u
    #define NTFRSLT_E_TIMEOUT_CR           0x04u
    #define NTFRSLT_E_WRONG_SN             0x05u
    #define NTFRSLT_E_INVALID_FS           0x06u
    #define NTFRSLT_E_UNEXP_PDU            0x07u
    #define NTFRSLT_E_WFT_OVRN             0x08u
    #define NTFRSLT_E_ABORT                0x09u
    #define NTFRSLT_E_NO_BUFFER            0x0Au
    #define NTFRSLT_E_CANCELATION_OK       0x0Bu
    #define NTFRSLT_E_CANCELATION_NOT_OK   0x0Cu
    #define NTFRSLT_PARAMETER_OK           0x0Du
    #define NTFRSLT_E_PARAMETER_NOT_OK     0x0Eu
    #define NTFRSLT_E_RX_ON                0x0Fu
    #define NTFRSLT_E_VALUE_NOT_OK         0x10u
    /*TRACE[SWS_COMTYPE_00011]: PduInfoType*/
    typedef struct
    {
        P2VAR(uint8,AUTOMATIC,AUTOSAR_COMSTACKDATA) SduDataPtr;
        PduLengthType SduLength;
    } PduInfoType;
    
    /*TRACE[SWS_COMTYPE_00036]: PNCHandleType used to store the identifier of a partial network cluster.*/
    typedef uint8   PNCHandleType;
    
    /*TRACE[SWS_COMTYPE_00031]: TPParameterType-Specify the parameter to which the value has to be changed (TP_STMIN or TP_BS or TP_BC or BS or TP_BFS).*/
    typedef enum
    {
        TP_STMIN = 0x00,
        TP_BS    = 0x01,
        TP_BC    = 0x02,
        TP_BFS   = 0x03
    } TPParameterType;
    
    /*TRACE[SWS_COMTYPE_00012]: BufReq_ReturnType-Variables*/
    typedef enum
    {
        BUFREQ_OK       = 0x00,
        BUFREQ_E_NOT_OK = 0x01,
        BUFREQ_E_BUSY   = 0x02,
        BUFREQ_E_OVFL   = 0x03
    } BufReq_ReturnType;
    
    /* Chapter 8.1.6: Result status of a notification */
    
    /* NotifResultType is provided to ensure backward compatibility to AR40,although not applicable as per AR422 
    specifcation and shall be removed later, when ComStack package adapt to AR422 requirements in
    CommunicationStackTypes*/
    typedef uint8   NotifResultType;
    
    /*TRACE[SWS_COMTYPE_00020]: Variables of this type shall be used to return the bus status evaluated by a transceiver.*/
    typedef uint8   BusTrcvErrorType;
    
    /*TRACE[SWS_COMTYPE_00021]: General codes for BusTrcvErrorType.*/
    #define BUSTRCV_OK                     0x00
    #define BUSTRCV_E_ERROR                0x01
    
    /*TRACE[SWS_COMTYPE_00027]: TpDataStateType-Variables of this type shall be used to store the state of TP buffer.*/
    typedef enum
    {
        TP_DATACONF = 0x00,
        TP_DATARETRY = 0x01,
        TP_CONFPENDING = 0x02
    } TpDataStateType;
    
    /*TRACE[SWS_COMTYPE_00037]:RetryInfoType-Variables */
    typedef struct
    {
        TpDataStateType TpDataState;
        PduLengthType TxTpDataCnt;
    } RetryInfoType;
    
    /*TRACE[SWS_COMTYPE_00038]:NetworkHandleType-Variables*/
    typedef uint8   NetworkHandleType;
    
    /*TRACE[SWS_COMTYPE_00039]: IcomConfigIdType-IcomConfigIdType defines the configuration ID.*/
    typedef uint8   IcomConfigIdType;
    
    /*TRACE[SWS_COMTYPE_00040]: IcomSwitch_ErrorType-IcomSwitch_ErrorType*/
    typedef enum
    {
        ICOM_SWITCH_E_OK,
        ICOM_SWITCH_E_FAILED
    } IcomSwitch_ErrorType;
    
    #endif /* COMSTACK_TYPES_H */
    
    


十六宿舍 原创作品,转载必须标注原文链接。

©2023 Yang Li. All rights reserved.

欢迎关注 『十六宿舍』,大家喜欢的话,给个👍,更多关于嵌入式相关技术的内容持续更新中。