Incorrect Definition of Enumerator “en_mfs_mode” in PDL 2.1.0 - KBA229085

Version 2

    Author: TakashiM_61         Version: **

     

    The enumerator “en_mfs_mode” in PDL 2.1.0 is defined as following.

    <PDL installation directory>\drivers\mfs\mfs.h

    /// MFS mode

    typedef enum en_mfs_mode

    {

        MfsInitMode = 0u,    ///< MFS initial mode

        MfsUartMode = 1u,    ///< MFS UART mode

        MfsCsioMode = 2u,    ///< MFS CSIO mode

        MfsI2cMode = 3u,    ///< MFS I2C mode

        MfsLinMode = 4u,    ///< MFS LIN mode

     

    }en_mfs_mode_t;

     

    however, according to the FM0+ Family Peripheral Manual Communication Macro Part (Doc. No. 002-05024 Rev. *C), I2C mode is “4” and LIN mode is “3”.

    Therefore, the definition of enumerator “en_mfs_mode” in PDL 2.1.0 is incorrect; the correct definition of enumerator “en_mfs_mode” is as follows:

    /// MFS mode

    typedef enum en_mfs_mode

    {

        MfsInitMode = 0u,    ///< MFS initial mode

        MfsUartMode = 1u,    ///< MFS UART mode

        MfsCsioMode = 2u,    ///< MFS CSIO mode

        MfsLinMode = 3u,    ///< MFS LIN mode

        MfsI2cMode = 4u,    ///< MFS I2C mode

     

    }en_mfs_mode_t;

     

    Additionally, the interface mode in MFS driver is hardcoded with a number, instead of using the enumerator “en_mfs_mode”. The definition of enumerator “en_mfs_mode” must be used in MFS driver in order to avoid any ambiguity.

    In the following code snippet of mfs.c in PDL 2.1.0, the lines in red indicates hard coding and the lines in blue indicates that the enumerator “en_mfs_mode” is used.

     

    --- mfs.c.org   2017-12-23 01:29:26.000000000 +0900

    +++ mfs.c       2019-11-25 15:07:50.429769700 +0900

    @@ -1025,10 +1025,10 @@

    switch (pstcConfig->enMode)

    {

    case UartNormal:

    -            stcSMR.MD = 0u;   /* Normal mode */

    +            stcSMR.MD = MfsInitMode;   /* Normal mode */

                 break;

    case UartMulti:

    -            stcSMR.MD = 1u;    /* Multi-processor mode */

    +            stcSMR.MD = MfsUartMode;   /* Multi-processor mode */

                 break;

    default:

                 return (ErrorInvalidParameter);

    @@ -2011,7 +2011,7 @@

    pstcMfsInternData->enMode = MfsCsioMode;

     

    /* Set CSIO mode */

    -    stcSMR.MD = 2u;

    +    stcSMR.MD = MfsCsioMode;

     

    /* Set master/slave mode */

    switch(pstcConfig->enMsMode)

    @@ -3372,7 +3372,7 @@

    {

    case I2cMaster:

    case I2cSlave:

    -            stcSMR.MD = 4u;

    +            stcSMR.MD = MfsLinMode;

                 break;

    default:

                 return (ErrorInvalidParameter);

    @@ -4424,7 +4424,7 @@

    pstcLin->SCR_f.UPCL = TRUE;

     

    /* Set LIN mode to HW and preset variable */

    -    stcSMR.MD = 3u;

    +    stcSMR.MD = MfsI2cMode;

     

    /* Enable serial output */

    stcSMR.SOE = TRUE;