📄 testuart232_ce1.c
字号:
/* ======================================================================== */
/* NAME */
/* uart_pc.c */
/* DESCRIPTION */
/* UART module communication with PC for the jydVCM */
/* ------------------------------------------------------------------------ */
/* Copyright (c) 2006 Wintech Digital System Technology Corp. */
/* All Rights Reserved. */
/* ======================================================================== */
//date:2006 9 15
//auther:shangqr
/* ======================================================================== */
/* basic header includes */
/* ======================================================================== */
#include <stdio.h>
#include <std.h>
#include <sys.h>
#include "testuartcfg.h"
#include "DM643.h"
#include "DM643_uart.h"
void UART_PC();
Int8 *buffer;
volatile Uint32 sleepCount = 0;
void sleepIsr()
{
sleepCount++;
}
/***********************
baud rate can use:
#define DM643_UART_BAUD115200 0x010
#define DM643_UART_BAUD57600 0x020
#define DM643_UART_BAUD38400 0x030
#define DM643_UART_BAUD19200 0x060
#define DM643_UART_BAUD9600 0x0c0
#define DM643_UART_BAUD4800 0x180
#define DM643_UART_BAUD2400 0x300
#define DM643_UART_BAUD1200 0x600
*/
main()
{
/* Call BSL init */
DM643_init();
/* call uart function */
UART_PC( );
/* Success */
printf("\n*** All tests PASS ***\n");
/* Disable interrupts */
IRQ_globalDisable();
/* Software breakpoint */
asm(" .long 0x10000000");
}
/*****************************/
void UART_PC()
{
Int32 baudrate,delaytime,i;
DM643_UART_Handle hUart;
Int16 temp;
Int8 buffer0[1000];
DM643_UART_Config uartcfg =
{
0x00, // IER
0x57, // FCR - FIFO Mode, 16 character trigger level
0x03, // LCR - 8 bits, no parity, 1 stop
0x00, // MCR
};
delaytime = 1;
//default bautrate;
baudrate=0x9600;
// Open UART
hUart = DM643_UART_open(DM643_UART232,baudrate, &uartcfg); // DM643_UART485
// allocation a buffer for data which comes from uart
buffer = (Int8*)malloc(2*1024*sizeof(Int8));
// change baudrate,paritybit,databit,stopbit;
DM643_UART_setParameter(hUart,9600,0,8,1);
//set S_RT TO LOW
//*((Uint32 *)0x90030000) = 0x0000;
for (i=0;i<6000;i++)
{
buffer0[i]=i;
}
while(1)
{
//set S_RT TO LOW for 485 getchar from uart
//*((Uint32 *)0x90030000) = 0x0000;
//get data
temp=DM643_UART_getChar(hUart,1000,buffer); //get data
//set S_RT TO HIGH for 485 putchar to uart
// *((Uint32 *)0x90030000) = 0x1000;
//send data
DM643_UART_putChar(hUart,256,buffer0);//send data
//wait
DM643_waitusec(1000);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -