[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/pxa27x/uart
HalPXA27xSerialP.nc, 1.1.2.6, 1.1.2.7
Philip Buonadonna
philipb at users.sourceforge.net
Fri Oct 20 16:19:56 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/pxa27x/uart
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv22239
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
HalPXA27xSerialP.nc
Log Message:
Updated Serial HAL for PXA27X. receivedByte event ENABLED BY DEFAULT for compatibility
Index: HalPXA27xSerialP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/pxa27x/uart/HalPXA27xSerialP.nc,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -d -r1.1.2.6 -r1.1.2.7
*** HalPXA27xSerialP.nc 19 Oct 2006 00:47:07 -0000 1.1.2.6
--- HalPXA27xSerialP.nc 20 Oct 2006 23:19:54 -0000 1.1.2.7
***************
*** 98,105 ****
uint8_t *txCurrentBuf, *rxCurrentBuf;
! uint32_t lenCurrent;
bool gbUsingUartStreamSendIF = FALSE;
bool gbUsingUartStreamRcvIF = FALSE;
! bool gbRcvIntEnabled = FALSE;
command error_t Init.init() {
--- 98,106 ----
uint8_t *txCurrentBuf, *rxCurrentBuf;
! uint32_t txCurrentLen, rxCurrentLen, rxCurrentIdx;
! uint32_t gulFCRShadow;
bool gbUsingUartStreamSendIF = FALSE;
bool gbUsingUartStreamRcvIF = FALSE;
! bool gbRcvByteEvtEnabled = TRUE;
command error_t Init.init() {
***************
*** 111,115 ****
gbUsingUartStreamSendIF = FALSE;
gbUsingUartStreamRcvIF = FALSE;
! gbRcvIntEnabled = FALSE;
}
call TxDMA.setMap(call UARTTxDMAInfo.getMapIndex());
--- 112,117 ----
gbUsingUartStreamSendIF = FALSE;
gbUsingUartStreamRcvIF = FALSE;
! gbRcvByteEvtEnabled = TRUE;
! gulFCRShadow = (FCR_TRFIFOE | FCR_ITL(0)); // FIFO Mode, 1 byte Rx threshold
}
call TxDMA.setMap(call UARTTxDMAInfo.getMapIndex());
***************
*** 119,123 ****
error = call HalPXA27xSerialCntl.configPort(defaultRate,8,NONE,1,FALSE);
! atomic {call UART.setFCR(FCR_TRFIFOE);}
return error;
}
--- 121,126 ----
error = call HalPXA27xSerialCntl.configPort(defaultRate,8,NONE,1,FALSE);
!
! atomic {call UART.setFCR(gulFCRShadow);}
return error;
}
***************
*** 125,129 ****
command error_t StdControl.start() {
atomic {
! call UART.setIER(IER_RAVIE | IER_TIE | IER_UUE);
}
return SUCCESS;
--- 128,132 ----
command error_t StdControl.start() {
atomic {
! call UART.setIER(IER_UUE | IER_RAVIE);
}
return SUCCESS;
***************
*** 139,142 ****
--- 142,146 ----
async command error_t UartByte.send(uint8_t data) {
atomic call UART.setTHR(data);
+ while ((call UART.getLSR() & LSR_TEMT) == 0);
return SUCCESS;
}
***************
*** 159,163 ****
atomic gbUsingUartStreamSendIF = TRUE;
error = call HalPXA27xSerialPacket.send(buf,len);
! if (!error) {
atomic gbUsingUartStreamSendIF = FALSE;
}
--- 163,167 ----
atomic gbUsingUartStreamSendIF = TRUE;
error = call HalPXA27xSerialPacket.send(buf,len);
! if (error) {
atomic gbUsingUartStreamSendIF = FALSE;
}
***************
*** 167,176 ****
async command error_t UartStream.enableReceiveInterrupt() {
! atomic gbRcvIntEnabled = TRUE;
return SUCCESS;
}
async command error_t UartStream.disableReceiveInterrupt() {
! atomic gbRcvIntEnabled = FALSE;
return SUCCESS;
}
--- 171,192 ----
async command error_t UartStream.enableReceiveInterrupt() {
! error_t error = SUCCESS;
! atomic {
! if (rxCurrentBuf == NULL) {
! call UART.setIER(call UART.getIER() | IER_RAVIE);
! }
! gbRcvByteEvtEnabled = TRUE;
! }
return SUCCESS;
}
async command error_t UartStream.disableReceiveInterrupt() {
! atomic {
! // Check to make sure a short stream/packet call isn't in progress
! if ((rxCurrentBuf == NULL) || (rxCurrentLen >= 8)) {
! call UART.setIER(call UART.getIER() & ~IER_RAVIE);
! }
! gbRcvByteEvtEnabled = FALSE;
! }
return SUCCESS;
}
***************
*** 179,184 ****
error_t error;
atomic gbUsingUartStreamRcvIF = TRUE;
! error = call HalPXA27xSerialPacket.send(buf,len);
! if (!error) {
atomic gbUsingUartStreamRcvIF = FALSE;
}
--- 195,200 ----
error_t error;
atomic gbUsingUartStreamRcvIF = TRUE;
! error = call HalPXA27xSerialPacket.receive(buf,len,0);
! if (error) {
atomic gbUsingUartStreamRcvIF = FALSE;
}
***************
*** 194,198 ****
if (txCurrentBuf == NULL) {
txCurrentBuf = buf;
! lenCurrent = len;
}
else {
--- 210,214 ----
if (txCurrentBuf == NULL) {
txCurrentBuf = buf;
! txCurrentLen = len;
}
else {
***************
*** 204,223 ****
return error;
! DMAFlags = (DCMD_FLOWTRG | DCMD_BURST8 | DCMD_WIDTH1 | DCMD_ENDIRQEN
| DCMD_LEN(len) );
! txAddr = (uint32_t) buf;
! DMAFlags |= DCMD_INCSRCADDR;
!
! call TxDMA.setDCSR(DCSR_NODESCFETCH);
! call TxDMA.setDSADR(txAddr);
! call TxDMA.setDTADR(call UARTTxDMAInfo.getAddr());
! call TxDMA.setDCMD(DMAFlags);
!
! call UART.setIER(IER_UUE | IER_DMAE);
! call UART.setFCR(FCR_TRFIFOE | FCR_ITL(1));
!
! call TxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH);
!
return error;
}
--- 220,254 ----
return error;
! if (len < 8) {
! uint16_t i;
! // Use PIO. Invariant: FIFO is empty
! atomic {
! gulFCRShadow |= FCR_TIL;
! call UART.setFCR(gulFCRShadow);
! }
! for (i = 0;i < len;i++) {
! call UART.setTHR(buf[i]);
! }
! atomic call UART.setIER(call UART.getIER() | IER_TIE);
! }
! else {
! // Use DMA
! DMAFlags = (DCMD_FLOWTRG | DCMD_BURST8 | DCMD_WIDTH1 | DCMD_ENDIRQEN
| DCMD_LEN(len) );
+
+ txAddr = (uint32_t) buf;
+ DMAFlags |= DCMD_INCSRCADDR;
+
+ call TxDMA.setDCSR(DCSR_NODESCFETCH);
+ call TxDMA.setDSADR(txAddr);
+ call TxDMA.setDTADR(call UARTTxDMAInfo.getAddr());
+ call TxDMA.setDCMD(DMAFlags);
+
+ atomic {
+ call UART.setIER(call UART.getIER() | IER_DMAE);
+ }
! call TxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH);
! }
return error;
}
***************
*** 233,237 ****
if (rxCurrentBuf == NULL) {
rxCurrentBuf = buf;
! lenCurrent = len;
}
else {
--- 264,269 ----
if (rxCurrentBuf == NULL) {
rxCurrentBuf = buf;
! rxCurrentLen = len;
! rxCurrentIdx = 0;
}
else {
***************
*** 243,271 ****
return error;
! DMAFlags = (DCMD_FLOWSRC | DCMD_BURST8 | DCMD_WIDTH1 | DCMD_ENDIRQEN
| DCMD_LEN(len) );
! rxAddr = (uint32_t) buf;
! DMAFlags |= DCMD_INCTRGADDR;
! call RxDMA.setDCSR(DCSR_NODESCFETCH);
! call RxDMA.setDTADR(rxAddr);
! call RxDMA.setDSADR(call UARTRxDMAInfo.getAddr());
! call RxDMA.setDCMD(DMAFlags);
!
! call UART.setIER(IER_UUE | IER_DMAE);
! call UART.setFCR(FCR_TRFIFOE | FCR_ITL(1));
!
! call RxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH);
!
return error;
-
}
! 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) {
--- 275,313 ----
return error;
! if (len < 8) {
! // Use PIO. Invariant: FIFO is empty
! atomic {
! gulFCRShadow = ((gulFCRShadow & ~(FCR_ITL(3))) | FCR_ITL(0));
! call UART.setFCR(gulFCRShadow);
! call UART.setIER(call UART.getIER() | IER_RAVIE);
! }
! }
! else {
! // Use DMA
! DMAFlags = (DCMD_FLOWSRC | DCMD_BURST8 | DCMD_WIDTH1 | DCMD_ENDIRQEN
| DCMD_LEN(len) );
+
+ rxAddr = (uint32_t) buf;
+ DMAFlags |= DCMD_INCTRGADDR;
+
+ call RxDMA.setDCSR(DCSR_NODESCFETCH);
+ call RxDMA.setDTADR(rxAddr);
+ call RxDMA.setDSADR(call UARTRxDMAInfo.getAddr());
+ call RxDMA.setDCMD(DMAFlags);
! atomic {
! gulFCRShadow = ((gulFCRShadow & ~(FCR_ITL(3))) | FCR_ITL(1));
! call UART.setFCR(gulFCRShadow);
! call UART.setIER((call UART.getIER() & ~IER_RAVIE) | IER_DMAE);
! }
! call RxDMA.setDCSR(DCSR_RUN | DCSR_NODESCFETCH);
! }
return error;
}
! void DispatchStreamRcvSignal() {
uint8_t *pBuf = rxCurrentBuf;
! uint16_t len = rxCurrentLen;
rxCurrentBuf = NULL;
if (gbUsingUartStreamRcvIF) {
***************
*** 276,280 ****
pBuf = signal HalPXA27xSerialPacket.receiveDone(pBuf, len, SUCCESS);
if (pBuf) {
! call HalPXA27xSerialPacket.receive(pBuf,lenCurrent,0);
}
}
--- 318,322 ----
pBuf = signal HalPXA27xSerialPacket.receiveDone(pBuf, len, SUCCESS);
if (pBuf) {
! call HalPXA27xSerialPacket.receive(pBuf,len,0);
}
}
***************
*** 282,290 ****
}
! 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) {
--- 324,330 ----
}
! void DispatchStreamSendSignal() {
uint8_t *pBuf = txCurrentBuf;
! uint16_t len = txCurrentLen;
txCurrentBuf = NULL;
if (gbUsingUartStreamSendIF) {
***************
*** 295,299 ****
pBuf = signal HalPXA27xSerialPacket.sendDone(pBuf, len, SUCCESS);
if (pBuf) {
! call HalPXA27xSerialPacket.send(pBuf,lenCurrent);
}
}
--- 335,339 ----
pBuf = signal HalPXA27xSerialPacket.sendDone(pBuf, len, SUCCESS);
if (pBuf) {
! call HalPXA27xSerialPacket.send(pBuf,len);
}
}
***************
*** 301,304 ****
--- 341,360 ----
}
+ async event void RxDMA.interruptDMA() {
+ call RxDMA.setDCMD(0);
+ call RxDMA.setDCSR(DCSR_EORINT | DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERRINTR);
+ DispatchStreamRcvSignal();
+ if (gbRcvByteEvtEnabled)
+ call UART.setIER(call UART.getIER() | IER_RAVIE);
+ return;
+ }
+
+ async event void TxDMA.interruptDMA() {
+ call TxDMA.setDCMD(0);
+ call TxDMA.setDCSR(DCSR_EORINT | DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERRINTR);
+ DispatchStreamSendSignal();
+ return;
+ }
+
async command error_t HalPXA27xSerialCntl.configPort(uint32_t baudrate,
***************
*** 361,365 ****
atomic {
! call UART.setFCR(FCR_RESETTF | FCR_RESETRF);
}
--- 417,421 ----
atomic {
! call UART.setFCR(gulFCRShadow | FCR_RESETTF | FCR_RESETRF);
}
***************
*** 369,373 ****
async event void UART.interruptUART() {
uint8_t error, intSource;
!
intSource = call UART.getIIR();
intSource &= IIR_IID_MASK;
--- 425,430 ----
async event void UART.interruptUART() {
uint8_t error, intSource;
! uint8_t ucByte;
!
intSource = call UART.getIIR();
intSource &= IIR_IID_MASK;
***************
*** 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;
--- 435,454 ----
break;
case 1: // TRANSMIT FIFO
+ call UART.setIER(call UART.getIER() & ~IER_TIE);
+ DispatchStreamSendSignal();
break;
case 2: // RECEIVE FIFO data available
! while (call UART.getLSR() & LSR_DR) {
! ucByte = call UART.getRBR();
!
! if (rxCurrentBuf != NULL) {
! rxCurrentBuf[rxCurrentIdx] = ucByte;
! rxCurrentIdx++;
! if (rxCurrentIdx >= rxCurrentLen)
! DispatchStreamRcvSignal();
! }
! else if (gbRcvByteEvtEnabled) {
! signal UartStream.receivedByte(ucByte);
! }
}
break;
More information about the Tinyos-2-commits
mailing list