📄 uart3.c
字号:
#include <rs232.h>
#include <utility.h>
#include <ansi_c.h>
#include "uartx.h"
/*
===================================
uart3
===================================
*/
static
unsigned char * puart;
static
int com;
void uart3_enable( void )
{
puart = "CNCB3";
com = 4;
}
void uart3_disable( void )
{
puart = "";
com = 0;
}
int uart3_close ( void )
{
CloseCom ( com );
uart3_disable ();
return 0;
}
int uart3_open ( int baud, int startbits, int databits, int paritybit, int stopbits )
{
uart3_enable ();
OpenComConfig ( com, puart, baud, paritybit, databits, stopbits, 1024, 1024 );
/* Turn off Hardware handshaking (loopback test will not function with it on) */
SetCTSMode ( com, LWRS_HWHANDSHAKE_OFF );
// SetCTSMode ( com, LWRS_HWHANDSHAKE_CTS_RTS_DTR );
// SetCTSMode ( com, LWRS_HWHANDSHAKE_CTS_RTS );
/* Make sure Serial buffers are empty */
FlushInQ ( com );
FlushOutQ ( com );
/* Promt the user to enter an event character. */
// PromptPopup ("Event Character", "Enter the Event Character", gEventChar, 1);
/* Install a callback such that if the event character appears at the receive buffer, our function will be notified. */
// InstallComCallback (1, LWRS_RXFLAG, 0, (int)gEventChar[0] , Event_Char_Detect_Func, 0);
return 0;
}
int uart3_read ( unsigned char * pbuf, int nSize )
{
char szTmp[ 160 ];
int len;
int count = 2;
while ( !(len = GetInQLen ( com )) && (count-- > 0) );
if ( len <= 0 || nSize <= 0 )
{
sprintf ( szTmp, "InQ : %d, buffer size = %d\n", len, nSize );
printf ( szTmp );
// MessagePopup ( "Debug", szTmp );
return 0;
}
if ( len > nSize ) len = nSize;
return ComRd ( com, pbuf, len );
}
int uart3_write ( unsigned char * pdata, int size )
{
return ComWrt ( com, pdata, size );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -