📄 dec6713_uart.c
字号:
/*********************************************************************************
* DEC6713_UART.C v2.00 *
* Copyright 2003 by SEED Electronic Technology Ltd.
* All rights reserved. Property of SEED Electronic Technology Ltd. *
* Designed by: Hongshuai.Li
* Discription:Operation mode is FIFO.
* 05.10.2005
*********************************************************************************/
#include <csl.h>
#include <csl_irq.h>
#include "DEC6713.h"
#include "uartn.h"
#include <stdio.h>
/********************************************************************************/
#define LENGTH 160
Uint32 UART_Handle;
Uint32 UARTA_Handle; //added on 03.04.2005
Uint32 UARTB_Handle;
Uint8 RevBuffer_A[160];
Uint8 RevBuffer_B[160];
Uint16 i;
Uint8 int_flag = 1;
Uint8 TempData;
Uint16 BaudRate;
Uint8 reg_data=0;
Uint8 Lth = 0;
Uint8 RcountA =0;
Uint8 RcountB =0;
Uint8 ScountA =0;
Uint8 ScountB =0;
Uint8 ReVal = 0;
#pragma DATA_SECTION(uart_ab_channel_select,".uart_var");
unsigned char uart_ab_channel_select = 0;
/********************************************************************************/
void init_uart(); //added on 03.04.2005
extern far void vectors();
main()
{
/* Initialize the chip support library, must when using CSL */
CSL_init();
/*Initialize DEC6713 board.*/
DEC6713_init();
/*Initialize receive buffer.*/
for(i=0;i<LENGTH;i++)
RevBuffer_B[i] = 0;
/* Disable interrupt. */
IRQ_globalDisable();
IRQ_RSET(EXTPOL,0x0F);
IRQ_setVecs(vectors);
IRQ_map(IRQ_EVT_EXTINT6,6);
IRQ_disable(IRQ_EVT_EXTINT6);
IRQ_clear(IRQ_EVT_EXTINT6);
/*Open UART. */
init_uart();
/* Enable interrupt */
IRQ_enable(IRQ_EVT_EXTINT6);
IRQ_globalEnable();
IRQ_nmiEnable();
for(;;)
{
/*Transmit received data to PC.*/
if(ScountB != RcountB)
{
TempData = UART_rget(UARTB_Handle,UART_LSR);
if(TempData&0x40 == 0x40)
{
for(i=0; i<FIFO_Length; i++)
{
UART_rset(UARTB_Handle,UART_THR, RevBuffer_B[ScountB]);
}
ScountB++;
if(ScountB ==160)
{
ScountB = 0;
}
}
}
}
}
/********************************************************************************\
\*UART initialize routine *\ //added on 03.04.2005
\********************************************************************************/
void init_uart()
{
/* Initialize uart_b */
UARTB_Handle = UART_open(UART_B);
BaudRate = baud_19k2;
UART_setup(UARTB_Handle,BaudRate,
data_w8,
data_s1,
0,
0x07,
0x08);
/* Clear RHR and LSR registers. */
TempData = UART_rget(UARTB_Handle,UART_RHR);
TempData = UART_rget(UARTB_Handle,UART_LSR);
/* Setup UARTA interrupt. */
UART_IntSetup(UARTB_Handle,uartint_rhr);
}
/********************************************************************************\
\* -UART interrupt handle function.
\*Parameters:
\*
\*Return:
\********************************************************************************/
interrupt void
c_int6(void)
{
/*Receive data and save in data_buffer.*/
reg_data = DEC6713_cpld_rget(DEC6713_INTSTAT_REG);
// Receive UARTb data
if((reg_data & 0x60) == 0x40)
{
TempData = UART_rget(UARTB_Handle,UART_LSR);
if((TempData&0x01) == 0x01)
{
for(i=0;i<FIFO_Length;i++)
{
RevBuffer_B[RcountB]=UART_receive_single(UARTB_Handle);
}
RcountB++;
if(RcountB == 160) RcountB =0;
}
else
{
UART_rset(UARTB_Handle,UART_FCR,0x02);
}
}
int_flag = 0;
return;
}
/********************************************************************************/
/* End of DEC6713_UART.C */
/********************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -