91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-27
  • 語言: 其他
  • 標簽: ST16C554??

資源簡介

ST16C554 初始化、通信和通過串口收發(fā)數(shù)據(jù)

資源截圖

代碼片段和文件信息

//------------------------------------------------------------------------
#include???????????????????????????/*?I/O?Functions?*/
#include????????????????????????/*?S3C44B0X?definitions?*/
#include??“option.H“
#include??“ST16C554.H“




//--------------------------------------------------------------------------------------------------
TCommHandle exCom[PORT_NUM];
//---------------------------------------------------------------------------------------------------
//??Define?Private?Faction
//-----------------------------------------------------------------------------------------------------

int?ReadPortRecBuf(uchar?Portuchar?*Byte);
int?WritePortSendBuf(uchar?Portuchar?Byte);
//void?Port_open(uchar?PortIDushort?Baud);

//-------------------------------------------------------------------------
//??Define?Public?Faction
//-------------------------------------------------------------------------

void?Init_16c554(void);
void?OpenEcom(uchar?PortIDushort?Bauduchar?ucLCRuchar?ucType);
//void?Port_open(Uchar?PortIDint?BaudUchar?DataBitNumUchar?ParitUchar?Stop);
void?CloseEcom(uchar?PortID);
int??EcomRece(uchar?Portuchar?*Bufferint?Count);
int??EcomSend(uchar?Portuchar?*Bufferint?Count);




//---------------------------------------------------------------------------------------------
//??初始化ST16C554
//---------------------------------------------------------------------------------------------
void?Init_16c554(void)
{
// uchar?xdata?*ptr;
uchar?i;
// bool?Result=false;

//16C554?復位時間要求最少1us
pPIO->PDATE|=0x20;
wait(1);
pPIO->PDATE&=(~0x20);

//板上順序剛好相反,所以序號換過來
// for(i=0;i for(i=0;i exCom[i].base_addr=(unsigned?char?*)(EXT_PORT_base+?i*0x08);

}
//---------------------------------------------------------------------------------------------
//????打開串口????
//
// ucType:?串口用作的類型,232時不用處理,485時要使能485芯片
//---------------------------------------------------------------------------------------------
void?OpenEcom(uchar?PortIDushort?Bauduchar?ucLCRuchar?ucType)
{
volatile?unsigned?char?*ptr;


// PortID--; //傳入時是1~8,這里使用必須是0~7
PortID?=?8-?PortID; //因為定義1-8的順序倒過來,現(xiàn)在用8減
ptr?=?exCom[PortID].base_addr; //?取端口的基地址
*(ptr+LCR)?=?LCR_DIV_EN; //?允許發(fā)送波特率
*(ptr+DLM)?=?(uchar)(Baud>>8);
*(ptr+DLL)?=?(uchar)Baud; ???????????? //?設(shè)置默任波特率



// *(ptr+LCR)?=?LCR_WORD_LEN8|LCR_STOP_LEN1;??? //?設(shè)置字長為8,1個停止位,無校驗位
*(ptr+LCR)?=?ucLCR;??? //?按預設(shè)置值

*(ptr+FCR)?=?EX_FIFO_EN|EX_FIFO_TRI_LEVEL_1|EX_FIFO_CLEAR_RCVR
|EX_FIFO_CLEAR_XMIT;?? //?設(shè)置FIFO?控制寄存器

*(ptr+IER)?=?IER_RECEIVEHOLD_INT; //打開串口時只開接收中斷
*(ptr+MCR)?=?MCR_INTX_EN; //?允許中斷引腳輸出
// if(ucType?!=?CT_232)
switch(ucType)
{
case?CT_232: //不用設(shè)置,用芯片默認的兩個輸出
break;
case?CT_485: //半雙工
//mark?for?test?2010.08.31
// *(ptr+MCR)?=?((*(ptr+MCR))?|?0x03); ??//DTR?輸出0,允許485接收并阻止發(fā)送
*(ptr+MCR)?=?((*(ptr+MCR))?|?0x03); ??//DTR?輸出0,

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????13151??2012-01-11?13:16??ST16C554_1.c

-----------?---------??----------?-----??----

????????????????13151????????????????????1


評論

共有 條評論