/* Specifies work mode for the specified CAN unit.  */
static void CAN_SetWorkMode(CM_CAN_TypeDef *CANx, uint8_t u8WorkMode)
/* Specifies work mode for the specified CAN unit.  */
static void CAN_SetWorkMode(CM_CAN_TypeDef *CANx, uint8_t u8WorkMode)
{
    uint8_t u8CFGSTAT = 0U;
    uint8_t u8TCMD    = 0U;
    switch (u8WorkMode) {
        case CAN_WORK_MD_SILENT:
            u8TCMD    = CAN_TCMD_LOM;
            break;
        case CAN_WORK_MD_ILB:
            u8CFGSTAT = CAN_CFG_STAT_LBMI;
            break;
        case CAN_WORK_MD_ELB:
            u8CFGSTAT = CAN_CFG_STAT_LBME;
            break;
        case CAN_WORK_MD_ELB_SILENT:
            u8TCMD    = CAN_TCMD_LOM;
            u8CFGSTAT = CAN_CFG_STAT_LBME;
            break;
        case CAN_WORK_MD_NORMAL:
        default:
            break;
    }
    MODIFY_REG8(CANx->CFG_STAT, CAN_CFG_STAT_LBMI | CAN_CFG_STAT_LBME, u8CFGSTAT);
    MODIFY_REG8(CANx->TCMD, CAN_TCMD_LOM, u8TCMD);
}