📄 com.c
字号:
/* ##########################################################################
# Terawins Inc. Company #
# Copyright (c) 2005, All rights reserved #
# #
# All rights reserved. Reproduction in whole or in parts is prohibited #
# without the prior written consent. #
########################################################################## */
////////////////////////////////////////////////////////////////////////////////
// //
// LCD Application Firmware //
// ========================================================================== //
// //
// Module : Com.c //
// //
// Purpose : UART communication routine //
// //
// Version : 1.00 //
// //
// Compiler : Keil 8051 C Compiler v7.0 //
// //
// Reference: [1] Keil C51 Compiler User's Guide 09.2001, Keil Software, Inc.//
// //
// ========================================================================== //
// //
// Date Author Reason (what and why) //
// ----------- ------------- ---------------------------------------------- //
// 2005/12/30 Bruce Cho Initial Draft //
// //
////////////////////////////////////////////////////////////////////////////////
#define __COM_C__
#ifdef __COM_C__
#include "Com.h"
#include "reg51.h"
//#include "ICControl.h"
// _____________________________________________________________________________
//
// Private module variables (static module global 's_' prefixed for 's'tatic)
//
char code s_moduleInfo[] = __FILE__ " modified " __DATE__ " at " __TIME__;
// Ring variables.
//static uCHAR RING_MEM_SPACE s_rxRing[RX_RING_SIZE];
uCHAR RING_MEM_SPACE s_txRing[TX_RING_SIZE];
//static bit data s_translateEol;
//static volatile bit data s_rxRingEmpty;
bit s_txRingEmpty;
//static volatile RxRingIndex data s_rxWrIdx;
//static volatile RxRingIndex data s_rxRdIdx;
TxRingIndex s_txWrIdx;
TxRingIndex s_txRdIdx;
//static UartBaudRates data s_currentBaudRate;
//extern static volatile int data s_UartTimeOut;
//=======================================================================
// Function: initUart
//
// Description:
// ------------
// Sets up the 8051 Serial Port for UART (SCON.SM1 = 1, Mode 1) operation and
// initializes the ring buffers.
//
// Design Notes:
// -------------
// uCHAR framing is 8-N-1.
//=======================================================================
bit UartInit(void)
{
// IC_WritByte(0x00,0x91,0x87);
// IC_WritByte(0x100,0xb8,0x40);
// IC_WritByte(0x00,0x9d,0xff);
// For restartability.
ES = 0;
TR1=0;
// Setup the baud rate generator.
// if (setUartBaudRate(baudRate)) return FALSE;
// Setup the serial port.
SCON = SCON_8N1 | SCON_REN;
// SCON = 0x50;
TMOD=T1_MODE ; // Timer1 in Mode 2
// 砞﹚baudrate=19200
PCON |=PCON_SMOD;
TH1=TH1_VALUE ; // 0xfd:baud rate 9600
TL1=TH1_VALUE ; // 0xfd:baud rate 9600
TR1=1 ; // Timer1 璓
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -