parallel port core driven.c

来自「ADI 公司的DSP ADSP21262 EZ-KIT LITE开发板的全部源代」· C语言 代码 · 共 72 行

C
72
字号
/* Register Definitions */
#define PPCTL       0x1800
#define TXPP        0x1808
#define RXPP        0x1809
#define EIPP        0x1810
#define EMPP        0x1811
#define ECPP        0x1812

/* Register Bit Definitions */
#define PPEN    0x00000001
#define PPDUR4  0x00000006
#define PPBHC   0x00000040
#define PPTRAN  0x00000200
#define PPBS    0x00020000

/* External Memory Location */
#define EXTBUFFER 0x1200000

/* Source Buffer */
int dest[8];
int source[8] = {0x11111111,
                 0x22222222,
                 0x33333333,
                 0x44444444,
                 0x55555555,
                 0x66666666,
                 0x77777777,
                 0x88888888};

/* Main code section */
void main(){
int i;
/* setup ppdma registers for core use */
* (volatile int *)EMPP = 1;
* (volatile int *)EIPP = EXTBUFFER;

* (volatile int *)PPCTL =  PPEN|      /* enable port */
         PPTRAN|    /* transmit (write) */
         PPBHC|     /* implement a bus hold cycle*/
         PPDUR4;   /* make pp data cycles last for a */
                    /* duration of 20 cclk cycles */

/* loop to write 10 words into TXPP */
for(i=0; i<10; i++)
* (volatile int *)TXPP= source[i];

/*poll to ensure parallel port has completed the transfer*/
do{
;}
while( (* (volatile int *)PPCTL & PPBS) != 0);

* (volatile int *)PPCTL =  0;      /* disable port */
/* setup ppdma registers for core use */
* (volatile int *)EMPP = 1;
* (volatile int *)EIPP = EXTBUFFER;

* (volatile int *)PPCTL =  PPEN|      /* enable port */
         PPBHC|     /* implement a bus hold cycle*/
         PPDUR4;   /* make pp data cycles last for a */
                    /* duration of 4 cclk cycles */

/* loop to read 10 words from RXPP */
for(i=0; i<10; i++)
    dest[i]=* (volatile int *)RXPP;

/*poll to ensure parallel port has completed the transfer*/
do{
;}
while( (* (volatile int *)PPCTL & PPBS) != 0);

}

⌨️ 快捷键说明

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