#include <string.h>
#include <stdlib.h>
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\def.h"
#include "..\inc\uart.h"
#define KEY_BUFLEN 100
#define AFC_BUFLEN 0x100
#define IrDA_BUFLEN 0x100
char Uart_IntGetkey(void);
void Uart_Port(void);
void Return_Port(void);
void IrDA_Port(void);
void __irq Uart0_TxFifoInt(void);
void __irq Uart0_RxFifoInt(void);
void __irq Uart0_RxFifoErrorInt(void);
void __irq Uart0_RxInt(void);
void __irq Uart0_TxInt(void);
void __irq Uart1_TxFifoInt(void);
void __irq Uart1_RxFifoInt(void);
void __irq Uart1_RxFifoErrorInt(void);
void __irq Uart1_RxInt(void);
void __irq Uart1_TxInt(void);
void __irq U1AFC_TxInt(void);
void __irq U0AFC_RxInt(void);
void __irq U0AFC_RxErrorInt(void);
void __irq Exint2(void);
void __irq Test_Done(void);
void __irq Error(void);
void __irq U1IrDA_TxInt(void);
void __irq U1IrDA_RxInt(void);
void __irq U1IrDA_RxErrorInt(void);
static unsigned char keyBuf[KEY_BUFLEN];
volatile static int IrDA_BAUD,keyBufRdPt=0;
volatile static int keyBufWrPt=0;
volatile char out=1;
static char *uart0TxStr;
static char *uart1TxStr;
volatile U32 save_UC,save_UE,save_UF,save_UPC,save_UPE,save_UPF;
char Uart_IntGetkey(void)
{
if(keyBufRdPt==KEY_BUFLEN)
keyBufRdPt=0;
while(keyBufWrPt==keyBufRdPt); //until FIFO is triggered
return keyBuf[keyBufRdPt++];
}
////////UART 0 TEST////////////////
void Test_Uart0Fifo(void)
{
int key;
keyBufRdPt=keyBufWrPt=0;
pISR_UTXD0=(unsigned)Uart0_TxFifoInt;
pISR_URXD0=(unsigned)Uart0_RxFifoInt;
pISR_UERR01=(unsigned)Uart0_RxFifoErrorInt;
/*********** UART0 Tx FIFO test with interrupt ***********/
Uart_Printf("[Uart channel 0 tx FIFO Interrupt Test]\n");
Uart_TxEmpty(0); //wait until tx shifter is empty.
uart0TxStr="123456789abcdef";//UART0 Tx FIFO interrupt test is good!!!!\r\n";
rUFCON0=(2<<6)|(1<<4)|(6)|1;
//FIFO trigger:tx/rx:8byte,tx/rx_fifo reset(will be cleared),FIFO enable.
rUCON0 = 0x244; //tx:levl,rx:edge,error int,normal*2,interrupt(Start)
rINTMSK=~(BIT_GLOBAL|BIT_UTXD0);
Delay(500);
/*********** UART0 Tx FIFO test with BDMA0 ***********/
Uart_Init(0,115200);
Uart_Printf("\n[Uart0 FIFO Tx Test by BDMA0]\n");
uart0TxStr="UART0 Tx FIFO Test by BDMA0 is good!!!!\r\n";
Uart_TxEmpty(0);
rUCON0=0x48; //tx:BDMA0 rx:disable
rBDICNT0=0;
rBDCON0 =0x0;
rBDISRC0=(unsigned int)uart0TxStr|(0<<30)|(1<<28); // byte,inc
rBDIDES0=UTXH0 |(1<<30)|(3<<28); //L/B endian,M2IO,fix
rBDICNT0=strlen(uart0TxStr)|(2<<30)|(1<<26)|(1<<20); //UART0,start,polling
while(!((rBDCON0&0x30)==0x20));
Uart_TxEmpty(0);
/*********** UART0 Rx FIFO test with interrupt ***********/
rUCON0=0x245|0x80; //tx:level,rx:edge,tx/rx:int,rcv_time_out enabled,error int enable
Uart_Printf("\n[Uart channel 0 FIFO Rx Interrupt Test]:Type any key!!!\n");
Uart_Printf("You have to see the typed character. To quit, press Enter key.\n");
rINTMSK=~(BIT_GLOBAL|BIT_URXD0|BIT_UERR01);
while( (rUFSTAT0&0xf) >0 )
key=RdURXH0(); //To clear the Rx FIFO
// rUERSTAT0; //To clear the error state
while((key=Uart_IntGetkey())!='\r')
Uart_SendByte(key);
rUFCON0=(2<<6)|(1<<4)|(6)|0;
//FIFO trigger:tx/rx:8byte, txrx_fifo reset(will be cleared), FIFO disable.
rINTMSK=~BIT_GLOBAL;
rUCON0=0x45; //rcv_time_out disabled
Uart_Printf("\n");
}
void __irq Uart0_TxFifoInt(void)
{
// rI_ISPC=BIT_UTXD0;
int i;
// while( !(rUFSTAT0 & 0x200) && (*uart0TxStr != '\0') ) //until tx fifo full or end of string
while( !(rUFSTAT0 == 16) && (*uart0TxStr != '\0') ) //until tx fifo full or end of string
{
rUTXH0=*uart0TxStr++;
for(i=0;i<700;i++); //to avoid overwriting FIFO
}
rI_ISPC=BIT_UTXD0;
if(*uart0TxStr == '\0')
{
rUCON0 &= 0x3f3;
rI_ISPC=BIT_UTXD0;
rINTMSK|=BIT_UTXD0;
}
}
void __irq Uart0_RxFifoInt(void)
{
rI_ISPC=BIT_URXD0;
// if(rUFSTAT0==0)
// Uart_Printf("time out\n");
while( (rUFSTAT0&0xf) >0 ) //until FIFO is empty
{
keyBuf[keyBufWrPt++]=rURXH0;//rx buffer->keyBuf[]
if(keyBufWrPt==KEY_BUFLEN)
keyBufWrPt=0;
}
}
void __irq Uart0_RxFifoErrorInt(void)
{
rI_ISPC=BIT_UERR01;
switch(rUERSTAT0)//to clear and check the status of register bits
{
case '1':
Uart_Printf("Overrun error\n");
break;
case '2':
Uart_Printf("Parity error\n");
break;
case '4':
Uart_Printf("Frame error\n");
break;
case '8':
Uart_Printf("Breake detect\n");
break;
default :
break;
}
while( (rUFSTAT0&0xf) >0 )
{
keyBuf[keyBufWrPt++]=rURXH0;
if(keyBufWrPt==KEY_BUFLEN)
keyBufWrPt=0;
}
}
void Test_Uart0(void)
{
int key;
keyBufRdPt=keyBufWrPt=0;
pISR_UTXD0=(unsigned)Uart0_TxInt;
pISR_URXD0=(unsigned)Uart0_RxInt;
/*********** UART0 Tx test with interrupt ***********/
Uart_Printf("[Uart channel 0 tx Interrupt Test]\n");
Uart_TxEmpty(0); //wait until tx shifter is empty.
uart0TxStr="UART0 Tx interrupt test is good!!!!\r\n";
rINTMSK=~(BIT_GLOBAL|BIT_UTXD0);
// rUCON0 &= 0x3f3;
// rUCON0 |= 0x4; //needed to set the UTXD0 pending bit.
rUCON0 = 0x244; //tx:level,rx:edge,error int,normal*2,interrupt(Start)
Delay(3000);
/*********** UART0 Tx test with BDMA0 ***********/
rUCON0 = 0x245;//workaround
Uart_Printf("\n[Uart0 Tx Test by BDMA0]\n");
uart0TxStr="UART0 Tx Test by BDMA0 is good!!!!\r\n";
Uart_TxEmpty(0);
rUCON0=0x48; //tx:BDMA0 rx:disable
rBDICNT0=0x0;
rBDCON0 =0x0;
rBDISRC0=(unsigned int)uart0TxStr|(0<<30)|(1<<28); // byte,inc
rBDIDES0=UTXH0 |(1<<30)|(3<<28); //L/B endian,M2IO,fix
rBDICNT0=strlen(uart0TxStr)|(2<<30)|(1<<26)|(1<<20); //UART0,
while(!((rBDCON0&0x30)==0x20));
Uart_TxEmpty(0);
/*********** UART0 Rx test with interrupt ***********/
rUCON0=0x45; //tx:int rx:int
Uart_Printf("\n[Uart channel 0 Rx Interrupt Test]:Type any key!!!\n");
Uart_Printf("You will see the typed character. To quit, press Enter key.\n");
Uart_TxEmpty(0);
rINTMSK=~(BIT_GLOBAL|BIT_URXD0);
keyBufRdPt=keyBufWrPt=0;
while((key=Uart_IntGetkey())!='\r')
Uart_SendByte(key);
rINTMSK=~BIT_GLOBAL;
Uart_Printf("\n");
}
void __irq Uart0_RxInt(void)
{
rI_ISPC=BIT_URXD0;
keyBuf[keyBufWrPt++]=RdURXH0();
if(keyBufWrPt==KEY_BUFLEN)
keyBufWrPt=0;
}
//unsigned int txcount=0;
void __irq Uart0_TxInt(void)
{
// rI_ISPC=BIT_UTXD0;
// txcount++;
if(*uart0TxStr != '\0')
{
WrUTXH0(*uart0TxStr++);
rI_ISPC=BIT_UTXD0;
}
else
{
rUCON0 &= 0x3f3;//workaround
rI_ISPC=BIT_UTXD0;
rINTMSK|=BIT_UTXD0;
}
}
////////UART 1 TEST////////////////
void Test_Uart1Fifo(void)
{
int key;
keyBufRdPt=keyBufWrPt=0;
pISR_UTXD1=(unsigned)Uart1_TxFifoInt;
pISR_URXD1=(unsigned)Uart1_RxFifoInt;
pISR_UERR01=(unsigned)Uart1_RxFifoErrorInt;
/*********** UART1 Tx FIFO test with interrupt ***********/
Uart_Printf("[Uart channel 1 tx FIFO Interrupt Test]\n");
Uart_Printf("Plug the serial cable into ch1 connector!!! \n");
Uart_Printf("Then, press any key through UART ch1.\n");
Uart_Select(1);
Uart_Getch();
uart1TxStr="UART1 Tx FIFO interrupt test is good!!\r\n";
rUFCON1=(2<<6)|(1<<4)|(6)|1;
//FIFO trigger:tx/rx:8byte,tx/rx_fifo reset(will be cleared),FIFO enable.
rUCON1 = 0x244; //rx:edge,tx:level,error int,normal*2,interrupt(Start)
rINTMSK=~(BIT_GLOBAL|BIT_UTXD1);
Delay(500);
/*********** UART1 Tx FIFO test with BDMA1 ***********/
没有合适的资源?快使用搜索试试~ 我知道了~
s3c44b0_test.tar.gz_嵌入式
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 69 浏览量
2022-09-22
18:01:30
上传
评论
收藏 174KB GZ 举报
温馨提示
共69个文件
h:25个
s:19个
c:15个
s3c44b0功能测试源码,包含DMAtest、IICtest、PWMtest、TIMERtest、UARTtest。是嵌入式新手不可不看的经典源码,谢谢站长通过!
资源推荐
资源详情
资源评论
收起资源包目录
s3c44b0_test.tar.gz (69个子文件)
UARTtest
uarttest.bin 28KB
SRC
44BLIB_A.S 955B
44blib.c 5KB
44binit.s 13KB
44btest.c 2KB
Uart.c 22KB
INC
44b.h 5KB
DEF.H 221B
Option.s 1KB
Option.h 642B
Uart.h 400B
MEMCFG.s 2KB
44blib.h 697B
uarttest.mcp 189KB
IICtest
SRC
44BLIB_A.S 955B
44blib.c 3KB
44binit.s 13KB
44btest.c 1KB
IIC.C 4KB
INC
44b.h 5KB
DEF.H 221B
Option.s 1KB
Option.h 860B
MEMCFG.s 2KB
IIC.H 179B
44blib.h 663B
IICtest.mcp 189KB
IICtest.bin 19KB
TIMERtest
SRC
TIMER.C 1019B
44blib.c 3KB
44binit.s 13KB
44btest.c 1KB
INC
TIMER.H 98B
44b.h 4KB
DEF.H 221B
Option.s 1KB
Option.h 640B
MEMCFG.s 2KB
44blib.h 563B
timertest.bin 18KB
timertest.mcp 189KB
DMAtest
SRC
44BLIB_A.S 955B
DMA.C 5KB
44blib.c 6KB
44binit.s 13KB
44btest.c 2KB
INC
44b.h 5KB
DEF.H 221B
Option.s 1KB
Option.h 881B
MEMCFG.s 2KB
Dma.h 114B
44blib.h 854B
DMAtest.bin 21KB
DMAtest.mcp 191KB
PWMtest
SRC
44BLIB_A.S 955B
44blib.c 5KB
44binit.s 13KB
44btest.c 1KB
Pwm.C 2KB
INC
44b.h 8KB
DEF.H 221B
Option.s 1KB
Option.h 1KB
PWM.H 88B
MEMCFG.s 2KB
44blib.h 972B
pwmtest.mcp 189KB
pwmtest.bin 20KB
共 69 条
- 1
资源评论
林当时
- 粉丝: 103
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功