



下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、uart 操作的程序佚名/ 2008-09-18 t3c25-v5 僅售 880元uart 操作的程序作者:轉(zhuǎn)載#include config.h /*define uarts data structure*/ typedef struct uartmode uint8 datab; / byte length uint8 stopb; / stop bit,1/2 uint8 parity; / parity bit setting uartmode; uint8 rcv_buf8; uint8 rcv_byte8; volatile uint8 add_data_num; volatile
2、 uint8 rcv_new; /flag for rcving new data volatile uint8 add_data; void _irq irq_uart0(void) uint8 i; if (u0iir & 0 x0f) = 0 x04) rcv_new = 1; for (i = 0; i8; i+) rcv_bufi = u0rbr; / read all the data in fifo once. then there is no too much interruptions if (u0iir & 0 xf) = 0 x0c) add_data_n
3、um = 0; while (u0lsr & 0 x00000001)/ read uarts lsr register first, / and determine whether fifo is empty add_data = 1; / or not. rcv_byteadd_data_num = u0rbr; add_data_num+; vicvectaddr = 0 x00; void uart0_sendbyte(uint8 dat) u0thr = dat; void uart0_sendbuf(void) uint8 i; for (i=0; i8; i+) uart
4、0_sendbyte(rcv_bufi); while (u0lsr & 0 x20) = 0) ; void uart0_sendaddbyte(uint8 j) uint8 i; for (i = 0; i 115200) return (0); if (set.datab 8) return (0); if (set.stopb = 0)|(set.stopb 2) return (0); if (set.parity 4) return (0); /*set uarts baud rate*/ u0lcr = 0 x80; /dlab = 1 bak = (fpclk 4)/b
5、aud; u0dlm = bak 8; u0dll = bak &0 xff; /*set uarts mode*/ bak = set.datab - 5; if (set.stopb = 2) bak |= 0 x04; if (set.parity != 0) set.parity = set.parity - 1; bak |= 0 x08; bak |= set.parity 4; u0lcr = bak; return (1); int main (void) / add user source code uartmode set; set.datab = 8; set.s
6、topb = 1; set.parity = 0; rcv_new = 0; pinsel0 = (pinsel0 & 0 xfffffff0) | 0 x5; uart0_init(115200, set); u0fcr = 0 x81; u0ier = 0 x01; irqenable(); /*enable uart0 interruption*/ vicintselect = 0 x00000000; vicvectcntl0 = 0 x20|0 x06; vicvectaddr0 = (uint32)irq_uart0; vicintenable = 10 x06; /enable uart0s interruption while (1) if (rcv_new = 1) rcv_new
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 超強脫氧劑項目投資可行性研究分析報告(2024-2030版)
- 中國太陽能蓄電池行業(yè)發(fā)展監(jiān)測及投資戰(zhàn)略咨詢報告
- 安平行業(yè)報告
- 蕭山區(qū)公共場所管理辦法
- 蕉城市公益捐贈管理辦法
- 蛋糕廠生產(chǎn)管理辦法制度
- 衡東縣加裝電梯管理辦法
- 衢江區(qū)水庫流轉(zhuǎn)管理辦法
- 西安市應(yīng)急物資管理辦法
- 規(guī)劃局項目落位管理辦法
- 電動車維修與保養(yǎng)考核試卷
- 隧道突泥涌水應(yīng)急培訓(xùn)
- 2025-2030中國氣象服務(wù)行業(yè)市場前景趨勢及競爭格局與投資研究報告
- 2025年心理咨詢師職業(yè)倫理心得體會
- 《人工智能通識基礎(chǔ)》全套教學課件
- A3報告解析課件
- 2024年煤礦安全規(guī)程(修訂)
- 外研版六年級上冊英語全冊教學課件
- 廣西壯族自治區(qū)南寧市2024-2025學年九年級上學期期末道德與法治試題(含答案)
- 企業(yè)迎檢工作要點
- 2025年度汽車維修配件股份合作協(xié)議4篇
評論
0/150
提交評論