📄 em9010.c
字号:
/*
* Copyright (c) 1999 by TriMedia Technologies.
*
* +------------------------------------------------------------------+
* | This software is furnished under a license and may only be used |
* | and copied in accordance with the terms and conditions of such |
* | a license and with the inclusion of this copyright notice. This |
* | software or any other copies of this software may not be provided|
* | or otherwise made available to any other person. The ownership |
* | and title of this software is not transferred. |
* | |
* | The information in this software is subject to change without |
* | any prior notice and should not be construed as a commitment by |
* | TriMedia Technologies. |
* | |
* | this code and information is provided "as is" without any |
* | warranty of any kind, either expressed or implied, including but |
* | not limited to the implied warranties of merchantability and/or |
* | fitness for any particular purpose. |
* +------------------------------------------------------------------+
*
* Module name : em9010.c 1.2
*
* Last update : 18:43:40 - 00/11/09
*/
#include "em9010.h"
#include "xioReg.h"
/* -------------------------- STATIC ROUTINES ----------------------------- */
static void em9010WriteBit(pem9010Param_t param, UInt8 BitVal);
static UInt8 em9010ReadBit(pem9010Param_t param);
static void em9010WriteByte(pem9010Param_t param, UInt8 Data);
static UInt8 em9010ReadByte(pem9010Param_t param);
static void em9010WriteBit(pem9010Param_t param, UInt8 BitVal)
{
UInt32 reg = param->regWrite;
UInt8 clk = param->clk;
UInt8 data = param->sdaW;
UInt8 dataEn = param->sdaWEn;
xioRegWriteBit(reg, clk, False);
xioRegWriteBit(reg, dataEn, False);
if(BitVal)
{
xioRegWriteBit(reg, data, True);
}
else
{
xioRegWriteBit(reg, data, False);
}
/*
DELAY MAY BE REQUIRED HERE
This delay will be setup time required for data
*/
xioRegWriteBit(reg, clk, True);
/*
Add delay here if the is hold time requirement on this bus
*/
xioRegWriteBit(reg, dataEn, True);
/*
Add delay here if there are recovery time requirements for the bus
*/
}
static UInt8 em9010ReadBit(pem9010Param_t param)
{
UInt8 dataByte;
UInt32 reg = param->regWrite;
UInt8 clk = param->clk;
UInt8 data = param->sdaW;
UInt8 dataEn = param->sdaWEn;
UInt32 regRead = param->regRead;
UInt32 dataRead = param->sdaR;
/* Assert clock and Disable Write Enable dont care about data */
xioRegWriteBit(reg, clk, False);
xioRegWriteBit(reg, dataEn, True);
xioRegWriteBit(reg, data, True);
/*
DELAY MAY BE REQUIRED HERE
This delay will be setup time required for data
*/
xioRegReadByte(regRead, &dataByte);
xioRegWriteBit(reg, clk, True);
/*
Add delay here if there are recovery time requirements for the bus
*/
if (dataByte & dataRead)
return 1;
else
return 0;
}
static void em9010WriteByte(pem9010Param_t param, UInt8 Data)
{
UInt8 BitNum;
for(BitNum=0; BitNum<8; BitNum++)
{
em9010WriteBit(param, (Data>>(7-BitNum))&0x01);
}
}
static UInt8 em9010ReadByte(pem9010Param_t param)
{
UInt8 Data,BitNum;
Data =0;
for(BitNum = 0; BitNum < 8; BitNum++)
{
Data = (Data << 1) | em9010ReadBit(param);
}
return Data;
}
/*------------------------- INTERFACE ROUTINES ---------------------*/
extern tmLibdevErr_t em9010Init(pem9010Param_t param)
{
UInt32 reg = param->regWrite;
UInt8 clk = param->clk;
UInt8 data = param->sdaW;
UInt8 dataEn = param->sdaWEn;
xioRegWriteBit(reg, clk, True);
xioRegWriteBit(reg, dataEn, True);
xioRegWriteBit(reg, data, True);
return TMLIBDEV_OK;
}
extern tmLibdevErr_t em9010WriteReg(pem9010Param_t param, UInt8 Addr, UInt8 Data)
{
em9010WriteBit(param, 0x01); /* Start on Sigma Serial Interface */
em9010WriteByte(param, 0x01); /* Main Address for NOVA is 0x01 */
em9010WriteBit(param, 0x01); /* Write Cycle */
em9010WriteByte(param, Addr); /* SubAddress in NOVA */
em9010WriteBit(param, 0x00 ); /* No Address Increment */
em9010WriteByte(param, Data); /* Write Data */
em9010WriteBit(param, 0x01 ); /* Cycle End */
return TMLIBDEV_OK;
}
extern tmLibdevErr_t em9010ReadReg(pem9010Param_t param, UInt8 Addr, UInt8 * Data)
{
em9010WriteBit(param, 0x01); /* Start on Sigma Serial Interface */
em9010WriteByte(param, 0x01); /* Main Address for NOVA is 0x01 */
em9010WriteBit(param, 0x00); /* Write Cycle */
em9010WriteByte(param, Addr); /* SubAddress in NOVA */
em9010WriteBit(param, 0x00); /* No Address Increment */
* Data = em9010ReadByte(param); /* Write Data */
em9010WriteBit(param, 0x01); /* Cycle End */
return TMLIBDEV_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -