?? tl16c752 串口擴展芯片驅動源代碼.htm
字號:
<td background=/Skin/Ocean/addr_line.jpg height=4></td>
</tr>
</table>
<div align=center>
<script language="javascript" src="/AD/200610/56.js"></script>
</div>
<!-- ********網(wǎng)頁中部代碼開始******** -->
<!--文章顯示代碼開始-->
<table class=center_tdbgall style="WORD-BREAK: break-all" cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<tr>
<td colSpan=2>
<table class=main_title_760 style="WORD-BREAK: break-all" cellSpacing=0 cellPadding=0 width="100%" border=0>
<tr>
<td vAlign=center width="4%"> </td>
<td width="65%"><STRONG>TL16C752 串口擴展芯片驅動源代碼</STRONG></td>
<td width="18%"><FONT color=#ff0000> <font color=red>熱</font> <font color='#009999'>★★★</font></FONT></td>
<td align=right width="13%"><FONT color=#ff0000>【字體:<A href="javascript:fontZoomA();"><FONT color=#ff0000>小</FONT></A> <A href="javascript:fontZoomB();"><FONT color=#ff0000>大</FONT></A>】</FONT></td>
</tr>
</table>
</td>
</tr>
<tr vAlign=center align=middle>
<td class=main_ArticleTitle style="WORD-BREAK: break-all" colSpan=2 height=50>TL16C752 串口擴展芯片驅動源代碼</td>
</tr>
<tr vAlign=center align=middle>
<td class=main_ArticleSubheading style="WORD-BREAK: break-all" colSpan=2></td>
</tr>
<tr align=middle>
<td class=Article_tdbgall colSpan=2>作者:61IC 文章來源:本站原創(chuàng) 點擊數(shù):<script language='javascript' src='/Article/GetHits.asp?ArticleID=11115'></script> 更新時間:2007-1-22 <A title=收藏的網(wǎng)頁將被永久地保存到新浪ViVi收藏夾http://vivi.sina.com.cn href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(vivi=window.open('http://vivi.sina.com.cn/collect/icollect.php?pid=2008&title='+escape(d.title)+'&url='+escape(d.location.href)+'&desc='+escape(t),'vivi','scrollbars=no,width=480,height=480,left=75,top=20,status=no,resizable=yes'));vivi.focus();"><IMG src="/images/vivi_coop1.gif" align=absMiddle border=0></A></td>
</tr>
<tr>
<td class=main_tdbg_760 id=fontzoom style="WORD-BREAK: break-all" vAlign=top colSpan=2 height=300>
<table cellSpacing=0 cellPadding=10 align=left border=0>
<tr>
<td>
<!--插入廣告JS代碼--></td>
</tr>
</table>
<P>#include "uart.h"</P>
<P>/***************************************************************************/<BR>/* ======== UART_rset ======== */<BR>/* Set a UART register,設置寄存器 */<BR>/***************************************************************************/<BR>void UART_rset(Int16 regnum,Int16 regval)<BR>{<BR> Int16 regindex, lcr;<BR> <BR> /* Register index is determined by lower 3 bits and the target UART */<BR> <BR> //regindex = regnum & 0x7;<BR>// if (hUart == 1)<BR>// regindex += 8;<BR> /*是否為高位的寄存器*/<BR> /* If regnum between 0x08 and 0x0F, set bit 7 of LCR to access register */<BR> //if ((regnum & 0x18) == 0x8)<BR> if((regnum >= 0x10) && (regnum <= 0x1e))<BR> {<BR> lcr = rget(TL_UART_LCR);<BR> waitusec(1);<BR> rset(TL_UART_LCR, lcr | 0x80);<BR> waitusec(1);<BR> rset(regnum, regval);<BR> waitusec(1);<BR> rset(TL_UART_LCR, lcr);<BR> waitusec(1);<BR> }<BR> else<BR> {<BR> <BR> rset(regnum, regval);<BR> waitusec(1);<BR> }<BR>}</P>
<P>/**********************************************************************/<BR>/* ======== UART_rget ======== */<BR>/* Get the value of a UART register,讀出寄存器的值 */<BR>/**********************************************************************/<BR>Int16 UART_rget(Int16 regnum)<BR>{<BR> Int16 regindex, returnval, lcr;<BR> <BR> /* Register index is determined by lower 3 bits and the target UART */<BR> //regindex = regnum & 0x7;<BR>// if (hUart == 1)<BR>// regindex += 8;<BR> <BR> /* If regnum between 0x08 and 0x0F, set bit 7 of LCR to access register */<BR> //if ((regnum & 0x18) == 0x8)<BR> if((regnum >= 0x10) && (regnum <= 0x1e))<BR> {<BR> lcr = rget(TL_UART_LCR);<BR> rset(TL_UART_LCR, lcr | 0x80);<BR> returnval = rget(regnum);<BR> rset(TL_UART_LCR, lcr);<BR> }<BR> else<BR> {<BR> returnval = rget(regnum);<BR> }<BR> <BR> return returnval;<BR>}</P>
<P>/**************************************************************************/<BR>/* ======== UART_open ======== */<BR>/* Initialize UART and return handle */<BR>/* 描述:打開相應的串口,并進行相應的配置 */<BR>/* 輸入?yún)?shù): */<BR>/* devid: 選擇UART的通路 */<BR>/* baudrate: 選擇正確的波待率 */<BR>/* config: 其它配置其它的參數(shù)組 */<BR>/**************************************************************************/<BR>void UART_open(Int16 baudrate,UART_Config *config)<BR>{<BR>// UART_Handle hUart;<BR> //Int16 dl;<BR> Int8 dl,test;<BR> /* Assign handle */<BR>// hUart = devid;<BR> <BR> /* Set registers based on config structure */</P>
<P> /*設置MCR*/<BR> UART_rset(TL_UART_MCR,config -> regs[3]);<BR> //test = UART_rget(TL_UART_MCR);<BR> /*將EFR寄存器的第4位關閉*/<BR> dl = UART_rget(TL_UART_EFR);<BR> UART_rset(TL_UART_EFR, dl & 0xEF);<BR> //test = UART_rget(TL_UART_EFR);<BR> <BR> /*設置串口的MCR*/<BR> UART_rset(TL_UART_MCR, config -> regs[3]);<BR> //test = UART_rget(TL_UART_MCR);<BR> <BR> /*設置串口的IER*/<BR> UART_rset(TL_UART_IER, config -> regs[0]);<BR> //test = UART_rget(TL_UART_IER);<BR> /*設置串口的FCR*/<BR> UART_rset(TL_UART_FCR, config -> regs[1]);<BR> //test = UART_rget(TL_UART_FCR); <BR> /*設置串口的LCR*/<BR> UART_rset(TL_UART_LCR, config -> regs[2]);<BR> //test = UART_rget(TL_UART_LCR);</P>
<P> /* Set up baud divisor clock,設置波待率 */<BR> dl = UART_rget(TL_UART_MCR);<BR> if((dl & 0x80)==0x80)<BR> {<BR> baudrate = (baudrate/4); <BR> }<BR> //UART_rset(TL_UART_DLL, baudrate & 0xff);<BR> UART_rset(TL_UART_DLL, 0x50);<BR> dl = UART_rget(TL_UART_DLL);<BR> //UART_rset(TL_UART_DLH, (baudrate >> 8) & 0xff);<BR> UART_rset(TL_UART_DLH, 0x00);<BR> dl = UART_rget(TL_UART_DLH);<BR> /* Clear any outstanding receive characters,清空接收寄存器 */<BR> UART_rget(TL_UART_RBR);<BR> <BR>// return hUart;<BR>}</P>
<P>/*********************************************************************/<BR>/* ======== UART_getChar ======== */<BR>/* Get one character of data from the UART,讀取數(shù)據(jù) */<BR>/*********************************************************************/<BR>Int16 UART_getChar(void)<BR>{<BR> Int16 status;<BR> <BR> while(1)<BR> {<BR> status = UART_rget(TL_UART_LSR);<BR> if ((status & 1) != 0) // DR<BR> break;<BR> }<BR> <BR> return <BR> UART_rget(TL_UART_RBR);<BR>}</P>
<P>/*********************************************************************/<BR>/* ======== UART_putChar ======== */<BR>/* Send one character of data to the UART,發(fā)送一個數(shù)據(jù) */<BR>/*********************************************************************/<BR>void UART_putChar(Uint16 data)<BR>{<BR> Int16 status;<BR> <BR> while(1)<BR> {<BR> status = UART_rget(TL_UART_LSR);<BR> if ((status & 0x20) != 0) // THRE<BR> break;<BR> }<BR>// SEEDDM642_waitusec(3); <BR> UART_rset(TL_UART_THR, data);</P>
<P>}</P>
<P>void UART_puts(const char *s)<BR>{<BR> while (*s) {<BR> UART_putChar(*s++);<BR> }<BR>}</P>
<P>/* Spin in a delay loop for delay iterations */<BR>void wait(Uint32 delay)<BR>{<BR> volatile Uint32 i, n;<BR> <BR> n = 0;<BR> for (i = 0; i < delay; i++)<BR> {<BR> n = n + 1;<BR> }<BR>}</P>
<P>/* Spin in a delay loop for delay microseconds */<BR>void waitusec(Uint32 delay)<BR>{<BR> wait(delay * 21);<BR>}</P>
<P>Uint8 rget(Int16 regnum)<BR>{<BR> Uint8 *pdata;<BR> <BR> /* Return lower 8 bits of register */<BR> pdata = (Uint8 *)(UART_BASE + regnum);<BR> return (*pdata & 0xff);<BR>}</P>
<P>void rset(Int16 regnum, Uint8 regval)<BR>{<BR> Uint8 *pdata;<BR> <BR> /* Write lower 8 bits of register */<BR> pdata = (Uint8 *)(UART_BASE + regnum);<BR> *pdata = (regval & 0xff);<BR>}<BR></P>
<CENTER></CENTER></td>
</tr>
<tr>
<td class=Article_tdbgall align=right colSpan=2> <FONT color=#0089f7> <FONT style="BACKGROUND-COLOR: #f5f5f5" color=#000000>歡迎點擊進入:</FONT><A title="" href="http://www.tichinese.com/"><U><FONT color=#0033ff>TI德州中文網(wǎng)</FONT></U></A><FONT color=#0089f7> </FONT><FONT color=#ff0000> (國內(nèi)唯一針對TI應用的中文技術網(wǎng)站)</FONT> </FONT>文章錄入:admin 責任編輯:admin </td>
</tr>
<tr>
<td width=5></td>
<td width=752><li>上一篇文章: <a class='LinkPrevArticle' href='/Article/code/ADI/Blackfin/200701/11114.html' title='文章標題:UART RS-232 HyperTerminal (ASM)
作 者:61IC
更新時間:2007-1-22 13:09:50'>UART RS-232 HyperTerminal (ASM)</a></li><BR><li>下一篇文章: <a class='LinkNextArticle' href='/Article/code/ADI/Blackfin/200701/11116.html' title='文章標題:矩陣乘法源代碼
作 者:61IC
更新時間:2007-1-22 13:13:20'>矩陣乘法源代碼</a></li></td>
</tr>
<tr class=Article_tdbgall align=right>
<td colSpan=2>【<a href="/Article/Comment.asp?ArticleID=11115" target="_blank">發(fā)表評論</a>】【<a href="/User/User_Favorite.asp?Action=Add&ChannelID=1&InfoID=11115" target="_blank">加入收藏</a>】【<a href="/Article/SendMail.asp?ArticleID=11115" target="_blank">告訴好友</a>】【<a href="/Article/Print.asp?ArticleID=11115" target="_blank">打印此文</a>】【<a href="javascript:window.close();">關閉窗口</a>】</td>
</tr>
</table>
<table class=center_tdbgall cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<tr>
<td class=main_shadow>
</td>
</tr>
</table>
<!--文章顯示代碼結束-->
<!--最新熱點、最新推薦、相關文章代碼開始-->
<table class=center_tdbgall style="WORD-BREAK: break-all" cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<tr>
<td class=main_title_282 width="33%"><B>最新熱點</B></td>
<td width=5 rowSpan=2></td>
<td class=main_title_282 width="33%"><B>最新推薦</B></td>
<td width=5 rowSpan=2></td>
<td class=main_title_282 width="33%"><B>相關文章</B></td>
</tr>
<tr>
<td class=main_tdbg_760 vAlign=top height=100>
<script language="javascript" src="/Article/JS/Article_Hot3.js"></script></td>
<td class=main_tdbg_760 vAlign=top width="33%">
<script language="javascript" src="/Article/JS/Article_Elite3.js"></script></td>
<td class=main_tdbg_760 vAlign=top width="33%"><a class='LinkArticleCorrelative' href='/Article/code/ADI/Blackfin/200701/11116.html' title='文章標題:矩陣乘法源代碼
作 者:61IC
更新時間:2007-1-22 13:13:20' target="_self">矩陣乘法源代碼</a><br></td>
</tr>
</table>
<table class=center_tdbgall cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<tr>
<td class=main_shadow></td>
</tr>
</table>
<!--最新熱點、最新推薦、相關文章代碼結束-->
<!--網(wǎng)友評論代碼開始-->
<table class=center_tdbgall style="WORD-BREAK: break-all" cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<tr class=main_title_760>
<td height=25> <STRONG>網(wǎng)友評論:</STRONG><SPAN style="COLOR: #ff0000">(只顯示最新10條。評論內(nèi)容只代表網(wǎng)友觀點,與本站立場無關!) </SPAN></td>
</tr>
<tr>
<td class=main_tdbg_760>
<script language="javascript" src="/Article/Comment.asp?Action=JS&CommentNum=10&ArticleID=11115"></script></td>
</tr>
</table>
<table class=center_tdbgall cellSpacing=0 cellPadding=0 width=760 align=center border=0>
<tr>
<td class=main_shadow></td>
</tr>
</table>
<!--網(wǎng)友評論代碼結束-->
<!-- ********網(wǎng)頁中部代碼結束******** -->
<!-- ********網(wǎng)頁底部代碼開始******** --><table cellSpacing=0 cellPadding=0 width=778 align=center border=0>
<tr>
<td class=menu_bottombg align=middle>| <A class=Bottom onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.61ic.com/');" href="#">設為首頁</A> | <A class=Bottom href="javascript:window.external.addFavorite('http://www.61ic.com/','61IC中國電子在線');">加入收藏</A> | <A class=Bottom href="mailto:web_61ic@163.com">聯(lián)系站長</A> | <A class=Bottom href="/FriendSite/Index.asp" target=_blank>友情鏈接</A> | <A class=Bottom href="/Copyright.asp" target=_blank>版權申明</A> | <A class=Bottom href="/Announcelist.asp" target=_blank>網(wǎng)站公告</A> | <a class='Bottom' href='/Admin/Admin_Index.asp' target='_blank'>管理登錄</a> | </td>
</tr>
<tr>
<td class=bottom_bg height=80>
<table cellSpacing=0 cellPadding=0 width="90%" align=center border=0>
<tr>
<td><IMG height=80 src="/Skin/Ocean/bottom_left.gif" width=9></td>
<td align=middle width="80%"> 站長:<A href="mailto:web_61ic@163.com">61IC 湘ICP備05002478號</A> </td>
<td align=right><IMG height=80 src="/Skin/Ocean/bottom_r.gif" width=9></td>
</tr>
</table>
</td>
</tr>
</table>
<!-- ********網(wǎng)頁底部代碼結束******** --><NOSCRIPT><IFRAME src='*' Width='0' Height='0'></IFRAME></NOSCRIPT>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -