LP-MSPM0G3519: undeclared identifier 'CAN_UNINIT' and 'CAN_READY'

Part Number: LP-MSPM0G3519

Tool/software:

Hello team,

we are using MCAL : MCAL_MSPM0_00.02.04.00 package

SDK : mspm0_sdk_2_04_00_06 version

While integrating Can module, below compilation error is occured

Error:

C:/work/ACP-9.3.2_MSPM0GX51X_ticgt-4.0.0_LTS_BasicTemplate/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:181:41: error: use of undeclared identifier 'CAN_UNINIT

C:/work/ACP-9.3.2_MSPM0GX51X_ticgt-4.0.0_LTS_BasicTemplate/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:790:24: error: use of undeclared identifier 'CAN_READY'

Reason:   

Although the states CAN_UNINIT and CAN_READY are already defined in Can_GeneralTypes.h, as per the AUTOSAR standard, such states should be handled internally by the driver.

BR,

Prashant Singh Tomar

  • Hi Prashant,

    Thanks for your feedback and sorry for the late response.

    As for the compile error, I tested with the CanApp example in the MCAL package, but not find this error. As you said, the CAN_UNINIT and CAN_READY is defined in Can_GeneralTypes.h, which is further included in the can.h file. If you keep these header file as same, I think this macro undeclared error should not occur.

    Could you please share more information about your problem background? Thanks.

    Best Regards,

    Pengfei

  • Hi Pengfei

    If we include Can_GeneralTypes.h, we get a lot of errors related to redefinition. Please check the error log below.  

    compiling: Can.c
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:65:16: error: typedef redefinition with different types
          ('uint16' (aka 'unsigned short') vs 'uint8' (aka 'unsigned char'))
       65 | typedef uint16 Can_HwHandleType;
          |                ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/test_base/Compile/IN/Can_ComTest_1/output/generated/include\Can_GeneralTypes_Cfg.h:48:15: note: previous definition is here
       48 | typedef uint8 Can_HwHandleType;
          |               ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:72:5: error: redefinition of enumerator 'CAN_CS_UNINIT'
       72 |     CAN_CS_UNINIT,  /**< CAN Controller is not yet configured.
          |     ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:123:3: note: previous definition is here
      123 |   CAN_CS_UNINIT = 0x00,  /**< CAN controller state UNINIT */
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:74:5: error: redefinition of enumerator 'CAN_CS_STARTED'
       74 |     CAN_CS_STARTED, /**< CAN controller transition value to request state STARTED.
          |     ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:124:3: note: previous definition is here
      124 |   CAN_CS_STARTED,        /**< CAN controller state STARTED */
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:76:5: error: redefinition of enumerator 'CAN_CS_STOPPED'
       76 |     CAN_CS_STOPPED,  /**< CAN controller transition value to request state STOPPED.
          |     ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:125:3: note: previous definition is here
      125 |   CAN_CS_STOPPED,        /**< CAN controller state STOPPED */
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:78:5: error: redefinition of enumerator 'CAN_CS_SLEEP'
       78 |     CAN_CS_SLEEP /**< CAN controller transition value to request state SLEEP. */
          |     ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:126:3: note: previous definition is here
      126 |   CAN_CS_SLEEP           /**< CAN controller state SLEEP */
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:79:3: error: typedef redefinition with different types
          ('enum Can_ControllerStateType' vs 'enum Can_ControllerStateType')
       79 | } Can_ControllerStateType;
          |   ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:127:3: note: previous definition is here
      127 | } Can_ControllerStateType;
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:91:5: error: redefinition of enumerator 'CAN_BUSY'
       91 |     CAN_BUSY = 0x02U
          |     ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:86:3: note: previous definition is here
       86 |   CAN_BUSY      /**< Transmit request could not be processed because no transmit object was
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:94:3: error: typedef redefinition with different types
          ('enum Can_ReturnType' vs 'enum Can_ReturnType')
       94 | } Can_ReturnType;
          |   ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:88:3: note: previous definition is here
       88 | } Can_ReturnType;
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:100:3: error: redefinition of enumerator 'CAN_ERRORSTATE_ACTIVE'
      100 |   CAN_ERRORSTATE_ACTIVE,
          |   ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:94:3: note: previous definition is here
       94 |   CAN_ERRORSTATE_ACTIVE,    /**< The CAN controller takes fully part in communication. */
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:102:3: error: redefinition of enumerator 'CAN_ERRORSTATE_PASSIVE'
      102 |   CAN_ERRORSTATE_PASSIVE,
          |   ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:95:3: note: previous definition is here
       95 |   CAN_ERRORSTATE_PASSIVE,   /**< The CAN controller takes  part in communication, but does not send active error frames. */
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:105:3: error: redefinition of enumerator 'CAN_ERRORSTATE_BUSOFF'
      105 |   CAN_ERRORSTATE_BUSOFF,
          |   ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:96:3: note: previous definition is here
       96 |   CAN_ERRORSTATE_BUSOFF     /**<  The CAN controller does not take part in communication. */
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:107:3: error: typedef redefinition with different types
          ('enum Can_ErrorStateType' vs 'enum Can_ErrorStateType')
      107 | } Can_ErrorStateType;
          |   ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:97:3: note: previous definition is here
       97 | } Can_ErrorStateType;
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:120:3: error: typedef redefinition with different types
          ('struct Can_PduType_s' vs 'struct Can_PduType')
      120 | } Can_PduType;
          |   ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:45:3: note: previous definition is here
       45 | } Can_PduType;
          |   ^
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/src/Can.c:67:
    In file included from C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can.h:100:
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/McalExt_TS_T47DxM1I0R0/MCAL_Delivery/mcal/Can/include\Can_GeneralTypes.h:131:2: error: typedef redefinition with different types
          ('struct Can_HwType' vs 'struct Can_HwType')
      131 | }Can_HwType;
          |  ^
    C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Base_TS_TxDxM5I6R0/include\Can_GeneralTypes.h:66:3: note: previous definition is here
       66 | } Can_HwType;
          |   ^
    14 errors generated.
    make: *** [C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/Tresos/plugins/Make_TS_TxDxM4I2R0/make/Make_rules.mak:324: C:/work/ACL-9.4.0_MSPM0GX51X_ticgt-4.0.0_LTS/test_base/Compile/IN/Can_ComTest_1/output/obj/Can.o] Error 1

    The states CAN_UNINIT and CAN_READY should be handled internally by the driver.

    BR,

    Prashant Singh Tomar

  • Hi Prashant,

    Sorry I may not state clearly. I did not let you to include the Can_GeneralTypes.h in your main program, actually this header file is included in Can.h file, and you could directly include Can.h in your main program.  

    You could refer to CanApp.c example in path of \mcal\examples\Can\soc\MSPM0G351x\m0plus\CanApp.c.

    Best Regards,

    Pengfei

  • Hi Pengfei Xie,

    Sorry for the late reply. What I meant to say is that, according to the AUTOSAR standard, the Can_GeneralTypes.h file should be included from the AUTOSAR Base Module, not from the vendor implementation. Therefore, the states CAN_UNINIT and CAN_READY, which are already defined in Can_GeneralTypes.h, should be referenced in either Can.h or any common header file included within the CAN driver implementation.

    BR,
    Prashant Singh Tomar