⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 encregdrv5.c

📁 freescale i.mx31 BSP CE5.0全部源码
💻 C
字号:
/*------------------------------------------------------------------------------
--                                                                            --
--       This software is confidential and proprietary and may be used        --
--        only as expressly authorized by a licensing agreement from          --
--                                                                            --
--                            Hantro Products Oy.                             --
--                                                                            --
--      In the event of publication, the following notice is applicable:      --
--                                                                            --
--                   (C) COPYRIGHT 2003 HANTRO PRODUCTS OY                    --
--                            ALL RIGHTS RESERVED                             --
--                                                                            --
--          The entire notice above must be reproduced on all copies.         --
--                                                                            --
--------------------------------------------------------------------------------
--
--  Abstract : Encoder HW register access functions
--
-------------------------------------------------------------------------------*/

#include "ewl.h"
#include "basetype.h"
#include "encregdrv.h"
#include "EncSim.h"
/* 1. (AMBAIFE) Encoder Register Offsets   */

#define ENCREG(nr)	(nr<<2)

/* 2. Mask fields */

#define mask_14b         (u32)0x00003FFF

/* 3. Encoder register access drivers */

/******************************************************************************/
/********************** ENCODER REGISTER (BASE + 0x70) ************************/
/******************************************************************************/

/*******************************************************************************
 Function name   : SetEncBitError1
 Description     : Set the bit error level 1
 Return type     : void
 Argument        : i32 bytes
*******************************************************************************/
void SetEncBitError1(i32 bytes)
{
    u32 val;

    ASSERT(bytes >= -8192 && bytes <= 8191);

    val = EWL_ReadReg(0x70);
    val = (val & ~(mask_14b << 14)) | ((bytes & mask_14b) << 14);
    EWL_WriteReg(0x70, val);
}

/*******************************************************************************
 Function name   : GetEncBitError1
 Description     : Get the bit error level 1
 Return type     : i32 
*******************************************************************************/
i32 GetEncBitError1()
{
    u32 val;

    val = EWL_ReadReg(0x70);
    val = val >> 14;

    if(val > 8191)
        return (i32) (((~0) << 14) | val);  /* negative number */
    else
        return (i32) val;   /* positive number */
}

/*******************************************************************************
 Function name   : SetEncBitError2
 Description     : Set the bit error level 2
 Return type     : void
 Argument        : i32 bytes
*******************************************************************************/
void SetEncBitError2(i32 bytes)
{
    u32 val;

    ASSERT(bytes >= -8192 && bytes <= 8191);

    val = EWL_ReadReg(0x70);
    val = (val & (~mask_14b)) | ((bytes & mask_14b));
    EWL_WriteReg(0x70, val);
}

/*******************************************************************************
 Function name   : GetEncBitError2
 Description     : Get the bit error level 2
 Return type     : i32 
*******************************************************************************/
i32 GetEncBitError2()
{
    u32 val;

    val = EWL_ReadReg(0x70);
    val = (mask_14b & val);

    if(val > 8191)
        return (i32) (((~0) << 14) | val);  /* negative number */
    else
        return (i32) val;   /* positive number */
}

/******************************************************************************/
/********************** ENCODER REGISTER (BASE + 0x74) ************************/
/******************************************************************************/

/*******************************************************************************
 Function name   : SetEncBitError3
 Description     : Set the bit error level 3
 Return type     : void
 Argument        : i32 bytes
*******************************************************************************/
void SetEncBitError3(i32 bytes)
{
    u32 val;

    ASSERT(bytes >= -8192 && bytes <= 8191);

    val = EWL_ReadReg(0x74);
    val = (val & ~(mask_14b << 14)) | ((bytes & mask_14b) << 14);
    EWL_WriteReg(0x74, val);
}

/*******************************************************************************
 Function name   : GetEncBitError3
 Description     : Get the bit error level 3
 Return type     : i32 
*******************************************************************************/
i32 GetEncBitError3()
{
    u32 val;

    val = EWL_ReadReg(0x74);
    val = (val >> 14);

    if(val > 8191)
        return (i32) (((~0) << 14) | val);  /* negative number */
    else
        return (i32) val;   /* positive number */
}

/*******************************************************************************
 Function name   : SetEncBitError4
 Description     : Set the bit error level 4
 Return type     : void
 Argument        : i32 bytes
*******************************************************************************/
void SetEncBitError4(i32 bytes)
{
    u32 val;

    ASSERT(bytes >= -8192 && bytes <= 8191);

    val = EWL_ReadReg(0x74);
    val = (val & ~(mask_14b)) | ((bytes & mask_14b));
    EWL_WriteReg(0x74, val);
}

/*******************************************************************************
 Function name   : GetEncBitError4
 Description     : Get the bit error level 4
 Return type     : i32 
*******************************************************************************/
i32 GetEncBitError4()
{
    u32 val;

    val = EWL_ReadReg(0x74);
    val = (mask_14b & val);

    if(val > 8191)
        return (i32) (((~0) << 14) | val);  /* negative number */
    else
        return (i32) val;   /* positive number */
}

/******************************************************************************/
/********************** ENCODER REGISTER (BASE + 0x78) ************************/
/******************************************************************************/

/*******************************************************************************
 Function name   : SetEncBitError5
 Description     : Set the bit error level 5
 Return type     : void
 Argument        : i32 bytes
*******************************************************************************/
void SetEncBitError5(i32 bytes)
{
    u32 val;

    ASSERT(bytes >= -8192 && bytes <= 8191);

    val = EWL_ReadReg(0x78);
    val = (val & ~(mask_14b << 14)) | ((bytes & mask_14b) << 14);
    EWL_WriteReg(0x78, val);
}

/*******************************************************************************
 Function name   : GetEncBitError5
 Description     : Get the bit error level 5
 Return type     : i32 
*******************************************************************************/
i32 GetEncBitError5()
{
    u32 val;

    val = EWL_ReadReg(0x78);
    val = (val >> 14);

    if(val > 8191)
        return (i32) (((~0) << 14) | val);  /* negative number */
    else
        return (i32) val;   /* positive number */
}

/*******************************************************************************
 Function name   : SetEncBitError6
 Description     : Set the bit error level 6
 Return type     : void
 Argument        : i32 bytes
*******************************************************************************/
void SetEncBitError6(i32 bytes)
{
    u32 val;

    ASSERT(bytes >= -8192 && bytes <= 8191);

    val = EWL_ReadReg(0x78);
    val = (val & ~(mask_14b)) | ((bytes & mask_14b));
    EWL_WriteReg(0x78, val);
}

/*******************************************************************************
 Function name   : GetEncBitError6
 Description     : Get the bit error level 6
 Return type     : i32 
*******************************************************************************/
i32 GetEncBitError6()
{
    u32 val;

    val = EWL_ReadReg(0x78);
    val = (mask_14b & (val));

    if(val > 8191)
        return (i32) (((~0) << 14) | val);  /* negative number */
    else
        return (i32) val;   /* positive number */
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -