[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/pxa27x/uart
HalPXA27xSerialP.nc, 1.1.2.5, 1.1.2.6
Philip Buonadonna
philipb at users.sourceforge.net
Wed Oct 18 17:47:09 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/pxa27x/uart
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv15314/uart
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
HalPXA27xSerialP.nc
Log Message:
Updated to support current UART interfaces
Index: HalPXA27xSerialP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/pxa27x/uart/HalPXA27xSerialP.nc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** HalPXA27xSerialP.nc 17 Jul 2006 18:42:01 -0000 1.1.2.5
--- HalPXA27xSerialP.nc 19 Oct 2006 00:47:07 -0000 1.1.2.6
***************
*** 62,67 ****
*/
/**
! * Implements the SerialByteComm interface over an 8,N,1 configuration
! * of a PXA27x UART usingin PIO.
*
* @param defaultRate Default baud rate for the serial port.
--- 62,68 ----
*/
/**
! * Implements the UartByte, UartStream and HalPXA27xSerialPacket interface
! * for a PXA27x UART.
! *
*
* @param defaultRate Default baud rate for the serial port.
***************
*** 78,82 ****
interface Init;
interface StdControl;
! interface SerialByteComm;
interface HalPXA27xSerialPacket;
interface HalPXA27xSerialCntl;
--- 79,84 ----
interface Init;
interface StdControl;
! interface UartByte;
! interface UartStream;
interface HalPXA27xSerialPacket;
interface HalPXA27xSerialCntl;
***************
*** 97,100 ****
--- 99,105 ----
uint8_t *txCurrentBuf, *rxCurrentBuf;
uint32_t lenCurrent;
+ bool gbUsingUartStreamSendIF = FALSE;
+ bool gbUsingUartStreamRcvIF = FALSE;
+ bool gbRcvIntEnabled = FALSE;
command error_t Init.init() {
***************
*** 103,106 ****
--- 108,115 ----
atomic {
call UARTInit.init();
+ txCurrentBuf = rxCurrentBuf = NULL;
+ gbUsingUartStreamSendIF = FALSE;
+ gbUsingUartStreamRcvIF = FALSE;
+ gbRcvIntEnabled = FALSE;
}
call TxDMA.setMap(call UARTTxDMAInfo.getMapIndex());
***************
*** 128,148 ****
}
! async command error_t SerialByteComm.put(uint8_t data) {
atomic call UART.setTHR(data);
return SUCCESS;
}
! async command error_t HalPXA27xSerialPacket.send(uint8_t *buf, uint16_t len) {
! uint32_t tmp;
uint32_t txAddr;
uint32_t DMAFlags;
! error_t error = FAIL;
atomic {
! txCurrentBuf = buf;
! lenCurrent = len;
}
DMAFlags = (DCMD_FLOWTRG | DCMD_BURST8 | DCMD_WIDTH1 | DCMD_ENDIRQEN
| DCMD_LEN(len) );
--- 137,207 ----
}
! async command error_t UartByte.send(uint8_t data) {
atomic call UART.setTHR(data);
return SUCCESS;
}
! async command error_t UartByte.receive( uint8_t *data, uint8_t timeout) {
! error_t error = FAIL;
! uint8_t t;
! for (t = 0; t < timeout; t++) {
! if (call UART.getLSR() & LSR_DR) {
! *data = call UART.getRBR();
! error = SUCCESS;
! break;
! }
! }
! return error;
! }
! async command error_t UartStream.send( uint8_t* buf, uint16_t len ) {
! error_t error;
! atomic gbUsingUartStreamSendIF = TRUE;
! error = call HalPXA27xSerialPacket.send(buf,len);
! if (!error) {
! atomic gbUsingUartStreamSendIF = FALSE;
! }
! return error;
! }
!
!
! async command error_t UartStream.enableReceiveInterrupt() {
! atomic gbRcvIntEnabled = TRUE;
! return SUCCESS;
! }
!
! async command error_t UartStream.disableReceiveInterrupt() {
! atomic gbRcvIntEnabled = FALSE;
! return SUCCESS;
! }
!
! async command error_t UartStream.receive( uint8_t* buf, uint16_t len ) {
! error_t error;
! atomic gbUsingUartStreamRcvIF = TRUE;
! error = call HalPXA27xSerialPacket.send(buf,len);
! if (!error) {
! atomic gbUsingUartStreamRcvIF = FALSE;
! }
! return error;
! }
!
! async command error_t HalPXA27xSerialPacket.send(uint8_t *buf, uint16_t len) {
uint32_t txAddr;
uint32_t DMAFlags;
! error_t error = SUCCESS;
atomic {
! if (txCurrentBuf == NULL) {
! txCurrentBuf = buf;
! lenCurrent = len;
! }
! else {
! error = FAIL;
! }
}
+ if (error)
+ return error;
+
DMAFlags = (DCMD_FLOWTRG | DCMD_BURST8 | DCMD_WIDTH1 | DCMD_ENDIRQEN
| DCMD_LEN(len) );
***************
*** 161,166 ****
call TxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH);
- error = SUCCESS;
-
return error;
}
--- 220,223 ----
***************
*** 169,182 ****
async command error_t HalPXA27xSerialPacket.receive(uint8_t *buf, uint16_t len,
uint16_t timeout) {
- uint32_t tmp;
uint32_t rxAddr;
uint32_t DMAFlags;
! error_t error = FAIL;
atomic {
! rxCurrentBuf = buf;
! lenCurrent = len;
}
DMAFlags = (DCMD_FLOWSRC | DCMD_BURST8 | DCMD_WIDTH1 | DCMD_ENDIRQEN
| DCMD_LEN(len) );
--- 226,246 ----
async command error_t HalPXA27xSerialPacket.receive(uint8_t *buf, uint16_t len,
uint16_t timeout) {
uint32_t rxAddr;
uint32_t DMAFlags;
! error_t error = SUCCESS;
atomic {
! if (rxCurrentBuf == NULL) {
! rxCurrentBuf = buf;
! lenCurrent = len;
! }
! else {
! error = FAIL;
! }
}
+ if (error)
+ return error;
+
DMAFlags = (DCMD_FLOWSRC | DCMD_BURST8 | DCMD_WIDTH1 | DCMD_ENDIRQEN
| DCMD_LEN(len) );
***************
*** 195,200 ****
call RxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH);
- error = SUCCESS;
-
return error;
--- 259,262 ----
***************
*** 202,211 ****
async event void RxDMA.interruptDMA() {
! uint8_t *pBuf;
call RxDMA.setDCMD(0);
call RxDMA.setDCSR(DCSR_EORINT | DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERRINTR);
! pBuf = signal HalPXA27xSerialPacket.receiveDone(rxCurrentBuf, lenCurrent, SUCCESS);
! if (pBuf) {
! call HalPXA27xSerialPacket.receive(pBuf,lenCurrent,0);
}
return;
--- 264,281 ----
async event void RxDMA.interruptDMA() {
! uint8_t *pBuf = rxCurrentBuf;
! uint16_t len = lenCurrent;
call RxDMA.setDCMD(0);
call RxDMA.setDCSR(DCSR_EORINT | DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERRINTR);
! rxCurrentBuf = NULL;
! if (gbUsingUartStreamRcvIF) {
! gbUsingUartStreamRcvIF = FALSE;
! signal UartStream.receiveDone(pBuf, len, SUCCESS);
! }
! else {
! pBuf = signal HalPXA27xSerialPacket.receiveDone(pBuf, len, SUCCESS);
! if (pBuf) {
! call HalPXA27xSerialPacket.receive(pBuf,lenCurrent,0);
! }
}
return;
***************
*** 213,222 ****
async event void TxDMA.interruptDMA() {
! uint8_t *pBuf;
call TxDMA.setDCMD(0);
call TxDMA.setDCSR(DCSR_EORINT | DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERRINTR);
! pBuf = signal HalPXA27xSerialPacket.sendDone(txCurrentBuf, lenCurrent, SUCCESS);
! if (pBuf) {
! call HalPXA27xSerialPacket.send(pBuf,lenCurrent);
}
return;
--- 283,300 ----
async event void TxDMA.interruptDMA() {
! uint8_t *pBuf = txCurrentBuf;
! uint16_t len = lenCurrent;
call TxDMA.setDCMD(0);
call TxDMA.setDCSR(DCSR_EORINT | DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERRINTR);
! txCurrentBuf = NULL;
! if (gbUsingUartStreamSendIF) {
! gbUsingUartStreamSendIF = FALSE;
! signal UartStream.sendDone(pBuf, len, SUCCESS);
! }
! else {
! pBuf = signal HalPXA27xSerialPacket.sendDone(pBuf, len, SUCCESS);
! if (pBuf) {
! call HalPXA27xSerialPacket.send(pBuf,lenCurrent);
! }
}
return;
***************
*** 300,308 ****
break;
case 1: // TRANSMIT FIFO
- signal SerialByteComm.putDone();
break;
case 2: // RECEIVE FIFO data available
! while (call UART.getLSR() & LSR_DR) {
! signal SerialByteComm.get(call UART.getRBR());
}
break;
--- 378,385 ----
break;
case 1: // TRANSMIT FIFO
break;
case 2: // RECEIVE FIFO data available
! while (gbRcvIntEnabled && (call UART.getLSR() & LSR_DR)) {
! signal UartStream.receivedByte(call UART.getRBR());
}
break;
***************
*** 316,322 ****
}
! default async event void SerialByteComm.get(uint8_t data) { return; }
! default async event void SerialByteComm.putDone() { return; }
default async event uint8_t* HalPXA27xSerialPacket.sendDone(uint8_t *buf,
--- 393,407 ----
}
! default async event void UartStream.sendDone( uint8_t* buf, uint16_t len, error_t error ) {
! return;
! }
! default async event void UartStream.receivedByte(uint8_t data) {
! return;
! }
!
! default async event void UartStream.receiveDone( uint8_t* buf, uint16_t len, error_t error ) {
! return;
! }
default async event uint8_t* HalPXA27xSerialPacket.sendDone(uint8_t *buf,
More information about the Tinyos-2-commits
mailing list