?? uart0.c
字號:
#include <string.h>
#include <stdlib.h>
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"
#include "uart0.h"
void __irq Uart0_TxInt(void);
void Uart0_SendString(INT8 * pcTemp);
static int send_index=0;
static int send_isr_index=0;
#define MAX_BUFSIZE 1024
static char send_buf[MAX_BUFSIZE];
//---------------------------------------UART0 test function-------------------------------------
void __irq Uart0_TxInt(void)
{
rINTSUBMSK|=(BIT_SUB_RXD0|BIT_SUB_TXD0|BIT_SUB_ERR0); // Just for the safety
if(send_index!= send_isr_index)
{
WrUTXH0(send_buf[send_isr_index++]);
ClearPending(BIT_UART0); // Clear master pending
rSUBSRCPND|=(BIT_SUB_TXD0); // Clear Sub int pending
rINTSUBMSK&=~(BIT_SUB_TXD0); // Unmask sub int
}
else
{
ClearPending(BIT_UART0); // Clear master pending
rSUBSRCPND|=(BIT_SUB_TXD0); // Clear Sub int pending
rINTMSK|=(BIT_UART0);
send_index=0;
send_isr_index=0;
}
}
void Uart0_SendString(INT8 * pcTemp)
{
int ix=0;
INT8U ch;
while(*pcTemp!='\0')
{
ch=*pcTemp;
if(ch=='\n')
{
ch='\r';
send_buf[send_index++]=ch;
}
send_buf[send_index++]=*pcTemp;
pcTemp++;
}
pISR_UART0=(unsigned)Uart0_TxInt;
rULCON0=(0<<6)|(0<<3)|(0<<2)|(3); // Normal,No parity,One stop bit, 8bit
rUCON0 &= 0x400; // For the PCLK <-> UCLK fuction
rUCON0 |= (TX_INTTYPE<<9)|(RX_INTTYPE<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(1);
//Clock,Tx:Def,Rx:Def,Rx timeout:x,Rx error int:x,Loop-back:x,Send break:x,Tx:int,Rx:int
Uart_TxEmpty(0); //wait until tx buffer is empty.
rINTMSK&=~(BIT_UART0);
rINTSUBMSK&=~(BIT_SUB_TXD0);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -