📄 eth_ctl.c
字号:
SpeLinDupMode.w32 = *(UINT32 *) ETH_MAC_REG(4); SpeLinDupMode.bits.link_stat = 0; *(UINT32 *) ETH_MAC_REG(4) = SpeLinDupMode.w32; /*clear the input queue frame*/ *(UINT32 *) ETH_MAC_REG(10) = 0; *(UINT32 *) ETH_MAC_REG(10) = 1; *(UINT32 *) ETH_MAC_REG(10) = 0; /*set the queue length*/ SetFrameQueue.w32 = *(UINT32 *) ETH_GLB_REG(6); SetFrameQueue.bits.iq_len = u32InputLength; SetFrameQueue.bits.eq_len = u32OutputLength; *(UINT32 *) ETH_GLB_REG(6) = SetFrameQueue.w32; return 1;}/*======================================================================= * 函数名称:UINT32 ETH_SetPauseFrameLimitLevel (In UINT32 u32EnablePauseUpLimit, In UINT32 u32DisablePauseDownLimit) * 初稿完成:2005/1/6 * 作 者: * 函数功能:设置队列流控上限和解除流控下限,均<=32 * 输入参数: * 输出参数: * 返回类型: return 0->set fail; return 1->set success. * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/UINT32 ETH_SetPauseFrameLimitLevel (In UINT32 u32EnablePauseUpLimit, In UINT32 u32DisablePauseDownLimit){ Set_PauseFrameLimitLevel_U SetPauseFrameLimitLevel; if ((u32EnablePauseUpLimit > 32) || (u32DisablePauseDownLimit > 32)) { return 0; } SetPauseFrameLimitLevel.w32 = *(UINT32 *) ETH_GLB_REG(7); SetPauseFrameLimitLevel.bits.qlimit_up = u32EnablePauseUpLimit; SetPauseFrameLimitLevel.bits.qlimit_down = u32DisablePauseDownLimit; *(UINT32 *) ETH_GLB_REG(7) = SetPauseFrameLimitLevel.w32; return 1;}/*======================================================================= * 函数名称:void ETH_ClearFrameQueue (In UINT32 u32CPUCleQue) * 初稿完成:2005/1/8 * 作 者: * 函数功能:CPU清空输出队列控制 * 输入参数:CPU清空队列控制信息,1-clear * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_ClearFrameQueue (In UINT32 u32CPUCleQue) { CPU_ClearQueue_U SetCPUCleQue; SetCPUCleQue.w32 = *(UINT32 *) ETH_GLB_REG(10); SetCPUCleQue.bits.Flush_in = u32CPUCleQue; *(UINT32 *) ETH_GLB_REG(10) = SetCPUCleQue.w32;}/*======================================================================= * 函数名称:void ETH_ClearFrameQueue (In UINT32 u32CPUCleQue) * 初稿完成:2005/1/8 * 作 者: * 函数功能:设置输入输出队列起始地址,高21位有效,低11位无效 * 输入参数: * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_SetQueueAddress (In UINT32 u32InputQueueAddr,In UINT32 u32OutputQueueAddr) { *(UINT32 *) ETH_GLB_REG(14) = u32InputQueueAddr & 0xFFFFF800; *(UINT32 *) ETH_GLB_REG(15) = u32OutputQueueAddr & 0xFFFFF800;}/*======================================================================= * 函数名称:void ETH_SetRetryTimes (In UINT32 u32RetryTimes) * 初稿完成:2005/1/8 * 作 者: * 函数功能:设置帧重传的次数上限,达到这个上限的时候,如果中断使能的时候会产生中断 * 输入参数: * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_SetRetryTimes (In UINT32 u32RetryTimes) { Frame_RetryTimes_U SetRetryTimes; SetRetryTimes.w32 = *(UINT32 *) ETH_GLB_REG(16); SetRetryTimes.bits.retry_time = u32RetryTimes; *(UINT32 *) ETH_GLB_REG(16) = SetRetryTimes.w32;}/*======================================================================= * 函数名称:void ETH_ReadQueueUseLength (Out UINT32 *pu32InputQueue,Out UINT32 *pu32OutputQueue) * 初稿完成:2005/1/8 * 作 者: * 函数功能:读取输出输入队列使用长度 * 输入参数: * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_ReadQueueUseLength (Out UINT32 *pu32InputQueue,Out UINT32 *pu32OutputQueue) { Queue_UseLength_U ReadQueueLength; ReadQueueLength.w32 = *(UINT32 *) ETH_GLB_REG(18); *pu32OutputQueue = ReadQueueLength.bits.eq_cnt; *pu32InputQueue = ReadQueueLength.bits.iq_cnt;}/*======================================================================= * 函数名称:void ETH_StatisticFiltFrameNumber (Out UINT32 *pu32FiltFrameCnt) * 初稿完成:2005/1/8 * 作 者: * 函数功能:统计过滤帧计数 * 输入参数: * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_StatisticFiltFrameNumber (Out UINT32 *pu32FiltFrameCnt) { *pu32FiltFrameCnt = *(UINT32 *) ETH_GLB_REG(19);}/*=======================================================================* MAC REG**=======================================================================*//*======================================================================= * 函数名称:void ETH_SetFrameConfiguration (In UINT32 u32PreCodNo, In UINT32 u32FraCle, In UINT32 u32StrFraDist) * 初稿完成:2005/1/8 * 作 者: * 函数功能:设置连续检测到帧前导码个数 * 设置帧间隙值 * 设置输出流控帧间隔参数 * 输入参数:u32PreCodNo->帧前导码个数 * u32FraCle->帧间隙值 * u32StrFraDist->流控帧间隔参数 * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_SetFrameConfiguration (In UINT32 u32PreCodNo, In UINT32 u32FraCle, In UINT32 u32StrFraDist){ Frame_Para_U SetFrameConfig; SetFrameConfig.w32 = *(UINT32 *) ETH_MAC_REG(0); SetFrameConfig.bits.ipg = u32FraCle; SetFrameConfig.bits.pre_cnt_limit = u32PreCodNo; SetFrameConfig.bits.para = u32StrFraDist; *(UINT32 *) ETH_MAC_REG(0) = SetFrameConfig.w32;}/*======================================================================= * 函数名称:void ETH_SetPortStatusMode(In UINT32 u32PortStatMode) * 初稿完成:2005/1/6 * 作 者: * 函数功能:设置端口状态信息获得方式 * 输入参数:2'b10:使用CPU设定的状态信息 其他: 使用从MDIO接口获得的状态信息 * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_SetPortStatusMode(In UINT32 u32PortStatMode){ Port_Stat_Choice_U SetPortStatMode; SetPortStatMode.w32 = *(UINT32 *) ETH_MAC_REG(1); SetPortStatMode.bits.stat_ctrl = u32PortStatMode; *(UINT32 *) ETH_MAC_REG(1) = SetPortStatMode.w32;}/*======================================================================= * 函数名称:void ETH_SetSpeedLinkDuplexMode(In UINT32 u32Speed, In UINT32 u32Link, In UINT32 u32Duplex) * 初稿完成:2005/1/6 * 作 者: * 函数功能:CPU设置速度、链接状态、双工模式 * 输入参数:速度(1-100M,0-10M)、链接状态(1-链接,0-无链接)、双工模式(1-双工,0-半双工)对应的指针数据 * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_SetSpeedLinkDuplexMode(In UINT32 u32Speed, In UINT32 u32Link, In UINT32 u32Duplex){ Set_CPUSetSpeLinDup_U SetSpeLinDupMode; SetSpeLinDupMode.w32 = *(UINT32 *) ETH_MAC_REG(3); SetSpeLinDupMode.bits.speed_stat_dio = u32Speed; SetSpeLinDupMode.bits.duplex_stat_dio = u32Duplex; SetSpeLinDupMode.bits.link_stat_dio = u32Link; *(UINT32 *) ETH_MAC_REG(3) = SetSpeLinDupMode.w32;}/*======================================================================= * 函数名称:void ETH_ReadSpeedLinkDuplexMode(Out UINT32 *u32Speed Out UINT32 *u32Link, Out UINT32 *u32Duplex,) * 初稿完成:2005/1/6 * 作 者: * 函数功能:读取端口的速度、链接状态、双工模式 * 输入参数: * 输出参数: 速度(1-100M,0-10M)、链接状态(1-链接,0-无链接)、双工模式(1-双工,0-半双工)对应的指针数据, * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_ReadSpeedLinkDuplexMode(Out UINT32 *u32Speed, Out UINT32 *u32Link, Out UINT32 *u32Duplex) { Set_CPUReadSpeLinDup_U ReadSpeLinDupMode; ReadSpeLinDupMode.w32 = *(UINT32 *) ETH_MAC_REG(4); *u32Speed = ReadSpeLinDupMode.bits.speed_stat ; *u32Duplex = ReadSpeLinDupMode.bits.duplex_stat; *u32Link = ReadSpeLinDupMode.bits.link_stat;}/*======================================================================= * 函数名称:void ETH_ClearSpeedLinkDuplexMode(In UINT8 u8PortNo, In UINT32 u32Speed ,In UINT32 u32Link, In UINT32 u32Duplex) * 初稿完成:2005/1/6 * 作 者: * 函数功能:清除速度、链接状态、双工模式改变指示信号 * 输入参数:清除-1,不清除-0 * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_ClearSpeedLinkDuplexMode(In UINT32 u32Speed, In UINT32 u32Link, In UINT32 u32Duplex){ Set_CPUSetSpeLinDup_U ClearSpeLinDupMode; ClearSpeLinDupMode.w32 = *(UINT32 *) ETH_MAC_REG(5); ClearSpeLinDupMode.bits.speed_stat_dio = u32Speed; ClearSpeLinDupMode.bits.duplex_stat_dio = u32Duplex; ClearSpeLinDupMode.bits.link_stat_dio = u32Link; *(UINT32 *) ETH_MAC_REG(5) = ClearSpeLinDupMode.w32;}/*=======================================================================* MAC0 REG**=======================================================================*//*======================================================================= * 函数名称:void ETH_ClearPortCountInformation( Out UINT32 u32Value) * 初稿完成:2005/1/5 * 作 者: * 函数功能:清除指定端口列表的计数信息 * 输入参数: 需要清除统计信息的端口置1,否则置0 * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_ClearPortCountInformation( In UINT32 u32Value){ Port_Conf_U ClearCountInf; ClearCountInf.w32 = *(UINT32 *) ETH_MAC0_REG(0); ClearCountInf.bits.cntr_clr_all = u32Value; *(UINT32 *) ETH_MAC0_REG(0) = ClearCountInf.w32; /*finish clear, then disable clear.*/ ClearCountInf.bits.cntr_clr_all = 0; *(UINT32 *) ETH_MAC0_REG(0) = ClearCountInf.w32;}/*======================================================================= * 函数名称:void ETH_SetPortCntCleanEnable(In UINT32 u32CntAuCleEn) * 初稿完成:2005/1/6 * 作 者: * 函数功能:设置端口统计寄存器读清空使能/禁止 * 输入参数:读清空设置.1:表示读清空,0:禁止读清空。 * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_SetPortCntCleanEnable(In UINT32 u32CntAuCleEn){ Port_Conf_U SetCntAuCleEn; SetCntAuCleEn.w32 = *(UINT32 *) ETH_MAC0_REG(0); SetCntAuCleEn.bits.cntr_rdclr_en = u32CntAuCleEn; *(UINT32 *) ETH_MAC0_REG(0) = SetCntAuCleEn.w32;}#if 0/*======================================================================= * 函数名称:void ETH_CountPortStatistic( In UINT8 u8PortNo, Out Port_Cnt_S *pu32StaticCnt) * 初稿完成:2005/1/6 * 作 者: * 函数功能:统计端口的统计信息 * 输入参数:端口号(上行口或者下行口), * 输出参数: * 返回类型: 无 * 其他说明: * 调用函数: 建议 * 主调函数: 建议 *========================================================================*/void ETH_CountPortStatistic( Out Port_Cnt_S *pu32StaticCnt) { UINT32 AddrForPort = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -