📄 myhdlc.h
字号:
/*现在这个头函数变成我的了,哈哈!*/
/***********************************/
#include <stdio.h>
#include <stdlib.h>
/*下面是一些寄存器的地址
我用的是CHANNEL 1*/
/**********************************/
#define ASIC_BASE 0x3ff0000
#define CS4510HDLC_HMODE (*(volatile unsigned *)(ASIC_BASE + 0x7000))
#define CS4510HDLC_HCON (*(volatile unsigned *)(ASIC_BASE + 0x7004))
#define CS4510HDLC_HSTAT (*(volatile unsigned *)(ASIC_BASE + 0x7008))
#define CS4510HDLC_HINTEN (*(volatile unsigned *)(ASIC_BASE + 0x700C))
#define CS4510HDLC_HTxFIFOC (*(volatile unsigned *)(ASIC_BASE + 0x7010))
#define CS4510HDLC_HTxFIFOT (*(volatile unsigned *)(ASIC_BASE + 0x7014))
#define CS4510HDLC_HRxFIFO (*(volatile unsigned *)(ASIC_BASE + 0x7018))
#define CS4510HDLC_HBRGTC (*(volatile unsigned *)(ASIC_BASE + 0x701C))
#define CS4510HDLC_HPRMB (*(volatile unsigned *)(ASIC_BASE + 0x7020))
#define CS4510HDLC_HSAR0 (*(volatile unsigned *)(ASIC_BASE + 0x7024))
#define CS4510HDLC_HSAR1 (*(volatile unsigned *)(ASIC_BASE + 0x7028))
#define CS4510HDLC_HSAR2 (*(volatile unsigned *)(ASIC_BASE + 0x702C))
#define CS4510HDLC_HSAR3 (*(volatile unsigned *)(ASIC_BASE + 0x7030))
#define CS4510HDLC_HMASK (*(volatile unsigned *)(ASIC_BASE + 0x7034))
#define CS4510HDLC_HDMATxPTR (*(volatile unsigned *)(ASIC_BASE + 0x7038))
#define CS4510HDLC_HDMARxPTR (*(volatile unsigned *)(ASIC_BASE + 0x703C))
#define CS4510HDLC_HMFLR (*(volatile unsigned *)(ASIC_BASE + 0x7040))
#define CS4510HDLC_HRBSR (*(volatile unsigned *)(ASIC_BASE + 0x7044))
/**********************************/
/*/*下面是一些寄存器的各位的设置*/
/***********************************/
#define CPU 0
#define HDMA 1
#define MODE HDMA
#define HDLCA 0
#define HDLCB 1
#define HDLCPORTNUM 2
#define WORD 4
#define HdlcReturnOk 1
#define HdlcReturnFail 0
#define HDLCRx_Ok 1
#define HDLCRx_Fail 0
#define HDLCTx_Ok 1
#define HDLCTx_Fail 0
#define MaxTxBDCount 64
#define MaxRxBDCount 256
#define NonCache 0x4000000
/*99.1.3 such
*/
#define RxBufLength 64
#define MaxFrameLength 1500
#define TxBufferSize 0x2000
#define RxBufferSize 0x2000
#define UserAreaSize 0x7000
#define RxBufferDataPreamble 0xDDDDDDD/*/cjw*/
#define ExtCLK TxCTxC|RxCRxC
#define IntCLK TxCBO2|RxCBO2
#define HDLC_BAUDRATE 256000
#define HDLC_PREAMBLE 0xAA
/* Tx Buffer Descriptor structure
// HDLC Mode Register (HMODE)
*/
#define MFinFIFO 0x00000001 /*/ bit 0*/
#define RxChigh 0x00000004
#define TxCINV 0x00000008
#define RxCINV 0x00000010
#define TxLittle 0x00000020
#define TxPL1 0x00000000
#define TxPL2 0x00000100
#define TxPL3 0x00000200
#define TxPL4 0x00000300
#define TxPL5 0x00000400
#define TxPL6 0x00000500
#define TxPL7 0x00000600
#define TxPL8 0x00000700
#define NRZ 0x00000000
#define NRZI 0x00001000
#define FM0 0x00002000
#define FM1 0x00003000
#define Manchester 0x00004000
#define DPLLTxC 0x00000000
#define DPLLRxC 0x00010000
#define DPLLMCLK 0x00020000
#define DPLLBO1 0x00030000
#define DPLLBO2 0x00040000
#define BRGRxC 0x00000000
#define BRGMCLK 0x00080000
#define TxCTxC 0x00000000
#define TxCRxC 0x00100000
#define TxCPLL 0x00200000
#define TxCBO1 0x00300000
#define TxCBO2 0x00400000
#define RxCTxC 0x00000000
#define RxCRxC 0x01000000
#define RxCPLL 0x02000000
#define RxCBO1 0x03000000
#define RxCBO2 0x04000000
#define TxOTxC 0x00000000
#define TxORxC 0x10000000
#define TxOBO1 0x20000000
#define TxOBO2 0x30000000
#define TxOPLLT 0x40000000
#define TxOPLLR 0x50000000
/*HDLC control register (HCON)
*/
#define TxRS 0x00000001
#define RxRS 0x00000002
#define DTxRS 0x00000004
#define DRxRS 0x00000008
#define TxEN 0x00000010
#define RxEN 0x00000020
#define DTxEN 0x00000040
#define DRxEN 0x00000080
#define DPLLEN 0x00000100
#define BRGEN 0x00000200
#define Tx1WD 0x00000000
#define Tx4WD 0x00000400
#define Rx1WD 0x00000000
#define Rx4WD 0x00000800
#define WIDGETMASK 0x00003000
#define RxWA0 0x00000000
#define RxWA1 0x00001000
#define RxWA2 0x00002000
#define RxWA3 0x00003000
#define DTxSTSK 0x00004000
#define DRxSTSK 0x00008000
#define DRxMADec 0x00010000
#define TxFlag 0x00020000
#define TxDFlag 0x00040000
#define TxLOOP 0x00080000
#define RxECHO 0x00100000
#define TxABText 0x00200000
#define TxABT 0x00400000
#define TxPRMB 0x00800000
#define TxDTR 0x01000000
#define RxDISCON 0x02000000
#define TxNoCRC 0x04000000
#define RxNoCRC 0x08000000
#define AutoEN 0x10000000
/* HDLC Status Register (HSTAT)
*/
#define RxRB1 0x00000000
#define RxRB2 0x00000001
#define RxRB3 0x00000002
#define RxRB4 0x00000003
#define TxFC 0x00000010
#define TxFA 0x00000020
#define TxCTS 0x00000040
#define TxSCTS 0x00000080
#define TxU 0x00000100
#define RxFA 0x00000200
#define RxFD 0x00000800
#define RxDCD 0x00001000
#define RxSDCD 0x00002000
#define RxFV 0x00004000
#define RxIDLE 0x00008000
#define RxABT 0x00010000
#define RxCRCE 0x00020000
#define RxNO 0x00040000
#define RxOV 0x00080000
#define RxMOV 0x00100000
#define DTxABT 0x00400000
#define RxIERR 0x00800000
#define DRxFD 0x01000000
#define DRxNL 0x02000000
#define DRxNO 0x04000000
#define DTxFD 0x08000000
#define DTxNL 0x10000000
#define DTxNO 0x20000000
#define DPLLOM 0x40000000
#define DPLLTM 0x80000000
/* HDLC Interrupt Enable Register (HINTEN)
*/
#define TxFCIE 0x00000010
#define TxFAIE 0x00000020
#define TxSCTSIE 0x00000080
#define TxUIE 0x00000100
#define RxFAIE 0x00000200
#define RxFDIE 0x00000800
#define RxSDCDIE 0x00002000
#define RxFVIE 0x00004000
#define RxIDLEIE 0x00008000
#define RxABTIE 0x00010000
#define RxCRCEIE 0x00020000
#define RxNOIE 0x00040000
#define RxOVIE 0x00080000
#define RxMOVIE 0x00100000
#define DTxABTIE 0x00400000
#define RxIERRIE 0x00800000
#define DRxFDIE 0x01000000
#define DRxNLIE 0x02000000
#define DRxNOIE 0x04000000
#define DTxFDIE 0x08000000
#define DTxNLIE 0x10000000
#define DTxNOIE 0x20000000
#define DPLLOMIE 0x40000000
#define DPLLTMIE 0x80000000
/* HDLC Tx Buffer Descriptor (HTxBD)
*/
#define BOwnerShip_CPU 0x7fffffff
#define BOwnerShip_DMA 0x80000000
#define Preamble 0x00000001
#define TxNoCRCM 0x00000002
#define Little 0x00000004
#define LastBF 0x00000008
#define BDPDec 0x00000010
#define BDWA0 0x00000000
#define BDWA1 0x00000020
#define BDWA2 0x00000040
#define BDWA3 0x00000060
#define TxComp 0x04000000
/* HDLC Rx Buffer Descriptor (HRxBD)
*/
#define CDlost 0x00000001
#define CRCE 0x00000002
#define NonOctet 0x00000004
#define OverRun 0x00000008
#define DTM 0x00000010
#define ABT 0x00000020
#define FrameF 0x00000040
#define FrameL 0x00000080
#define FLV 0x00000100
/*一些数据结构*/
/*帧的数据结构*/
/*struct frame
{
int Address = 0x22222222 ;
char Control ;
char *information = NULL ;
};
struct bd
{
unsigned int bufDPTR;
unsigned int reserved;
unsigned int bufLength;
HDLC_BD *nextBD;
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -