/* Set Baud Rate of FlexCAN. 
This function set the baud rate of FlexCAN. */
static void FLEXCAN_SetBaudRate(CAN_Type *base, uint32_t sourceClock_Hz, uint32_t baudRate_Bps, flexcan_timing_config_t timingConfig)
/* Set Baud Rate of FlexCAN. 
This function set the baud rate of FlexCAN. */
static void FLEXCAN_SetBaudRate(CAN_Type *base, uint32_t sourceClock_Hz, uint32_t baudRate_Bps, flexcan_timing_config_t timingConfig)
{
    uint32_t quantum = (1U + ((uint32_t)timingConfig.phaseSeg1 + 1U) + ((uint32_t)timingConfig.phaseSeg2 + 1U) +
                        ((uint32_t)timingConfig.propSeg + 1U));
    uint32_t priDiv  = baudRate_Bps * quantum;
    assert(baudRate_Bps <= 1000000U);
    assert(priDiv <= sourceClock_Hz);
    if (0U == priDiv)
    {
        priDiv = 1;
    }
    priDiv = (sourceClock_Hz / priDiv) - 1U;
    if (priDiv > 0xFFU)
    {
        priDiv = 0xFF;
    }
    timingConfig.preDivider = (uint16_t)priDiv;
    FLEXCAN_SetTimingConfig(base, (const flexcan_timing_config_t *)(uint32_t)&timingConfig);
}