📄 chap14.c
字号:
// Chapter 14 6805 C programs// Jonathan W. Valvano// This software accompanies the book,// Embedded Microcomputer Systems: Real Time Interfacing// published by Brooks Cole, 1999 // Program 14.1. AART code to receive from an input-only full-duplex AART.// AART full duplex Input only, returns ID:S as 16-bitunsigned int GetAART(unsigned char addr){ // addr specifies which AART unsigned char ID,S; // inputs from AART OutCh(addr|0x80); // activate AART ID=InCh(); // read ID S=InCh(); // read status return((ID<<8)+S);} // return ID:S as 16-bit unsigned int// Program 14.2. AART code to receive from an input-only half-duplex AART.// AART half duplex Input only, returns ID:S as 16-bitunsigned int GetAART(unsigned char addr){ // addr specifies which AART unsigned char ID,S; // inputs from AART OutCh(addr|0x80); // activate AART InCh(); // read echo of previous addr output ID=InCh(); // read ID S=InCh(); // read status return((ID<<8)+S);} // return ID:S as 16-bit unsigned int// Program 14.3. AART code to transmit to an output-only half-duplex AART.// AART full duplex output onlyvoid PutAART(unsigned char addr,data){ // addr specifies which AART OutCh(addr|0x80); // activate AART OutCh(data&0x7F); // send data OutCh(addr|0x80);} // deactivate AART// Program 14.4. AART code to transmit to an output-only half-duplex AART.// AART half duplex output onlyvoid PutAART(unsigned char addr,data){ // addr specifies which AART OutCh(addr|0x80); // activate AART InCh(); // read echo of addr output OutCh(data&0x7F); // send data InCh(); // read echo of data output OutCh(addr|0x80); // deactivate AART InCh();} // read echo of previous output// Program 14.5. AART code to transmit then receive.// AART full duplex Output then Input, returns ID:S as 16-bitunsigned int PutGetAART(unsigned char addr,data){ // addr specifies which AART unsigned char ID,S; // inputs from AART OutCh(addr|0x80); // activate AART OutCh(data&0x7F); // send data ID=InCh(); // read ID S=InCh(); // read status return((ID<<8)+S);} // return ID:S as 16-bit unsigned int// Program 14.7. Bit fifo routines.//********************GetTxBit************************// returns TRUE=1 if successful, FALSE=0 if empty and data not removed// output is boolean 0 means FALSE, nonzero is trueint GetTxBit (unsigned int *datapt) { if (SameBit(PutTxPt,GeTxtPt)) return(0); /* Failed, fifo was empty */ else { *datapt=(*GetTxPt.WPt)&GetTxPt.Mask; GetTxPt.Mask=GetTxPt.Mask>>1; if(GetTxPt.Mask==0) { GetTxPt.Mask=0x8000; ++GetTxPt.WPt; // next word if((GetTxPt.WPt)==&TxFifo[FifoSize]) GetTxPt.WPt=&TxFifo[0];} // wrap return(1); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -