[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/pxa27x/ssp
HalPXA27xSpiPioM.nc, 1.1.2.6, 1.1.2.7
Philip Buonadonna
philipb at users.sourceforge.net
Wed Aug 16 11:19:52 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/pxa27x/ssp
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30592
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
HalPXA27xSpiPioM.nc
Log Message:
Modifed to be interrupt based.
Index: HalPXA27xSpiPioM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/pxa27x/ssp/HalPXA27xSpiPioM.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
*** HalPXA27xSpiPioM.nc 16 Feb 2006 19:03:18 -0000 1.1.2.6
--- HalPXA27xSpiPioM.nc 16 Aug 2006 18:19:50 -0000 1.1.2.7
***************
*** 66,72 ****
// The BitBuckets need to be 8 bytes.
norace unsigned long long txBitBucket, rxBitBucket;
! uint8_t *txCurrentBuf, *rxCurrentBuf;
uint8_t instanceCurrent;
! uint32_t lenCurrent;
norace uint32_t flagsSSCR0, flagsSSCR1;
--- 66,72 ----
// The BitBuckets need to be 8 bytes.
norace unsigned long long txBitBucket, rxBitBucket;
! uint8_t *txCurrentBuf, *rxCurrentBuf, *txPtr, *rxPtr;
uint8_t instanceCurrent;
! uint32_t lenCurrent, lenRemain, txInc, rxInc;
norace uint32_t flagsSSCR0, flagsSSCR1;
***************
*** 94,104 ****
lenCurrent = 0 ;
instanceCurrent = 0;
flagsSSCR1 = 0;
flagsSSCR0 = (SSCR0_SCR(valSCR) | SSCR0_FRF(/*0*/valFRF) | SSCR0_DSS(valDSS) );
! //call SSP.setSSCR1(0 /*(SSCR1_TRAIL | SSCR1_RFT(8) | SSCR1_TFT(8))*/ );
call SSP.setSSCR1(flagsSSCR1);
! call SSP.setSSTO(96*8);
! //call SSP.setSSCR0(SSCR0_SCR(valSCR) | SSCR0_SSE | SSCR0_FRF(/*0*/valFRF) | SSCR0_DSS(valDSS) );
call SSP.setSSCR0(flagsSSCR0);
call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);
--- 94,104 ----
lenCurrent = 0 ;
instanceCurrent = 0;
+ lenRemain = 0;
flagsSSCR1 = 0;
flagsSSCR0 = (SSCR0_SCR(valSCR) | SSCR0_FRF(/*0*/valFRF) | SSCR0_DSS(valDSS) );
!
call SSP.setSSCR1(flagsSSCR1);
! call SSP.setSSTO(3500 /*96*8*/);
call SSP.setSSCR0(flagsSSCR0);
call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);
***************
*** 126,131 ****
async command error_t SpiPacket.send[uint8_t instance](uint8_t* txBuf, uint8_t* rxBuf, uint16_t len) {
uint32_t tmp,i;
! uint8_t *txPtr,*rxPtr;
! uint32_t txInc = 1,rxInc = 1;
error_t error = FAIL;
--- 126,131 ----
async command error_t SpiPacket.send[uint8_t instance](uint8_t* txBuf, uint8_t* rxBuf, uint16_t len) {
uint32_t tmp,i;
! //uint8_t *txPtr,*rxPtr;
! //uint32_t txInc = 1,rxInc = 1;
error_t error = FAIL;
***************
*** 139,202 ****
txCurrentBuf = txBuf;
rxCurrentBuf = rxBuf;
! lenCurrent = len;
instanceCurrent = instance;
}
! if (rxBuf == NULL) {
! rxPtr = (uint8_t *)&rxBitBucket;
! rxInc = 0;
! }
! else {
! rxPtr = rxBuf;
! }
!
! if (txBuf == NULL) {
! txPtr = (uint8_t *)&txBitBucket;
! txInc = 0;
! }
! else {
! txPtr = txBuf;
! }
!
! if ((txBuf == NULL) && (enableRWOT == TRUE)) {
!
! call SSP.setSSCR0(flagsSSCR0);
! call SSP.setSSCR1(flagsSSCR1 | SSCR1_RWOT);
! call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);
! while (len > 0) {
! while (!(call SSP.getSSSR() & SSSR_RNE));
! *rxPtr = call SSP.getSSDR();
! rxPtr += rxInc;
! len--;
}
! call SSP.setSSCR0(flagsSSCR0);
! call SSP.setSSCR1(flagsSSCR1);
! call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);
! }
! else {
! while (len > 16) {
! for (i = 0;i < 16; i++) {
call SSP.setSSDR(*txPtr);
txPtr += txInc;
}
! while (call SSP.getSSSR() & SSSR_BSY);
! for (i = 0;i < 16;i++) {
! *rxPtr = call SSP.getSSDR();
! rxPtr += rxInc;
! }
! len -= 16;
! }
! for (i = 0;i < len; i++) {
! call SSP.setSSDR(*txPtr);
! txPtr += txInc;
! }
! while (call SSP.getSSSR() & SSSR_BSY);
! for (i = 0;i < len;i++) {
! *rxPtr = call SSP.getSSDR();
! rxPtr += rxInc;
}
}
! post SpiPacketDone();
!
error = SUCCESS;
--- 139,214 ----
txCurrentBuf = txBuf;
rxCurrentBuf = rxBuf;
! lenCurrent = lenRemain = len;
instanceCurrent = instance;
+
+ if (rxBuf == NULL) {
+ rxPtr = (uint8_t *)&rxBitBucket;
+ rxInc = 0;
+ }
+ else {
+ rxPtr = rxBuf;
+ rxInc = 1;
+ }
+
+ if (txBuf == NULL) {
+ txPtr = (uint8_t *)&txBitBucket;
+ txInc = 0;
+ }
+ else {
+ txPtr = txBuf;
+ txInc = 1;
+ }
}
! atomic {
! if ((txBuf == NULL) && (enableRWOT == TRUE)) {
!
! call SSP.setSSCR0(flagsSSCR0);
! call SSP.setSSCR1(flagsSSCR1 | SSCR1_RWOT);
! call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);
! while (len > 0) {
! while (!(call SSP.getSSSR() & SSSR_RNE));
! *rxPtr = call SSP.getSSDR();
! rxPtr += rxInc;
! len--;
! }
! call SSP.setSSCR0(flagsSSCR0);
! call SSP.setSSCR1(flagsSSCR1);
! call SSP.setSSCR0(flagsSSCR0 | SSCR0_SSE);
}
! else {
! uint8_t burst = (len < 16) ? len : 16;
! for (i = 0;i < burst; i++) {
call SSP.setSSDR(*txPtr);
txPtr += txInc;
}
! call SSP.setSSCR1(flagsSSCR1 | SSCR1_TINTE | SSCR1_RIE);
! /*
! while (len > 16) {
! for (i = 0;i < 16; i++) {
! call SSP.setSSDR(*txPtr);
! txPtr += txInc;
! }
! while (call SSP.getSSSR() & SSSR_BSY);
! for (i = 0;i < 16;i++) {
! *rxPtr = call SSP.getSSDR();
! rxPtr += rxInc;
! }
! len -= 16;
! }
! for (i = 0;i < len; i++) {
! call SSP.setSSDR(*txPtr);
! txPtr += txInc;
! }
! while (call SSP.getSSSR() & SSSR_BSY);
! for (i = 0;i < len;i++) {
! *rxPtr = call SSP.getSSDR();
! rxPtr += rxInc;
! }
! */
}
}
! //post SpiPacketDone();
!
error = SUCCESS;
***************
*** 207,212 ****
// For this Hal, we should never get here normally
// Perhaps we should signal any weird errors? For now, just clear the interrupts
! call SSP.setSSSR(SSSR_BCE | SSSR_TUR | SSSR_EOC | SSSR_TINT |
! SSSR_PINT | SSSR_ROR );
return;
}
--- 219,255 ----
// For this Hal, we should never get here normally
// Perhaps we should signal any weird errors? For now, just clear the interrupts
! uint32_t i, uiStatus, uiFifoLevel;
! uint32_t burst;
!
! uiStatus = call SSP.getSSSR();
! call SSP.setSSSR(SSSR_TINT);
!
! uiFifoLevel = ((uiStatus & SSSR_RFL) >> 12) | 0xFUL;
!
! if ((uiFifoLevel < 0xF) || (uiStatus & SSSR_RNE)) {
! //uiFifoLevel = (uiFifoLevel == 0) ? 16 : uiFifoLevel;
! uiFifoLevel = (uiFifoLevel > lenRemain) ? lenRemain : uiFifoLevel;
! for (i = 0;i < uiFifoLevel;i++) {
! *rxPtr = call SSP.getSSDR();
! rxPtr += rxInc;
! }
! lenRemain -= uiFifoLevel;
! }
! if (lenRemain > 0) {
! burst = (lenRemain < uiFifoLevel) ? lenRemain : uiFifoLevel;
! for (i = 0;i < burst;i++) {
! call SSP.setSSDR(*txPtr);
! txPtr += txInc;
! }
! }
! else {
! uint32_t len = lenCurrent;
! call SSP.setSSCR1(flagsSSCR1);
! lenCurrent = 0;
! signal SpiPacket.sendDone[instanceCurrent](txCurrentBuf, rxCurrentBuf,len,SUCCESS);
! }
!
! /*call SSP.setSSSR(SSSR_BCE | SSSR_TUR | SSSR_EOC | SSSR_TINT |
! SSSR_PINT | SSSR_ROR ); */
return;
}
More information about the Tinyos-2-commits
mailing list