标签:pre related select ptr ready nal 个数 gis pos
G:\controlSUITE\device_support\F2837xD\v180\F2837xD_examples_Cpu1\emif1_16bit_asram\cpu01\emif1_16bit_asram.c 2016年11月22日 20:35
//--------------------------------------------------------------------------------------------
-
//DSP28377 利用EMIF控制网口DM9000芯片收发数据
//--------------------------------------------------------------------------------------------
-
#include "F28x_Project.h" // Device Headerfile and Examples Include File
void Emif1Initialize(void);
//emif 映射地址
#define ASRAM_CS3_START_ADDR 0x37FFF0
#define ASRAM_CS3_SIZE 0x8000
extern void setup_emif1_pinmux_async_16bit(Uint16);
//地址指定;通过操作指针实现地址对应数据操作
Uint16 *ADDR_POINT = (Uint16 *)(ASRAM_CS3_START_ADDR);
Uint16 *DATA_POINT = (Uint16 *)(ASRAM_CS3_START_ADDR + 1);
#define EMIF1 0
//##########DM9000 SETING ######################
#define DM_NCR 0X00
#define DM_NSR 0X01
#define DM_TCR 0X02
#define DM_RCR 0X05
#define DM_BPTR 0X08
#define DM_FCTR 0X09
#define DM_RTFCR 0X0A
#define DM_EPCR 0X0B
#define DM_EPAR 0X0C
#define DM_EPDRL 0X0D
#define DM_EPDRH 0X0E
#define DM_PAB0 0X10
#define DM_PAB1 0X11
#define DM_PAB2 0X12
#define DM_PAB3 0X13
#define DM_PAB4 0X14
#define DM_PAB5 0X15
#define DM_GPCR 0X1E
#define DM_GPR 0X1F
#define DM_SMCR 0X2F
#define DM_MRCMDX 0XF0
#define DM_MRCMD 0XF2
#define DM_MWCMD 0XF8
#define DM_TXPLH 0XFD
#define DM_TXPLL 0XFC
#define DM_ISR 0XFE
#define DM_IMR 0XFF
#define PHY_BADDR 0X40
#define PHY_WCMD 0X0A
#define PHY_RCMD 0X0C
Uint16 NODE_ADDR[6] = {0X5A , 0X5A , 0X5A , 0X5A , 0X5A , 0X5A};
Uint16 databuffer[540];
Uint16 buffersize = 520;
//---------------------------------------------------------------------
// 向DM9000内部寄存器写值
void iow(Uint16 IOADDR , Uint16 REGDARA){
*ADDR_POINT = IOADDR;
DELAY_US(20);
*DATA_POINT = REGDARA;
-1-
G:\controlSUITE\device_support\F2837xD\v180\F2837xD_examples_Cpu1\emif1_16bit_asram\cpu01\emif1_16bit_asram.c 2016年11月22日 20:35
DELAY_US(20);
}
//---------------------------------------------------------------------
// 读取DM9000内部寄存器的值
Uint16 ior(Uint16 IOADDR){
DELAY_US(20);
*ADDR_POINT = IOADDR;
DELAY_US(20);
return(*DATA_POINT);
}
//---------------------------------------------------------------------
// 往固定地址写值
void outw(Uint16 REGDATA , Uint16 addr_data_type){
if(addr_data_type == 1) *DATA_POINT = REGDATA;
else if(addr_data_type == 2) *ADDR_POINT = REGDATA;
DELAY_US(50);
}
//---------------------------------------------------------------------
//读取寄存器的值
Uint16 inw(){
return *DATA_POINT;
}
//---------------------------------------------------------------------
//写物理接口PHY寄存器的值
void phy_write(Uint16 offset , Uint16 REGIN){
iow(DM_EPAR , (offset | PHY_BADDR));
iow(DM_EPDRH , (REGIN >> 8) & 0x00ff);
iow(DM_EPDRL , (REGIN & 0x00ff));
iow(DM_EPCR , PHY_WCMD);
while((ior(DM_EPCR) & 1));
DELAY_US(200);
iow(DM_EPCR , 0x08);
}
//---------------------------------------------------------------------
//读物理接口PHY寄存器的值
Uint16 phy_reaad(Uint16 offset , Uint16 REGIN){
Uint16 returndata=