📄 rs232dbg.c
字号:
#ifdef KEIL
#include <reg51.h> // for KEIL compiler 8051 sfr definition
#else
#include <io51.h> // for IAR compiler 8051 sfr definition
#endif
#include "types.h" // Basic Type declarations
#include "RS232DBG.h" // RS232 Debuging declarations
#include "tusb3410.h"
/*---------------------------------------------------------------------------+
| Constant Definition |
+---------------------------------------------------------------------------*/
// ---------------------------------------------------------------------------
// The following subroutines are for RS232 Debuging.
//----------------------------------------------------------------------------
VOID rs232Initialization(VOID)
{
// take care of TMOD, SCON setting, because Timer 0&1 use them together
TMOD &= 0x0f; // Set Timer 1 to AUTO RELOAD
TMOD |= 0x20;
SCON = 0x40; // Set serial port for mode 1
PCON = 0x80; // Set SMOD = 1
TH1 = RS232_BAUDRATE;
TR1 = 1; // enable Timer 1
TI = 1; // Set Transmit Interrupt flag 1 to transmit ready
RI = 0; // Set Receive Interrupt flag 0 to receive ready
}
//----------------------------------------------------------------------------
VOID rs232PutChar(BYTE bData)
{
while(TI!=1); // wait until last byte transfer complete
TI=0; // clear Transmit Interrupt flag
SBUF=bData; // transmit c to 8052's Serial BUFfer
}
//----------------------------------------------------------------------------
void rs232PutString(char *str)
{
while(*str != '\0') rs232PutChar(*str++);
}
//----------------------------------------------------------------------------
/*
VOID rs232PutHex(BYTE bData)
{
BYTE hexValue;
hexValue = (bData & 0xF0)>> 4;
if(hexValue < 10 )
rs232PutChar(hexValue + '0');
else
rs232PutChar(hexValue + 55);
hexValue = (bData & 0x0F);
if(hexValue < 10 )
rs232PutChar(hexValue + '0');
else
rs232PutChar(hexValue + 55);
}
*/
//----------------------------------------------------------------------------
/*
VOID rs232PutHexString(BYTE bNum, BYTE *pbData)
{
int i;
for (i=0; i<bNum; i++) {
rs232PutHex(pbData[i]);
}
}
*/
//----------------------------------------------------------------------------
/*
char rs232GetChar(void)
{
while(!RI);
RI = 0;
return (SBUF);
}
*/
//----------------------------- Cut along the line ----------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -