tinyos8051wg-commit Mailing List for tinyos8051wg (Page 2)
Status: Alpha
Brought to you by:
mleopold
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
(23) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(6) |
Sep
(20) |
Oct
(4) |
Nov
(1) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(8) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <qz...@us...> - 2009-09-07 09:19:26
|
Revision: 1083 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1083&view=rev Author: qzban Date: 2009-09-07 09:18:57 +0000 (Mon, 07 Sep 2009) Log Message: ----------- New UART code with added generic support for TinyOS 2.x UartByte, UartStream and SerialFlush. Only implemented on the nano platform, as it still needs testing! Modified Paths: -------------- trunk/diku/mcs51/tos/platforms/nano/PlatformSerialC.nc trunk/diku/mcs51/tos/platforms/nano/UartC.nc Removed Paths: ------------- trunk/diku/mcs51/tos/platforms/nano/PlatformUartC.nc Modified: trunk/diku/mcs51/tos/platforms/nano/PlatformSerialC.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/nano/PlatformSerialC.nc 2009-09-07 09:18:21 UTC (rev 1082) +++ trunk/diku/mcs51/tos/platforms/nano/PlatformSerialC.nc 2009-09-07 09:18:57 UTC (rev 1083) @@ -36,17 +36,17 @@ interface StdControl; interface UartStream; interface UartByte; - interface SerialFlush; - interface SerialByteComm; } } implementation { - components GenericUartC; + components GenericUartC, + GenericUartP; + GenericUartC.UartControl -> GenericUartP.StdControl; + GenericUartC.Uart -> GenericUartP.Uart; + StdControl = genericUartC.StdControl; UartStream = genericUartC.UartStream; UartByte = genericUartC.UartByte; - SerialFlush = genericUartC.SerialFlush; - SerialByteComm = genericUartC.SerialByteComm; } \ No newline at end of file Deleted: trunk/diku/mcs51/tos/platforms/nano/PlatformUartC.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/nano/PlatformUartC.nc 2009-09-07 09:18:21 UTC (rev 1082) +++ trunk/diku/mcs51/tos/platforms/nano/PlatformUartC.nc 2009-09-07 09:18:57 UTC (rev 1083) @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2009, Jan Flora <jan...@di...> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - Neither the name of the University of Copenhagen nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * This file provides an implementation of the GenericUart interface along with - * a control interface for stopping and starting the GenericUart. The GenericUart - * is used for providing implementations of UartByte, UartStream, SerialByteComm and - * SerialFlush. - * - * @author Jan Flora <jan...@di...> - */ - -configuration PlatformUartC -{ - provides - { - interface StdControl; - interface GenericUart as Uart; - } -} -implementation -{ - components GenericUartP; - - StdControl = GenericUartP.StdControl; - Uart = GenericUartP.Uart; -} \ No newline at end of file Modified: trunk/diku/mcs51/tos/platforms/nano/UartC.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/nano/UartC.nc 2009-09-07 09:18:21 UTC (rev 1082) +++ trunk/diku/mcs51/tos/platforms/nano/UartC.nc 2009-09-07 09:18:57 UTC (rev 1083) @@ -42,15 +42,24 @@ provides { interface SerialByteComm; + interface SerialFlush; + interface UartStream: } } implementation { components MainC, - GenericUartC; + GenericUartC, + GenericUartP; + // Wire the UART HPL + GenericUartC.UartControl -> GenericUartP.StdControl; + GenericUartC.Uart -> GenericUartP.Uart; + // Startup and enable the UART. MainC.SoftwareInit -> GenericUartC.Init; SerialByteComm = GenericUartC.SerialByteComm; + SerialFlush = GenericUartC.SerialFlush; + UartStream = GenericUartC.UartStream; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-09-07 09:18:50
|
Revision: 1082 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1082&view=rev Author: qzban Date: 2009-09-07 09:18:21 +0000 (Mon, 07 Sep 2009) Log Message: ----------- New UART code with added generic support for TinyOS 2.x UartByte, UartStream and SerialFlush. Only implemented on the nano platform, as it still needs testing! Modified Paths: -------------- trunk/diku/common/lib/uart/GenericUartC.nc Modified: trunk/diku/common/lib/uart/GenericUartC.nc =================================================================== --- trunk/diku/common/lib/uart/GenericUartC.nc 2009-09-06 23:53:49 UTC (rev 1081) +++ trunk/diku/common/lib/uart/GenericUartC.nc 2009-09-07 09:18:21 UTC (rev 1082) @@ -41,14 +41,18 @@ interface SerialByteComm; interface SerialFlush; } + uses + { + interface StdControl as UartControl; + interface GenericUart as Uart; + } } implementation { components GenericUartByteP, GenericUartStreamP, GenericSerialByteCommP, - GenericSerialFlushP, - PlatformUartC; + GenericSerialFlushP; // Connect the UART modules. UartByte = GenericUartByteP.UartByte; @@ -58,13 +62,13 @@ Init = GenericSerialByteCommP.Init; // Wire up the UART driver. - StdControl = PlatformUartC.StdControl; + StdControl = UartControl; // It is important that the SerialFlush module get the UART // signals first, as it needs act on the UART being free. - GenericSerialFlushP.Uart -> PlatformUartC.Uart; - GenericUartByteP.Uart -> PlatformUartC.Uart; - GenericUartStreamP.Uart -> PlatformUartC.Uart; - GenericSerialByteCommP.StdControl -> PlatformUartC.StdControl; - GenericSerialByteCommP.Uart -> PlatformUartC.Uart; + GenericSerialFlushP.Uart = Uart; + GenericUartByteP.Uart = Uart; + GenericUartStreamP.Uart = Uart; + GenericSerialByteCommP.StdControl = UartControl; + GenericSerialByteCommP.Uart = Uart; } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-09-07 01:15:07
|
Revision: 1080 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1080&view=rev Author: qzban Date: 2009-09-06 23:49:40 +0000 (Sun, 06 Sep 2009) Log Message: ----------- New UART code with added generic support for TinyOS 2.x UartByte, UartStream and SerialFlush. Only implemented on the nano platform, as it still needs testing! Added Paths: ----------- trunk/diku/common/lib/uart/ trunk/diku/common/lib/uart/GenericSerialByteCommP.nc trunk/diku/common/lib/uart/GenericSerialFlushP.nc trunk/diku/common/lib/uart/GenericUart.nc trunk/diku/common/lib/uart/GenericUartByteP.nc trunk/diku/common/lib/uart/GenericUartC.nc trunk/diku/common/lib/uart/GenericUartStreamP.nc Added: trunk/diku/common/lib/uart/GenericSerialByteCommP.nc =================================================================== --- trunk/diku/common/lib/uart/GenericSerialByteCommP.nc (rev 0) +++ trunk/diku/common/lib/uart/GenericSerialByteCommP.nc 2009-09-06 23:49:40 UTC (rev 1080) @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +module GenericSerialByteCommP +{ + provides + { + interface Init; + interface SerialByteComm; + } + uses + { + interface StdControl; + interface GenericUart as Uart; + } +} +implementation +{ + command error_t Init.init() + { + // We need to be able to startup the UART when using this interface. + call StdControl.start(); + call Uart.enableRx(); + } + + async command error_t SerialByteComm.put(uint8_t data) + { + // TODO: We probably should protect the UART resource to + // prevent problems with other modules. + + return call Uart.transmit(data); + } + + /** + * UART interrupt handlers. + */ + async event void Uart.transmitDone() + { + signal SerialByteComm.putDone(); + } + + async event void Uart.dataReady(uint8_t data) + { + signal SerialByteComm.get(data); + } + + /** + * Default events. + */ + default async event void SerialByteComm.get(uint8_t data) + { + // Do nothing for now. + } + + default async event void SerialByteComm.putDone() + { + // Do nothing for now. + } +} \ No newline at end of file Added: trunk/diku/common/lib/uart/GenericSerialFlushP.nc =================================================================== --- trunk/diku/common/lib/uart/GenericSerialFlushP.nc (rev 0) +++ trunk/diku/common/lib/uart/GenericSerialFlushP.nc 2009-09-06 23:49:40 UTC (rev 1080) @@ -0,0 +1,96 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +module GenericSerialFlushP +{ + provides + { + interface SerialFlush; + } + uses + { + interface GenericUart as Uart; + } +} +implementation +{ + bool waitUartFree = FALSE; + + void checkWaitDone(); + + command void SerialFlush.flush() + { + atomic { + if (call Uart.isActive()) { + waitUartFree = TRUE; + } + } + if (!waitUartFree) { + // Uart is already free. + signal SerialFlush.flushDone(); + } + } + + /** + * UART event handlers + */ + async event void Uart.dataReady(uint8_t data) + { + checkWaitDone(); + } + async event void Uart.transmitDone() + { + checkWaitDone(); + } + + void checkWaitDone() + { + bool wasWaiting; + + atomic { + wasWaiting = waitUartFree; + waitUartFree = FALSE; + } + + if (wasWaiting) { + signal SerialFlush.flushDone(); + + } + } + + /** + * Default event handlers. + */ + default event void SerialFlush.flushDone() + { + // Do nothing for now. + } +} \ No newline at end of file Added: trunk/diku/common/lib/uart/GenericUart.nc =================================================================== --- trunk/diku/common/lib/uart/GenericUart.nc (rev 0) +++ trunk/diku/common/lib/uart/GenericUart.nc 2009-09-06 23:49:40 UTC (rev 1080) @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +interface GenericUart +{ + // Control + async command error_t setBaudRate(uint32_t rate); + async command error_t enableRx(); + async command error_t disableRx(); + async command bool isActive(); + + // Transmit + async command error_t transmit(uint8_t data); + async event void transmitDone(); + + // Receive + async event void dataReady(uint8_t data); +} \ No newline at end of file Added: trunk/diku/common/lib/uart/GenericUartByteP.nc =================================================================== --- trunk/diku/common/lib/uart/GenericUartByteP.nc (rev 0) +++ trunk/diku/common/lib/uart/GenericUartByteP.nc 2009-09-06 23:49:40 UTC (rev 1080) @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +module GenericUartByteP +{ + provides + { + interface UartByte; + } + uses + { + interface GenericUart as Uart; + } +} +implementation +{ + bool sendDone = TRUE; + bool recvDone = TRUE; + uint8_t *recvData; + + async command error_t UartByte.send(uint8_t byte) + { + // TODO: We probably should protect the UART resource to + // prevent problems with other modules. + + error_t status; + bool wasDone = FALSE; + + // Try to transmit the byte. + atomic sendDone = FALSE; + status = call Uart.transmit(byte); + if (status != SUCCESS) { + // Operation failed. + return status; + } + // Block until the operation is done. + // TODO: We should probably go into a wait mode here if + // possible instead of busy waiting. + while (!wasDone) { + atomic wasDone = sendDone; + } + + return SUCCESS; + } + + async command error_t UartByte.receive(uint8_t* byte, uint8_t timeout) + { + // TODO: We probably should protect the UART resource to + // prevent problems with other modules. + // TODO: Implement timeout.. Interface states that "timeout" is + // "byte times" granularity. WTF is that? + + bool wasDone = FALSE; + + atomic { + recvData = byte; + recvDone = FALSE; + } + + // Enable the UART receiver. + call Uart.enableRx(); + + // Block until the operation is done. + // TODO: We should probably go into a wait mode here if + // possible instead of busy waiting. + while (!wasDone) { + atomic wasDone = recvDone; + } + + return SUCCESS; + } + + /** + * UART interrupt handlers. + */ + async event void Uart.transmitDone() + { + atomic sendDone = TRUE; + } + + async event void Uart.dataReady(uint8_t data) + { + atomic { + recvData[0] = data; + recvDone = TRUE; + } + } +} \ No newline at end of file Added: trunk/diku/common/lib/uart/GenericUartC.nc =================================================================== --- trunk/diku/common/lib/uart/GenericUartC.nc (rev 0) +++ trunk/diku/common/lib/uart/GenericUartC.nc 2009-09-06 23:49:40 UTC (rev 1080) @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +configuration GenericUartC +{ + provides + { + // Used for SerialByteComm only. + interface Init; + interface StdControl; + interface UartByte; + interface UartStream; + interface SerialByteComm; + interface SerialFlush; + } +} +implementation +{ + components GenericUartByteP, + GenericUartStreamP, + GenericSerialByteCommP, + GenericSerialFlushP, + PlatformUartC; + + // Connect the UART modules. + UartByte = GenericUartByteP.UartByte; + UartStream = GenericUartStreamP.UartStream; + SerialByteComm = GenericSerialByteCommP.SerialByteComm; + SerialFlush = GenericSerialFlushP.SerialFlush; + Init = GenericSerialByteCommP.Init; + + // Wire up the UART driver. + StdControl = PlatformUartC.StdControl; + // It is important that the SerialFlush module get the UART + // signals first, as it needs act on the UART being free. + GenericSerialFlushP.Uart -> PlatformUartC.Uart; + GenericUartByteP.Uart -> PlatformUartC.Uart; + GenericUartStreamP.Uart -> PlatformUartC.Uart; + GenericSerialByteCommP.StdControl -> PlatformUartC.StdControl; + GenericSerialByteCommP.Uart -> PlatformUartC.Uart; + +} \ No newline at end of file Added: trunk/diku/common/lib/uart/GenericUartStreamP.nc =================================================================== --- trunk/diku/common/lib/uart/GenericUartStreamP.nc (rev 0) +++ trunk/diku/common/lib/uart/GenericUartStreamP.nc 2009-09-06 23:49:40 UTC (rev 1080) @@ -0,0 +1,195 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +module GenericUartStreamP +{ + provides + { + interface UartStream; + } + uses + { + interface GenericUart as Uart; + } +} +implementation +{ + bool rxInt = FALSE; + bool isReceiving = FALSE; + bool isSending = FALSE; + + // The following variables are protected by "isReceiving". + norace uint8_t *rxBuf; + norace uint16_t rxLen; + norace uint16_t bytesReceived; + + // The following variables are protected by "isSending". + norace uint8_t *txBuf; + norace uint16_t txLen; + norace uint16_t bytesSend; + + async command error_t UartStream.enableReceiveInterrupt() + { + atomic rxInt = TRUE; + return SUCCESS; + } + + async command error_t UartStream.disableReceiveInterrupt() + { + atomic rxInt = FALSE; + return SUCCESS; + } + + async command error_t UartStream.send(uint8_t* buf, uint16_t len) + { + bool wasSending; + error_t status; + + // Check if the UART is available. + // TODO: We probably should protect the UART resource to + // prevent problems with other modules. + atomic { + wasSending = isSending; + isSending = TRUE; + } + if (wasSending) { + // Operation is already in progress. + return FAIL; + } + + // Setup a new transmission. + bytesSend = 0; + txBuf = buf; + txLen = len; + + status = call Uart.transmit(txBuf[0]); + if (status != SUCCESS) { + // Operation never started. + atomic isSending = FALSE; + } + return status; + } + + async command error_t UartStream.receive(uint8_t* buf, uint16_t len) + { + bool wasReceiving; + + // Check if the UART is available. + // TODO: We probably should protect the UART resource to + // prevent problems with other modules. + atomic { + wasReceiving = isReceiving; + isReceiving = TRUE; + } + if (wasReceiving) { + // Operation is already in progress. + return FAIL; + } + + // Setup a new reception. + bytesReceived = 0; + rxBuf = buf; + rxLen = len; + + // Enable the UART receiver. + call Uart.enableRx(); + } + + /** + * UART interrupt handlers + */ + + async event void Uart.transmitDone() + { + bool wasSending; + error_t status; + + atomic wasSending = isSending; + + if (wasSending) { + bytesSend++; + // Check if we are done. + if (bytesSend >= txLen) { + // We are done. + signal UartStream.sendDone(txBuf, bytesSend, SUCCESS); + atomic isSending = FALSE; + } else { + // Transmit next byte. + status = call Uart.transmit(txBuf[bytesSend]); + if (status != SUCCESS) { + // Transmission failed. + signal UartStream.sendDone(txBuf, bytesSend, status); + atomic isSending = FALSE; + } + } + } + } + + async event void Uart.dataReady(uint8_t data) + { + bool doSignal, wasReceiving; + + // Do byte reception signalling if appropriate. + atomic doSignal = rxInt; + if (doSignal) { + signal UartStream.receivedByte(data); + } + + atomic wasReceiving = isReceiving; + + if (wasReceiving) { + // Receive operation is in progress. + rxBuf[bytesReceived++] = data; + if (bytesReceived >= rxLen) { + // Disable the UART receiver. + call Uart.disableRx(); + // We are done. + signal UartStream.receiveDone(rxBuf, bytesReceived, SUCCESS); + atomic isReceiving = FALSE; + } + } + } + + default async event void UartStream.sendDone(uint8_t* buf, uint16_t len, error_t error) + { + // Do nothing for now. + } + + default async event void UartStream.receivedByte(uint8_t byte) + { + // Do nothing for now. + } + + default async event void UartStream.receiveDone(uint8_t* buf, uint16_t len, error_t error) + { + // Do nothing for now. + } +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-09-06 23:54:29
|
Revision: 1081 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1081&view=rev Author: qzban Date: 2009-09-06 23:53:49 +0000 (Sun, 06 Sep 2009) Log Message: ----------- Remove __attributes that are not catched in the HCS08 mangle-script Modified Paths: -------------- trunk/diku/freescale/support/make/CodeWarrior/hcs08MangleAppC.pl Modified: trunk/diku/freescale/support/make/CodeWarrior/hcs08MangleAppC.pl =================================================================== --- trunk/diku/freescale/support/make/CodeWarrior/hcs08MangleAppC.pl 2009-09-06 23:49:40 UTC (rev 1080) +++ trunk/diku/freescale/support/make/CodeWarrior/hcs08MangleAppC.pl 2009-09-06 23:53:49 UTC (rev 1081) @@ -120,6 +120,9 @@ $absolute_address_count--; } + # Remove attributes that has not been processed. + s{(__attribute(?:__)?\s*\(\(.*\)\))}{/*$1*/}g; + $sourceCode .= $_; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-09-06 23:49:34
|
Revision: 1079 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1079&view=rev Author: qzban Date: 2009-09-06 23:49:06 +0000 (Sun, 06 Sep 2009) Log Message: ----------- New UART code with added generic support for TinyOS 2.x UartByte, UartStream and SerialFlush. Only implemented on the nano platform, as it still needs testing! Modified Paths: -------------- trunk/diku/mcs51/tos/chips/cc2430/CC2430Clock.h trunk/diku/mcs51/tos/chips/cc2430/ioCC2430.h trunk/diku/mcs51/tos/chips/cc2430/usart/serial.h trunk/diku/mcs51/tos/chips/mcs51/README trunk/diku/mcs51/tos/platforms/nano/UartC.nc Added Paths: ----------- trunk/diku/mcs51/tos/chips/cc2430/usart/GenericUartP.nc trunk/diku/mcs51/tos/platforms/nano/PlatformSerialC.nc trunk/diku/mcs51/tos/platforms/nano/PlatformUartC.nc Modified: trunk/diku/mcs51/tos/chips/cc2430/CC2430Clock.h =================================================================== --- trunk/diku/mcs51/tos/chips/cc2430/CC2430Clock.h 2009-09-06 23:45:12 UTC (rev 1078) +++ trunk/diku/mcs51/tos/chips/cc2430/CC2430Clock.h 2009-09-06 23:49:06 UTC (rev 1079) @@ -54,36 +54,4 @@ TIMER_TICK_250KHZ = CC2430_TICKF_DIV_128, }; - #define BAUD_E(rate) ( \ - (rate==2400UL) ? 6 + SYSCLK : \ - (rate==4800UL) ? 7 + SYSCLK : \ - (rate==9600UL) ? 8 + SYSCLK : \ - (rate==14400UL) ? 8 + SYSCLK : \ - (rate==19200UL) ? 9 + SYSCLK : \ - (rate==28800UL) ? 9 + SYSCLK : \ - (rate==38400UL) ? 10 + SYSCLK : \ - (rate==57600UL) ? 10 + SYSCLK : \ - (rate==76800UL) ? 11 + SYSCLK : \ - (rate==115200UL) ? 11 + SYSCLK : \ - (rate==153600UL) ? 12 + SYSCLK : \ - (rate==230400UL) ? 12 + SYSCLK : \ - (rate==307200UL) ? 13 + SYSCLK : \ - 0 ) - - #define BAUD_M(rate) ( \ - (rate==2400UL) ? 59 : \ - (rate==4800UL) ? 59 : \ - (rate==9600UL) ? 59 : \ - (rate==14400UL) ? 216 : \ - (rate==19200UL) ? 59 : \ - (rate==28800UL) ? 216 : \ - (rate==38400UL) ? 59 : \ - (rate==57600UL) ? 216 : \ - (rate==76800UL) ? 59 : \ - (rate==115200UL) ? 216 : \ - (rate==153600UL) ? 59 : \ - (rate==230400UL) ? 216 : \ - (rate==307200UL) ? 59 : \ - 0 ) - #endif \ No newline at end of file Modified: trunk/diku/mcs51/tos/chips/cc2430/ioCC2430.h =================================================================== --- trunk/diku/mcs51/tos/chips/cc2430/ioCC2430.h 2009-09-06 23:45:12 UTC (rev 1078) +++ trunk/diku/mcs51/tos/chips/cc2430/ioCC2430.h 2009-09-06 23:49:06 UTC (rev 1079) @@ -52,6 +52,7 @@ * * * @author Martin Leopold <le...@di...> + * @author Jan Flora <jan...@di...> */ #ifndef _H_ioCC2430_H @@ -60,6 +61,43 @@ // Get sfr/sbit dummy definitions # include <io8051.h> +/** + * UART bit locations for non-bit-addressable SFRs + */ + +// UxCSR: USART Control and Status register +enum { + CC2430_UxCSR_MODE = 0x7, + CC2430_UxCSR_RE = 0x6, + CC2430_UxCSR_SLAVE = 0x5, + CC2430_UxCSR_FE = 0x4, + CC2430_UxCSR_ERR = 0x3, + CC2430_UxCSR_RX_BYTE = 0x2, + CC2430_UxCSR_TX_BYTE = 0x1, + CC2430_UxCSR_ACTIVE = 0x0 +}; + +// UxUCR: USART Control register +enum { + CC2430_UxUCR_FLUSH = 0x7, + CC2430_UxUCR_FLOW = 0x6, + CC2430_UxUCR_D9 = 0x5, + CC2430_UxUCR_BIT9 = 0x4, + CC2430_UxUCR_PARITY = 0x3, + CC2430_UxUCR_SPB = 0x2, + CC2430_UxUCR_STOP = 0x1, + CC2430_UxUCR_START = 0x0 +}; + +// UxGCR: USART Generic Control register +enum { + CC2430_UxGCR_CPOL = 0x7, + CC2430_UxGCR_CPHA = 0x6, + CC2430_UxGCR_ORDER = 0x5, + CC2430_UxGCR_BAUD_E = 0x4 +}; + + /* * Bit locations for IEN0 */ Added: trunk/diku/mcs51/tos/chips/cc2430/usart/GenericUartP.nc =================================================================== --- trunk/diku/mcs51/tos/chips/cc2430/usart/GenericUartP.nc (rev 0) +++ trunk/diku/mcs51/tos/chips/cc2430/usart/GenericUartP.nc 2009-09-06 23:49:06 UTC (rev 1079) @@ -0,0 +1,182 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +// TODO: Make this module generic so that we can support both UARTs +// through the same module. Right now, only UART 0 is supported. + +#include <serial.h> + +module GenericUartP +{ + provides + { + interface StdControl; + interface GenericUart as Uart; + } +} +implementation +{ + bool busy = FALSE; + + command error_t StdControl.start() + { + // Make Keil do the right stuff. + ser_rate_t fakeBaud = USART_BAUD_RATE; + + // PERCFG selects beween alternative pin mappings for the + // peripherals. PERCFG.U0CFG selects Uart0 as part + // of port0 (U0CFG=0) or port1 (U0CFG=1) + PERCFG &= ~0x1u; + // Map pin P0.2 to RX and pin P0.3 to TX + P0_ALT |= 0x0Cu; // Aka P0SEL + + // Set default baud rate. + call Uart.setBaudRate(fakeBaud*75ul); + + // Set mode to UART. + U0CSR |= _BV(CC2430_UxCSR_MODE); + // Flush the UART. + U0UCR |= _BV(CC2430_UxUCR_STOP) | _BV(CC2430_UxUCR_FLUSH); + + // Clear any pending interrupts flags + UTX0IF = 0; + URX0IF = 0; + + // Disable the transmit interrupt + IEN2 &= ~_BV(CC2430_IEN2_UTX0IE); + + // Disable the receive interrupt + URX0IE = 0; + + // Disable the receiver. + U0CSR &= ~_BV(CC2430_UxCSR_RE); + + return SUCCESS; + } + + command error_t StdControl.stop() + { + // Disable the transmit interrupt + IEN2 &= ~_BV(CC2430_IEN2_UTX0IE); + + // Disable the receive interrupt + URX0IE = 0; + + // Disable the receiver. + U0CSR &= ~_BV(CC2430_UxCSR_RE); + + return SUCCESS; + } + + async command error_t Uart.setBaudRate(uint32_t rate) + { + // Configure baud rate. + U0GCR = BAUD_E(rate); + U0BAUD = BAUD_M(rate); + + return SUCCESS; + } + + async command bool Uart.isActive() + { + return U0CSR & _BV(CC2430_UxCSR_ACTIVE); + } + + async command error_t Uart.enableRx() + { + // Enable the receiver + U0CSR |= _BV(CC2430_UxCSR_RE); + // Clear interrupt flag + URX0IF = 0; + // Enable interrupts + URX0IE = 1; + } + + async command error_t Uart.disableRx() + { + // Disable the receiver + U0CSR &= ~_BV(CC2430_UxCSR_RE); + // Clear interrupt flag + URX0IF = 0; + // Disable interrupts + URX0IE = 0; + } + + async command error_t Uart.transmit(uint8_t data) __attribute((reentrant)) + { + bool wasBusy; + + atomic { + wasBusy = busy; + busy = TRUE; + } + + // Check if the UART is free. + if (wasBusy) return EBUSY; + + // Clear the tx interrupt flag and + // enable the tx interrupt. + UTX0IF = 0; + IEN2 |= _BV(CC2430_IEN2_UTX0IE); + + // Write data to the UART. + U0BUF = data; + return SUCCESS; + } + + MCS51_INTERRUPT(SIG_UTX0) + { + // Clear the tx interrupt flag and disable + // the tx interrupt. + UTX0IF = 0; + IEN2 &= ~_BV(CC2430_IEN2_UTX0IE); + + // Release the resource. + atomic busy = FALSE; + + signal Uart.transmitDone(); + } + + MCS51_INTERRUPT(SIG_URX0) + { + // Clear the rx interrupt flag. + URX0IF = 0; + + signal Uart.dataReady(U0BUF); + } + + /** + * Default events + */ + default async event void Uart.dataReady(uint8_t data) { return; } + default async event void Uart.transmitDone() { return; } + +} \ No newline at end of file Modified: trunk/diku/mcs51/tos/chips/cc2430/usart/serial.h =================================================================== --- trunk/diku/mcs51/tos/chips/cc2430/usart/serial.h 2009-09-06 23:45:12 UTC (rev 1078) +++ trunk/diku/mcs51/tos/chips/cc2430/usart/serial.h 2009-09-06 23:49:06 UTC (rev 1079) @@ -35,37 +35,69 @@ * This file defines the allowed serial settings * * @author Martin Leopold <le...@po...> - * + * @author Jan Flora <jan...@di...> */ #ifndef _H_SERIAL_H #define _H_SERIAL_H -/** - * The enums are defined as multiples of 75 since Keil can't handle - * large constant enums - */ -typedef enum { - B75=1u, - B150=2U, - B300=4U, - B600=8U, - B1200=16U, - B1800=24U, - B2400=32U, - B4800=64U, - B9600=128U, - B19200=256U, - B38400=512U, - B57600=768U, - B76800=1024U, - B115200=1536U, - B230400=3072U, - B460800=6144U, - B576000=7680U, - B921600=12288U, - B1152000=15360U, - B3000000=40000U, -} ser_rate_t; + /** + * The enums are defined as multiples of 75 since Keil can't handle + * large constant enums + */ + typedef enum { + B75=1u, + B150=2U, + B300=4U, + B600=8U, + B1200=16U, + B1800=24U, + B2400=32U, + B4800=64U, + B9600=128U, + B19200=256U, + B38400=512U, + B57600=768U, + B76800=1024U, + B115200=1536U, + B230400=3072U, + B460800=6144U, + B576000=7680U, + B921600=12288U, + B1152000=15360U, + B3000000=40000U, + } ser_rate_t; + + #define BAUD_E(rate) ( \ + (rate==2400UL) ? 6 + SYSCLK : \ + (rate==4800UL) ? 7 + SYSCLK : \ + (rate==9600UL) ? 8 + SYSCLK : \ + (rate==14400UL) ? 8 + SYSCLK : \ + (rate==19200UL) ? 9 + SYSCLK : \ + (rate==28800UL) ? 9 + SYSCLK : \ + (rate==38400UL) ? 10 + SYSCLK : \ + (rate==57600UL) ? 10 + SYSCLK : \ + (rate==76800UL) ? 11 + SYSCLK : \ + (rate==115200UL) ? 11 + SYSCLK : \ + (rate==153600UL) ? 12 + SYSCLK : \ + (rate==230400UL) ? 12 + SYSCLK : \ + (rate==307200UL) ? 13 + SYSCLK : \ + 0 ) + + #define BAUD_M(rate) ( \ + (rate==2400UL) ? 59 : \ + (rate==4800UL) ? 59 : \ + (rate==9600UL) ? 59 : \ + (rate==14400UL) ? 216 : \ + (rate==19200UL) ? 59 : \ + (rate==28800UL) ? 216 : \ + (rate==38400UL) ? 59 : \ + (rate==57600UL) ? 216 : \ + (rate==76800UL) ? 59 : \ + (rate==115200UL) ? 216 : \ + (rate==153600UL) ? 59 : \ + (rate==230400UL) ? 216 : \ + (rate==307200UL) ? 59 : \ + 0 ) #endif //_H_SERIAL_H Modified: trunk/diku/mcs51/tos/chips/mcs51/README =================================================================== --- trunk/diku/mcs51/tos/chips/mcs51/README 2009-09-06 23:45:12 UTC (rev 1078) +++ trunk/diku/mcs51/tos/chips/mcs51/README 2009-09-06 23:49:06 UTC (rev 1079) @@ -12,9 +12,9 @@ This directory contains a generic implementation of the most commenly seen devices shared among many 8051 variants. At the time of writing this -one of the popular availabe software blocks for SoC production is the +one of the popular available software blocks for SoC production is the the DW8051 MacroCell from Synopsys. This is known to be used by the nRF24E1 -devcie, and is likely to be used in other devices. +device, and is likely to be used in other devices. -In addition there is a bunch of dummy system includes to provent NescC +In addition there is a bunch of dummy system includes to prevent NescC from including the ones from libc (which won't work with Keil). \ No newline at end of file Added: trunk/diku/mcs51/tos/platforms/nano/PlatformSerialC.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/nano/PlatformSerialC.nc (rev 0) +++ trunk/diku/mcs51/tos/platforms/nano/PlatformSerialC.nc 2009-09-06 23:49:06 UTC (rev 1079) @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +configuration PlatformSerialC +{ + provides + { + interface StdControl; + interface UartStream; + interface UartByte; + interface SerialFlush; + interface SerialByteComm; + } +} +implementation +{ + components GenericUartC; + + StdControl = genericUartC.StdControl; + UartStream = genericUartC.UartStream; + UartByte = genericUartC.UartByte; + SerialFlush = genericUartC.SerialFlush; + SerialByteComm = genericUartC.SerialByteComm; +} \ No newline at end of file Added: trunk/diku/mcs51/tos/platforms/nano/PlatformUartC.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/nano/PlatformUartC.nc (rev 0) +++ trunk/diku/mcs51/tos/platforms/nano/PlatformUartC.nc 2009-09-06 23:49:06 UTC (rev 1079) @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * This file provides an implementation of the GenericUart interface along with + * a control interface for stopping and starting the GenericUart. The GenericUart + * is used for providing implementations of UartByte, UartStream, SerialByteComm and + * SerialFlush. + * + * @author Jan Flora <jan...@di...> + */ + +configuration PlatformUartC +{ + provides + { + interface StdControl; + interface GenericUart as Uart; + } +} +implementation +{ + components GenericUartP; + + StdControl = GenericUartP.StdControl; + Uart = GenericUartP.Uart; +} \ No newline at end of file Modified: trunk/diku/mcs51/tos/platforms/nano/UartC.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/nano/UartC.nc 2009-09-06 23:45:12 UTC (rev 1078) +++ trunk/diku/mcs51/tos/platforms/nano/UartC.nc 2009-09-06 23:49:06 UTC (rev 1079) @@ -46,8 +46,11 @@ } implementation { - components MainC, HalCC2430SimpleUartC; - MainC.SoftwareInit -> HalCC2430SimpleUartC; - - SerialByteComm = HalCC2430SimpleUartC; + components MainC, + GenericUartC; + + // Startup and enable the UART. + MainC.SoftwareInit -> GenericUartC.Init; + + SerialByteComm = GenericUartC.SerialByteComm; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-09-06 23:45:43
|
Revision: 1078 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1078&view=rev Author: qzban Date: 2009-09-06 23:45:12 +0000 (Sun, 06 Sep 2009) Log Message: ----------- Some older Tiny15four changes. Modified Paths: -------------- trunk/diku/tiny15four/apps/non_beacon_test/ping/ping.nc trunk/diku/tiny15four/apps/non_beacon_test/ping/pingM.nc trunk/diku/tiny15four/apps/non_beacon_test/pong/pongM.nc trunk/diku/tiny15four/apps/radioTest/RadioTestP.nc trunk/diku/tiny15four/apps/timerTest/TimerTestP.nc trunk/diku/tiny15four/tos/chips/cc2430/HPLTimerP.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/MacTimerP.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430InterruptHandlerP.nc trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyDriverM.nc trunk/diku/tiny15four/tos/interfaces/debug/BufferedUart.nc trunk/diku/tiny15four/tos/interfaces/debug/ConsoleInput.nc trunk/diku/tiny15four/tos/interfaces/debug/ConsoleOutput.nc trunk/diku/tiny15four/tos/lib/debug/BufferedUartP.nc trunk/diku/tiny15four/tos/lib/debug/CommandInterpreterP.nc trunk/diku/tiny15four/tos/lib/debug/ConsoleP.nc trunk/diku/tiny15four/tos/lib/debug/DebugConsoleC.nc trunk/diku/tiny15four/tos/lib/debug/DebugConsoleP.nc trunk/diku/tiny15four/tos/lib/mac/AssociateM.nc trunk/diku/tiny15four/tos/lib/mac/CallbackServiceM.nc trunk/diku/tiny15four/tos/lib/mac/CapControlM.nc trunk/diku/tiny15four/tos/lib/mac/CsmaM.nc trunk/diku/tiny15four/tos/lib/mac/IndirectTxM.nc trunk/diku/tiny15four/tos/lib/mac/MacAddressM.nc trunk/diku/tiny15four/tos/lib/mac/MacFrameM.nc trunk/diku/tiny15four/tos/lib/mac/RxEnableM.nc trunk/diku/tiny15four/tos/lib/mac/ScanServiceM.nc trunk/diku/tiny15four/tos/lib/mac/SuperframeM.nc trunk/diku/tiny15four/tos/lib/macApi/ADTModules/SduM.nc trunk/diku/tiny15four/tos/lib/timing/AsyncAlarmM.nc trunk/diku/tiny15four/tos/lib/timing/LocalTimeM.nc trunk/diku/tiny15four/tos/lib/timing/VirtualSymbolChannelM.nc trunk/diku/tiny15four/tos/lib/timing/VirtualSymbolCounterM.nc trunk/diku/tiny15four/tos/lib/tools/FIFOQueueM.nc trunk/diku/tiny15four/tos/lib/tools/SimpleBufferManM.nc Added Paths: ----------- trunk/diku/tiny15four/tos/platforms/cc2430em/ trunk/diku/tiny15four/tos/platforms/cc2430em/CC2430ClockConfig.h trunk/diku/tiny15four/tos/platforms/cc2430em/PlatformInitC.nc trunk/diku/tiny15four/tos/platforms/cc2430em/platform.t15f trunk/diku/tiny15four/tos/platforms/cc2430em/time.h Modified: trunk/diku/tiny15four/apps/non_beacon_test/ping/ping.nc =================================================================== --- trunk/diku/tiny15four/apps/non_beacon_test/ping/ping.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/apps/non_beacon_test/ping/ping.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -41,6 +41,7 @@ components MainC, DebugC, Tiny15FourC, + LedsC, pingM; // Wire standard control @@ -55,6 +56,7 @@ Tiny15FourC.Debug -> DebugC.Debug; pingM.Debug -> DebugC.Debug; pingM.CommandInterpreter -> DebugC.CommandInterpreter; + pingM.Leds -> LedsC.Leds; // Wire interface pingM.IeeePanDescriptor -> Tiny15FourC; Modified: trunk/diku/tiny15four/apps/non_beacon_test/ping/pingM.nc =================================================================== --- trunk/diku/tiny15four/apps/non_beacon_test/ping/pingM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/apps/non_beacon_test/ping/pingM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -63,6 +63,7 @@ // Debugging interface CommandInterpreter; interface Debug; + interface Leds; } } implementation @@ -91,6 +92,8 @@ uint8_t myMsduHandle = 0x01; Ieee_Address coordAddr; + uint8_t pingRetry; + // Forward declarations of helper functions. task void doPing(); task void doPoll(); @@ -101,6 +104,7 @@ command error_t Init.init() { + call Leds.led0On(); // Setup extended address for the device. NTOUH64(myAddr, aExtendedAddress); @@ -135,6 +139,8 @@ event void Boot.booted() { + uint16_t i = 0xFFFF; + while(i--); call CommandInterpreter.prompt(); } @@ -181,7 +187,13 @@ DBG_STR("Ping transmitted.",1); post doPoll(); } else { - DBG_STR("Ping failed.",1); + if (pingRetry--) { + // We try to ping again. + post doPing(); + } else { + DBG_STR("Ping failed.",1); + call CommandInterpreter.prompt(); + } } call McpsDataRequestConfirm.destroy(confirm); @@ -222,6 +234,7 @@ myMsduHandle++; } else { DBG_STR("Transmission of ping failed.",1); + call CommandInterpreter.prompt(); } // Clean up. @@ -243,6 +256,7 @@ } else { DBG_STR("Association failed.",1); DBG_STRINT("Status was: ",status,1); + call CommandInterpreter.prompt(); } call MlmeAssociateRequestConfirm.destroy(confirm); @@ -263,11 +277,12 @@ call MlmeAssociateRequestConfirm.setLogicalChannel(request, logicalChannel); call MlmeAssociateRequestConfirm.setCapabilityInformation(request,IEEE802154_CapInfoAllocAddr); - if (call MlmeRequestConfirmAssociate.request(request)) + if (SUCCESS == call MlmeRequestConfirmAssociate.request(request)) { DBG_STR("Associating to PAN",1); } else { DBG_STR("Could not request association to PAN...",1); + call CommandInterpreter.prompt(); } } @@ -285,6 +300,7 @@ processScan(confirm); } else { DBG_STR("Scan failed.",1); + call CommandInterpreter.prompt(); } call MlmeScanRequestConfirm.destroy(confirm); @@ -333,7 +349,7 @@ } } - void doScan() + void doScan() __attribute((reentrant)) { Mlme_ScanRequestConfirm request; @@ -341,6 +357,9 @@ TOSH_SET_PROFILING4_PIN(); #endif + // Setup retry count + pingRetry = 0x03; + // Create the scan request // Scan channels 12 - 15 call MlmeScanRequestConfirm.create(&request); @@ -355,6 +374,7 @@ else { DBG_STR("Could not start scan...",1); + call CommandInterpreter.prompt(); } } @@ -374,6 +394,7 @@ post doPoll(); } else { DBG_STRINT("Poll failed: ",status,1); + call CommandInterpreter.prompt(); } call MlmePollRequestConfirm.destroy(confirm); @@ -402,6 +423,7 @@ DBG_STR("Polled coordinator.",1); } else { DBG_STR("Poll request failed.",1); + call CommandInterpreter.prompt(); } } Modified: trunk/diku/tiny15four/apps/non_beacon_test/pong/pongM.nc =================================================================== --- trunk/diku/tiny15four/apps/non_beacon_test/pong/pongM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/apps/non_beacon_test/pong/pongM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -92,6 +92,8 @@ uint8_t myMsduHandle = 0x01; Ieee_Address pingReplyAddr; + uint8_t retryCount; + // Forward declarations of helper functions. task void pingReply(); void startPan(); @@ -164,6 +166,7 @@ if (payloadLen == 5 && 0 == strcmp("ping", payload)) { DBG_STR("Received a ping request.",1); call McpsDataIndication.getSrcAddress(indication, pingReplyAddr); + retryCount = 0x03; post pingReply(); } else { DBG_STR("Ignoring data received different from ping request.",1); @@ -186,7 +189,11 @@ if (status == IEEE802154_SUCCESS) { DBG_STR("Ping reply transmitted.",1); } else { - DBG_STR("Ping reply failed.",1); + if (retryCount--) { + post pingReply(); + } else { + DBG_STR("Ping reply failed.",1); + } } call McpsDataRequestConfirm.destroy(confirm); @@ -287,7 +294,7 @@ PAN coordinator role handling *******************************/ - void startPan() + void startPan() __attribute((reentrant)) { Mlme_StartRequestConfirm request; Modified: trunk/diku/tiny15four/apps/radioTest/RadioTestP.nc =================================================================== --- trunk/diku/tiny15four/apps/radioTest/RadioTestP.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/apps/radioTest/RadioTestP.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -113,7 +113,7 @@ call PhyReceive.initRxBuffer(frameBuf); } - void toggleReceiver() + void toggleReceiver() __attribute((reentrant)) { if (receiverOn) { call PhyReceive.rxOff(); @@ -129,7 +129,7 @@ call CommandInterpreter.prompt(); } - void togglePromiscuous() + void togglePromiscuous() __attribute((reentrant)) { if (promiscuous) { call PhyFiltering.setPromiscuousMode(FALSE); @@ -143,7 +143,7 @@ call CommandInterpreter.prompt(); } - async event void PhyTransmit.txDone(phy_error_t error, uint8_t txId) + async event void PhyTransmit.txDone(phy_error_t error, uint8_t txId) __attribute((reentrant)) { switch (txId) { case 1: @@ -175,14 +175,14 @@ call CommandInterpreter.prompt(); } - async event uint8_t *PhyReceive.dataReady(rxdata_t *data) + async event uint8_t *PhyReceive.dataReady(rxdata_t *data) __attribute((reentrant)) { DBG_STR("Frame received",1); DBG_DUMP(data->frame, data->length,1); return data->frame; } - void transmit() + void transmit() __attribute((reentrant)) { txData.commenceTime = call LocalTime.getTime() + 0xF0; @@ -190,7 +190,7 @@ call PhyTransmit.tx(&txData); } - void transmitDataFrame() + void transmitDataFrame() __attribute((reentrant)) { txData.txId = 2; txData.frame = dataFrame; @@ -201,7 +201,7 @@ call PhyTransmit.tx(&txData); } - void toggleCca() + void toggleCca() __attribute((reentrant)) { if (ccaEnabled) { txData.cca = FALSE; @@ -215,7 +215,7 @@ call CommandInterpreter.prompt(); } - void toggleDefer() + void toggleDefer() __attribute((reentrant)) { if (deferEnabled) { txData.immediateCommence = TRUE; Modified: trunk/diku/tiny15four/apps/timerTest/TimerTestP.nc =================================================================== --- trunk/diku/tiny15four/apps/timerTest/TimerTestP.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/apps/timerTest/TimerTestP.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -66,9 +66,10 @@ time_t targetTime; time_t interval = 0x98968; uint8_t iteration = 1; + bool test = FALSE; command error_t Init.init() - { + { call CommandInterpreter.addCommand("start", startTimer); call CommandInterpreter.addCommand("time", showTime); return SUCCESS; Modified: trunk/diku/tiny15four/tos/chips/cc2430/HPLTimerP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/HPLTimerP.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/chips/cc2430/HPLTimerP.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -87,7 +87,7 @@ return SUCCESS; } - async command uint16_t Counter.getTime() + async command uint16_t Counter.getTime() __attribute((reentrant)) { uint16_t now; atomic { @@ -108,7 +108,7 @@ T1CNTL = 0; } - async command error_t Channel.arm(uint8_t id, uint16_t timeStamp) + async command error_t Channel.arm(uint8_t id, uint16_t timeStamp) __attribute((reentrant)) { switch (id) { case 0: Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/MacTimerP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/MacTimerP.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/MacTimerP.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -53,10 +53,10 @@ command error_t Init.init() { - uint8_t t2conf; + //uint8_t t2conf; - t2conf = T2CNF; - DBG_STRINT("Timer 2 config is: ",t2conf,1); + //t2conf = T2CNF; + //DBG_STRINT("Timer 2 config is: ",t2conf,1); // Make sure the timer is stopped. T2CNF &= ~_BV(CC2430_T2CNF_RUN); Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430InterruptHandlerP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430InterruptHandlerP.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430InterruptHandlerP.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -76,7 +76,6 @@ // Flush the FIFO. RFST = ISFLUSHRX; RFST = ISFLUSHTX; - } MCS51_INTERRUPT(SIG_RF) Modified: trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyDriverM.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyDriverM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyDriverM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -56,6 +56,8 @@ } implementation { + #define RADIO_DEBUG + // Methods for fast register access. #include "mc13192RegisterAccess.h" @@ -71,6 +73,19 @@ #define DBG_MIN_LEVEL 1 #include "Debug.h" + #ifdef RADIO_DEBUG + // Set up profiling pins. + TOSH_ASSIGN_PIN(DBG_1, C, 5); + TOSH_ASSIGN_PIN(DBG_2, C, 6); + TOSH_ASSIGN_PIN(DBG_3, C, 7); + TOSH_ASSIGN_PIN(DBG_4, G, 3); + TOSH_ASSIGN_PIN(DBG_5, G, 1); + TOSH_ASSIGN_PIN(DBG_6, B, 7); + TOSH_ASSIGN_PIN(DBG_7, B, 3); + TOSH_ASSIGN_PIN(DBG_8, B, 2); + TOSH_ASSIGN_PIN(DBG_9, B, 1); + #endif + // Phy attribute variables. norace uint8_t curChannel = 11; @@ -148,10 +163,33 @@ command error_t Init.init() { + #ifdef RADIO_DEBUG + // Setup profiling pins as output pins. + TOSH_MAKE_DBG_1_OUTPUT(); + TOSH_MAKE_DBG_2_OUTPUT(); + TOSH_MAKE_DBG_3_OUTPUT(); + TOSH_MAKE_DBG_4_OUTPUT(); + TOSH_MAKE_DBG_5_OUTPUT(); + TOSH_MAKE_DBG_6_OUTPUT(); + TOSH_MAKE_DBG_7_OUTPUT(); + TOSH_MAKE_DBG_8_OUTPUT(); + TOSH_MAKE_DBG_9_OUTPUT(); + + // Clear all pins. + TOSH_CLR_DBG_1_PIN(); + TOSH_CLR_DBG_2_PIN(); + TOSH_CLR_DBG_3_PIN(); + TOSH_CLR_DBG_4_PIN(); + TOSH_CLR_DBG_5_PIN(); + TOSH_CLR_DBG_6_PIN(); + TOSH_CLR_DBG_7_PIN(); + TOSH_CLR_DBG_8_PIN(); + TOSH_CLR_DBG_9_PIN(); + #endif + // Synchronize radio and MCU time. call MCUTime.reset(); call Timer.resetEventTime(); - return SUCCESS; } @@ -498,6 +536,26 @@ DBG_DUMP(rxPacket.frame,rxPacket.length,4); return FALSE; } + // Check if we are receiving an odd length frame. + if (nextByte+1 == lastByte) { + // Last byte is only available for 32 symbol periods! + // We busy-wait for the irq flag to go up. + #ifdef RADIO_DEBUG + TOSH_SET_DBG_1_PIN(); + #endif + + while(!IRQ_FLAG_SET); + + #ifdef RADIO_DEBUG + TOSH_CLR_DBG_1_PIN(); + #endif + + TOSH_CLR_RADIO_CE_PIN(); + call SPI.fastWriteByte(RX_PKT_RAM|0x80); + call SPI.fastReadWordSwapped(nextByte); + TOSH_SET_RADIO_CE_PIN(); + nextByte++; + } } else { // Transmit mode. Supply next word. TOSH_CLR_RADIO_CE_PIN(); @@ -946,6 +1004,7 @@ inline void ackFailed() { // We were waiting for an ACK, but it never arrived. + atomic ackedOperation = FALSE; abortReceive(); if (receiverOn) enableReceiver(TRUE); signal PhyTransmit.txDone(PHY_ACK_FAIL, txId); Modified: trunk/diku/tiny15four/tos/interfaces/debug/BufferedUart.nc =================================================================== --- trunk/diku/tiny15four/tos/interfaces/debug/BufferedUart.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/interfaces/debug/BufferedUart.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -32,6 +32,6 @@ interface BufferedUart { - async command error_t send( const uint8_t *data ); - async event void get( uint8_t data ); + async command error_t send( uint8_t data ); + async event void get( uint8_t *data ); } \ No newline at end of file Modified: trunk/diku/tiny15four/tos/interfaces/debug/ConsoleInput.nc =================================================================== --- trunk/diku/tiny15four/tos/interfaces/debug/ConsoleInput.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/interfaces/debug/ConsoleInput.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -5,6 +5,6 @@ it to get any data send remotely to the uart/pipe/whatever. @param data Value received @return Just return SUCCESS */ - async event void get(uint8_t data); + async event void get(uint8_t *data); } Modified: trunk/diku/tiny15four/tos/interfaces/debug/ConsoleOutput.nc =================================================================== --- trunk/diku/tiny15four/tos/interfaces/debug/ConsoleOutput.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/interfaces/debug/ConsoleOutput.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -49,20 +49,6 @@ async command int printHex(const uint8_t c); /** - * Format value as a hex string and put it into the output buffer. - * @param c Numberical value to be formatted and printed. - * @return Number of bytes actually buffered. - */ - async command int printHexword(const uint16_t c); - - /** - * Format value as a hex string and put it into the output buffer. - * @param c Numberical value to be formatted and printed. - * @return Number of bytes actually buffered. - */ - async command int printHexlong(const uint32_t c); - - /** * Put an array of hex values into the buffer, formatted as a string. * @param ptr[] Array of values to be formatted and printed. * @param count Length of array. Modified: trunk/diku/tiny15four/tos/lib/debug/BufferedUartP.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/debug/BufferedUartP.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/debug/BufferedUartP.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -26,9 +26,10 @@ */ /** + * This module adds a buffering scheme on top of the traditional + * TinyOS SerialByteComm interface. + * * @author Jan Flora <jan...@di...> - * - * A buffered UART. */ module BufferedUartP @@ -47,81 +48,84 @@ implementation { #ifndef UART_TX_BUFFER_SIZE - #define UART_TX_BUFFER_SIZE 200U - #endif - - // Internal send buffer. - uint8_t txBuffer[UART_TX_BUFFER_SIZE]; - FIFOQueue_t txQueue; - - bool isSending = FALSE; - - // Forward declarations - void moveDataToUart(); + #define UART_TX_BUFFER_SIZE 200U + #endif + #ifndef UART_RX_BUFFER_SIZE + #define UART_RX_BUFFER_SIZE 80U + #endif + + // Internal send buffer. + uint8_t txBuffer[UART_TX_BUFFER_SIZE]; + FIFOQueue_t txQueue; + // Internal receive buffer. + char rxBuffer[UART_RX_BUFFER_SIZE]; + uint8_t rxBufPointer = 0; + bool acceptingInput = TRUE; + + void startTransmit(); + command error_t Init.init() { // Initialize the transmission queue. call FIFOQueue.initQueue(&txQueue, txBuffer, UART_TX_BUFFER_SIZE); - return SUCCESS; } - async command error_t BufferedUart.send( const uint8_t *data ) + async command error_t BufferedUart.send( uint8_t data ) __attribute((reentrant)) { - bool wasSending; - - // Make sure the data fits inside the internal buffer. - if (call FIFOQueue.isFull(&txQueue)) { - return FAIL; - } + error_t res = SUCCESS; - // Copy data to internal buffer. - call FIFOQueue.enqueue(&txQueue, *data); - - atomic { - wasSending = isSending; - isSending = TRUE; - } - if (!wasSending) { - moveDataToUart(); - } - - return SUCCESS; + // Enqueue the data and try to startup transmission. + res = call FIFOQueue.enqueue(&txQueue, data); + startTransmit(); + return res; } - void moveDataToUart() + void startTransmit() __attribute((reentrant)) { uint8_t data = 0; - // Move data to the UART. - call FIFOQueue.dequeue(&txQueue, &data); - call Uart.put(data); + if (SUCCESS == call FIFOQueue.peek(&txQueue, &data)) { + // Transmit the next byte. + if (SUCCESS == call Uart.put(data)) { + // Dequeue the transmitted byte. + call FIFOQueue.dequeue(&txQueue, &data); + } + } } async event void Uart.putDone() { - bool stillSending; + startTransmit(); + } + + async event void Uart.get( uint8_t data ) + { + if (!acceptingInput) return; - atomic { - // Only keep sending if buffer is non-empty - isSending = !(call FIFOQueue.isEmpty(&txQueue)); - stillSending = isSending; + // NOTE: Make room for null termination of the input string. + if (data != '\n' && rxBufPointer < UART_RX_BUFFER_SIZE-1) { + // Just add data to the receive buffer. + rxBuffer[rxBufPointer++] = data; + return; } - // Check if we are still transmitting. - if (stillSending) { - // Transmit the next byte. - moveDataToUart(); - } + // If we end up here, we have a complete line of input or + // an overflow condition. Either way, we treat this as a + // valid input. + // Insert string termination. + rxBuffer[rxBufPointer] = 0; + // Don't accept any new input while processing is going on. + atomic acceptingInput = FALSE; - //signal BufferedUart. + // Submit the new data for processing. + signal BufferedUart.get(rxBuffer); + + // Reset the buffer pointer. + rxBufPointer = 0; + atomic acceptingInput = TRUE; } - - async event void Uart.get( uint8_t data ) - { - signal BufferedUart.get(data); - } - default async event void BufferedUart.get(uint8_t data) {} + default async event void BufferedUart.get(uint8_t *data) {} } \ No newline at end of file Modified: trunk/diku/tiny15four/tos/lib/debug/CommandInterpreterP.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/debug/CommandInterpreterP.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/debug/CommandInterpreterP.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -34,7 +34,6 @@ */ #define MAX_INTERPRETED_COMMANDS 10 -#define INPUT_BUFFER_SIZE 80 module CommandInterpreterP { @@ -50,8 +49,6 @@ } implementation { - char inputBuffer[INPUT_BUFFER_SIZE]; - uint8_t bufPointer = 0; bool acceptingInput = TRUE; const char *identifiers[MAX_INTERPRETED_COMMANDS]; @@ -76,61 +73,50 @@ atomic acceptingInput = TRUE; } - async event void Input.get(uint8_t data) + async event void Input.get(uint8_t *data) { bool wasAcceptingInput; uint8_t i=0; + + // Stop accepting input until "prompt" is called. + atomic { + wasAcceptingInput = acceptingInput; + acceptingInput = FALSE; + } + // Check if we are accepting input. - atomic wasAcceptingInput = acceptingInput; if (!wasAcceptingInput) return; - - if (data == '\n') { - // Stop accepting input until "prompt" is called. - atomic acceptingInput = FALSE; - // Insert string termination. - inputBuffer[bufPointer] = 0; - // Execute the command. - for (i=0; i<identifierCount; i++) { - if (!strcmp(identifiers[i],inputBuffer)) { - // Execute the callback function. - callbacks[i](); - bufPointer = 0; - return; - } + + // Execute the command. + for (i=0; i<identifierCount; i++) { + if (!strcmp(identifiers[i],data)) { + // Execute the callback function. + callbacks[i](); + return; } - // Command was not found.. - inputBuffer[bufPointer] = 0; - call Output.print("Unknown command: '"); - call Output.print(inputBuffer); - call Output.print("'...\n"); - call Output.print("Known commands are: \n"); - for (i=0; i<identifierCount; i++) { - call Output.print(identifiers[i]); - call Output.print("\n"); - } - bufPointer = 0; - call Interpreter.prompt(); - return; } - // Just add data to the input buffer. - // NOTE: Make room for null termination of the input string. - if (bufPointer < INPUT_BUFFER_SIZE-1) { - inputBuffer[bufPointer++] = data; - } else { - bufPointer = 0; - call Output.print("Input too large!\n"); + + // Command was not found.. + call Output.print("Unknown command: '"); + call Output.print(data); + call Output.print("'...\n"); + call Output.print("Known commands are: \n"); + for (i=0; i<identifierCount; i++) { + call Output.print(identifiers[i]); + call Output.print("\n"); } + + call Interpreter.prompt(); + return; } // Help function, does string compare int strcmp(const char * a, const char * b) { - uint8_t i = 1; while (*a && *b && *a == *b) { ++a; ++b; - ++i; } return *a - *b; Modified: trunk/diku/tiny15four/tos/lib/debug/ConsoleP.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/debug/ConsoleP.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/debug/ConsoleP.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -1,28 +1,27 @@ -/* - Console module - module that buffers and perhaps eventually will do some - printf like thing. - Copyright (C) 2002 Mads Bondo Dydensborg <ma...@di...> +/** + * Copyright (C) 2002 Mads Bondo Dydensborg <ma...@di...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - /** * Simple Console component that uses Uart interface. * <p>This configuration maps onto the uart that is normally used to connect onto * a pc.</p> - * + * @author Mads Bondo Dydensborg <ma...@di...> + * @author Jan Flora <jan...@di...> */ module ConsoleP @@ -35,25 +34,30 @@ uses { interface BufferedUart as Uart; + interface McuSleep; + interface Leds; } } implementation { - /* Writes a string to the UART. The string must be null-terminated. - The number of chars written will be returned (not including the trailing \0). - */ - async command int ConsoleOut.print(const char *str) + /** + * Writes a string to the UART. The string must be null-terminated. + * The number of chars written will be returned (not including the trailing \0). + */ + async command int ConsoleOut.print(const char *str) __attribute((reentrant)) { int countret = 0; while (*str != 0) { - if (SUCCESS == call Uart.send((uint8_t*)str)) { - str++; - countret++; - } else { - // Wait until some space becomes free. - return countret; - } + if (SUCCESS == call Uart.send(str[0])) { + str++; + countret++; + } else { + // Sleep. + call McuSleep.sleep(); + __nesc_enable_interrupt(); + call Leds.led0Toggle(); + } } return countret; @@ -64,7 +68,7 @@ int countret = 0; uint8_t i = 0; while (i < length) { - call Uart.send(&str[i]); + call Uart.send(str[i]); i++; countret++; } @@ -72,9 +76,11 @@ } - /* Add a hex number to the circular buffer - - code is meant to be easy to read */ - async command int ConsoleOut.printHex(const uint8_t c) + /** + * Add a hex number to the circular buffer + * - code is meant to be easy to read + */ + async command int ConsoleOut.printHex(const uint8_t c) __attribute((reentrant)) { char str[3]; uint8_t v; @@ -99,40 +105,14 @@ return call ConsoleOut.print(str); } - /* Add a word number to the circular buffer as hex - code is meant - to be easy to read. And, also, if you wrote this as an expression, - you will be bitten by compiler reordering. I was. And was - surprised. */ - - async command int ConsoleOut.printHexword(const uint16_t c) - { - int i = 0; - i += call ConsoleOut.printHex(c >> 8); - i += call ConsoleOut.printHex(0xFF & c); - return i; - } - - /* Add a long number to the circular buffer as hex - - code is meant to be easy to read.*/ - async command int ConsoleOut.printHexlong(const uint32_t c) - { - int i = 0; - i += call ConsoleOut.printHex(c >> 24); - i += call ConsoleOut.printHex( (c >> 16) & 0xFF); - i += call ConsoleOut.printHex( (c >> 8) & 0xFF); - i += call ConsoleOut.printHex( c & 0xFF); - return i; - } - - /** Dump an array of hex's + /** + * Dump an array of hex's * - * \param ptr - array of uint8_t values - * \param count - count of values in array - * \param sep - optional seperator string - - * Always return succes, even if something went wrong. + * @param ptr - array of uint8_t values + * @param count - count of values in array + * @param sep - optional seperator string */ - async command void ConsoleOut.dumpHex(const uint8_t ptr[], const uint8_t countar, const char * sep) + async command void ConsoleOut.dumpHex(const uint8_t ptr[], const uint8_t countar, const char * sep) __attribute((reentrant)) { int i; for (i = 0; i < countar; i++) { @@ -143,11 +123,10 @@ } } - /* Handle getting data such that the user of this interface can get data. */ - async event void Uart.get(uint8_t data) + async event void Uart.get(uint8_t *data) { signal ConsoleIn.get(data); } - default async event void ConsoleIn.get(uint8_t consoleData) {} + default async event void ConsoleIn.get(uint8_t *consoleData) {} } Modified: trunk/diku/tiny15four/tos/lib/debug/DebugConsoleC.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/debug/DebugConsoleC.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/debug/DebugConsoleC.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -50,12 +50,16 @@ BufferedUartP, CommandInterpreterP, new FIFOQueueM(uint8_t) as FIFOQueue, + LedsC, + McuSleepC, MainC; BufferedUartP.Uart = SerialByteComm; BufferedUartP.FIFOQueue -> FIFOQueue.FIFOQueue; MainC.SoftwareInit -> BufferedUartP.Init; ConsoleP.Uart -> BufferedUartP.BufferedUart; + ConsoleP.McuSleep -> McuSleepC.McuSleep; + ConsoleP.Leds -> LedsC.Leds; DebugConsoleP.ConsoleOut -> ConsoleP.ConsoleOut; CommandInterpreterP.Output -> ConsoleP.ConsoleOut; CommandInterpreterP.Input -> ConsoleP.ConsoleIn; Modified: trunk/diku/tiny15four/tos/lib/debug/DebugConsoleP.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/debug/DebugConsoleP.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/debug/DebugConsoleP.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -45,7 +45,7 @@ } implementation { - async command void Debug.debugStr(const char *dbgOut, uint8_t lvl) + async command void Debug.debugStr(const char *dbgOut, uint8_t lvl) __attribute((reentrant)) { call ConsoleOut.print("DBG_"); call ConsoleOut.printHex(lvl); @@ -54,12 +54,12 @@ call ConsoleOut.print("\n"); } - async command void Debug.debugStrClean(const char *dbgOut) + async command void Debug.debugStrClean(const char *dbgOut) __attribute((reentrant)) { call ConsoleOut.print(dbgOut); } - async command void Debug.debugInt(uint8_t *dbgOut, uint8_t len, uint8_t lvl) + async command void Debug.debugInt(uint8_t *dbgOut, uint8_t len, uint8_t lvl) __attribute((reentrant)) { call ConsoleOut.print("DBG_"); call ConsoleOut.printHex(lvl); @@ -68,13 +68,13 @@ call ConsoleOut.print("\n"); } - async command void Debug.debugIntClean(uint8_t *dbgOut, uint8_t len) + async command void Debug.debugIntClean(uint8_t *dbgOut, uint8_t len) __attribute((reentrant)) { call ConsoleOut.print("0x"); call ConsoleOut.dumpHex(dbgOut,len,""); } - async command void Debug.debugStrInt(const char *dbgOut,uint8_t *dbgInt, uint8_t len, uint8_t lvl) + async command void Debug.debugStrInt(const char *dbgOut,uint8_t *dbgInt, uint8_t len, uint8_t lvl) __attribute((reentrant)) { call ConsoleOut.print("DBG_"); call ConsoleOut.printHex(lvl); Modified: trunk/diku/tiny15four/tos/lib/mac/AssociateM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/mac/AssociateM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/mac/AssociateM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -300,7 +300,7 @@ } } - async event void PollService.done(Ieee_Status status) + async event void PollService.done(Ieee_Status status) __attribute((reentrant)) { DBG_STR("Associate poll done!",1); // Check the status and take action. @@ -401,7 +401,7 @@ } - void confirmAssociation(uint8_t *primitive) + void confirmAssociation(uint8_t *primitive) __attribute((reentrant)) { signal MlmeRequestConfirmAssociate.confirm((Mlme_AssociateRequestConfirm)primitive); } Modified: trunk/diku/tiny15four/tos/lib/mac/CallbackServiceM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/mac/CallbackServiceM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/mac/CallbackServiceM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -65,7 +65,7 @@ return SUCCESS; } - async command void CallbackService.enqueue(uint8_t *primitive, void(*callback)(uint8_t*)) + async command void CallbackService.enqueue(uint8_t *primitive, void(*callback)(uint8_t*)) __attribute((reentrant)) { call Queue.enqueue(&primitiveQueue, primitive); call Queue.enqueue(&primitiveFuncQueue, (uint8_t*)callback); Modified: trunk/diku/tiny15four/tos/lib/mac/CapControlM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/mac/CapControlM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/mac/CapControlM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -195,7 +195,7 @@ } #endif - async event void Csma.done() + async event void Csma.done() __attribute((reentrant)) { capTx_t *pendingEntry; uint8_t curPendingCap; @@ -243,7 +243,7 @@ } } - void enqueueTx(txHeader_t *header, uint8_t cap, uint8_t token) + void enqueueTx(txHeader_t *header, uint8_t cap, uint8_t token) __attribute((reentrant)) { uint8_t mySlot, i; bool emptySlotFound = FALSE; @@ -329,7 +329,7 @@ atomic donePosted = FALSE; } - void tendOperationQueue(uint8_t slot, uint8_t cap) + void tendOperationQueue(uint8_t slot, uint8_t cap) __attribute((reentrant)) { uint8_t i,s; uint8_t maxSlots = NUMDEVICECAPSLOTS; @@ -369,7 +369,7 @@ } } - void tryRxOff() + void tryRxOff() __attribute((reentrant)) { // First we check if the receiver is really on. bool deviceRxOn, coordRxOn = FALSE; @@ -393,7 +393,7 @@ DBG_STR("Receiver disabled",1); } - void tryRxOn() + void tryRxOn() __attribute((reentrant)) { // First we check that we are not already receiving bool deviceRxOn, coordRxOn = FALSE; Modified: trunk/diku/tiny15four/tos/lib/mac/CsmaM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/mac/CsmaM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/mac/CsmaM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -92,7 +92,7 @@ performIteration(); } - void performIteration() + void performIteration() __attribute((reentrant)) { //uint32_t myNow; bool isBeaconEnabled; @@ -139,7 +139,7 @@ } /** Calculates a random backoff period in symbol periods **/ - uint8_t getBackoffPeriods() + uint8_t getBackoffPeriods() __attribute((reentrant)) { uint8_t backoff = 1; backoff <<= pendingTx->BE; Modified: trunk/diku/tiny15four/tos/lib/mac/IndirectTxM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/mac/IndirectTxM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/mac/IndirectTxM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -95,7 +95,7 @@ return FAIL; } - async command void IndirectTx.send[uint8_t token](txHeader_t *header) + async command void IndirectTx.send[uint8_t token](txHeader_t *header) __attribute((reentrant)) { uint8_t i; macMhr_t myMhr; Modified: trunk/diku/tiny15four/tos/lib/mac/MacAddressM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/mac/MacAddressM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/mac/MacAddressM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -110,7 +110,7 @@ } // The new approach - async command void MacAddress.setAddrs(macMhr_t *myMhr, ieeeAddress_t *srcAddr, ieeeAddress_t *dstAddr) __attribute__((noinline)) + async command void MacAddress.setAddrs(macMhr_t *myMhr, ieeeAddress_t *srcAddr, ieeeAddress_t *dstAddr) __attribute((reentrant)) __attribute__((noinline)) { // Update address modes. if (dstAddr != NULL) { @@ -190,7 +190,7 @@ } } - async command void MacAddress.getLocalAddr(ieeeAddress_t *myAddress, bool preferExt) __attribute__((noinline)) + async command void MacAddress.getLocalAddr(ieeeAddress_t *myAddress, bool preferExt) __attribute((reentrant)) __attribute__((noinline)) { bool useExtended; Modified: trunk/diku/tiny15four/tos/lib/mac/MacFrameM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/mac/MacFrameM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/mac/MacFrameM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -51,7 +51,7 @@ uint8_t *updateSrcAddr(macMhr_t *myFrame, uint8_t *location); // This command requires intraPAN and address modes to be set. - async command void MacFrame.initializeMhrStruct(macMhr_t *myFrame, uint8_t *data) __attribute__((noinline)) + async command void MacFrame.initializeMhrStruct(macMhr_t *myFrame, uint8_t *data) __attribute((reentrant)) __attribute__((noinline)) { uint8_t *nextAddr; @@ -62,7 +62,7 @@ myFrame->payload = nextAddr; } - async command void MacFrame.updateMhtStruct(macMhr_t *myFrame) __attribute__((noinline)) + async command void MacFrame.updateMhtStruct(macMhr_t *myFrame) __attribute((reentrant)) __attribute__((noinline)) { uint8_t *nextAddr; nextAddr = updateDstAddr(myFrame, myFrame->seqNum+1); @@ -70,7 +70,7 @@ myFrame->payload = nextAddr; } - uint8_t *updateDstAddr(macMhr_t *myFrame, uint8_t *location) + uint8_t *updateDstAddr(macMhr_t *myFrame, uint8_t *location) __attribute((reentrant)) { uint8_t dstAddrMode = myFrame->frameControl->DstAddrMode; if (dstAddrMode) { @@ -83,7 +83,7 @@ return location; } - uint8_t *updateSrcAddr(macMhr_t *myFrame, uint8_t *location) + uint8_t *updateSrcAddr(macMhr_t *myFrame, uint8_t *location) __attribute((reentrant)) { uint8_t srcAddrMode = myFrame->frameControl->SrcAddrMode; if (srcAddrMode) { @@ -101,7 +101,7 @@ return location; } - async command uint8_t MacFrame.getMhrSize(macMhr_t *myFrame) __attribute__((noinline)) + async command uint8_t MacFrame.getMhrSize(macMhr_t *myFrame) __attribute((reentrant)) __attribute__((noinline)) { uint8_t dstAddrMode = myFrame->frameControl->DstAddrMode; uint8_t srcAddrMode = myFrame->frameControl->SrcAddrMode; Modified: trunk/diku/tiny15four/tos/lib/mac/RxEnableM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/mac/RxEnableM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/mac/RxEnableM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -154,7 +154,7 @@ } } - void turnOnReceiver() + void turnOnReceiver() __attribute((reentrant)) { DBG_STR("In turnOnReceiver...",1); // Only turn on receiver if CAP is active. Modified: trunk/diku/tiny15four/tos/lib/mac/ScanServiceM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/mac/ScanServiceM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/mac/ScanServiceM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -233,7 +233,7 @@ } } - async event void FrameTx.txDone(phy_error_t error) + async event void FrameTx.txDone(phy_error_t error) __attribute((reentrant)) { if (error != PHY_SUCCESS) { DBG_STR("WARNING: Scan, frame not send!",1); Modified: trunk/diku/tiny15four/tos/lib/mac/SuperframeM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/mac/SuperframeM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/mac/SuperframeM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -193,7 +193,7 @@ } } - async command bool Superframe.capActive(superframe_t *superframe) + async command bool Superframe.capActive(superframe_t *superframe) __attribute((reentrant)) { bool capActive; if (superframe == &deviceSuperframe) { Modified: trunk/diku/tiny15four/tos/lib/macApi/ADTModules/SduM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/macApi/ADTModules/SduM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/macApi/ADTModules/SduM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -46,7 +46,7 @@ return call BufferMng.claim(sizeof(msdu_t), (uint8_t**)msdu); } - command error_t IeeeSdu.destroy( Ieee_Msdu msdu ) + command error_t IeeeSdu.destroy( Ieee_Msdu msdu ) __attribute((reentrant)) { if (msdu->bufferDestroyable) { call BufferMng.release(msdu->bufferLen, msdu->buffer); Modified: trunk/diku/tiny15four/tos/lib/timing/AsyncAlarmM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/timing/AsyncAlarmM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/timing/AsyncAlarmM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -154,7 +154,7 @@ } } - error_t programAlarm(uint8_t timerId, time_t timeStamp) + error_t programAlarm(uint8_t timerId, time_t timeStamp) __attribute((reentrant)) { uint8_t i; error_t armed; Modified: trunk/diku/tiny15four/tos/lib/timing/LocalTimeM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/timing/LocalTimeM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/timing/LocalTimeM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -64,7 +64,7 @@ call SymbolCounter.reset(); } - async command bool LocalTime.compare(uint8_t op, time_t timeStamp1, time_t timeStamp2) + async command bool LocalTime.compare(uint8_t op, time_t timeStamp1, time_t timeStamp2) __attribute((reentrant)) { // Check for equality. // We use that the equality operations are assigned the smallest values. Modified: trunk/diku/tiny15four/tos/lib/timing/VirtualSymbolChannelM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/timing/VirtualSymbolChannelM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/timing/VirtualSymbolChannelM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -95,7 +95,7 @@ return SUCCESS; } - async command error_t nChannel.arm(uint8_t id, n_type timeStamp) + async command error_t nChannel.arm(uint8_t id, n_type timeStamp) __attribute((reentrant)) { uint8_t i; bool wasFree = FALSE; @@ -117,7 +117,7 @@ return EBUSY; } - async command error_t nChannel.stop(uint8_t id) + async command error_t nChannel.stop(uint8_t id) __attribute((reentrant)) { uint8_t i,j; bool wasArmed; @@ -186,7 +186,7 @@ return EBUSY; } - error_t doProgramming(n_type nTimeNow, m_type mTimeNow, uint8_t channel) + error_t doProgramming(n_type nTimeNow, m_type mTimeNow, uint8_t channel) __attribute((reentrant)) { atomic { virtualChannel_t* chan = virtualChannels+channel; Modified: trunk/diku/tiny15four/tos/lib/timing/VirtualSymbolCounterM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/timing/VirtualSymbolCounterM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/timing/VirtualSymbolCounterM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -58,7 +58,7 @@ return SUCCESS; } - async command n_type nCounter.getTime() + async command n_type nCounter.getTime() __attribute((reentrant)) { n_type retVal; atomic retVal = myCounter; Modified: trunk/diku/tiny15four/tos/lib/tools/FIFOQueueM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/tools/FIFOQueueM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/tools/FIFOQueueM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -26,6 +26,8 @@ */ /** + * This module implements a generic FIFO queue handler using cyclic buffers. + * * @author Jan Flora <jan...@di...> */ @@ -54,7 +56,7 @@ return SUCCESS; } - async command error_t FIFOQueue.enqueue(FIFOQueue_t *theQueue, elemType element) + async command error_t FIFOQueue.enqueue(FIFOQueue_t *theQueue, elemType element) __attribute((reentrant)) { error_t myResult = FAIL; elemType *buf = (elemType*)theQueue->buffer; @@ -69,7 +71,7 @@ return myResult; } - async command error_t FIFOQueue.dequeue(FIFOQueue_t *theQueue, elemType *element) + async command error_t FIFOQueue.dequeue(FIFOQueue_t *theQueue, elemType *element) __attribute((reentrant)) { error_t myResult = FAIL; elemType *buf = (elemType*)theQueue->buffer; @@ -85,7 +87,7 @@ return myResult; } - async command error_t FIFOQueue.peek(FIFOQueue_t *theQueue, elemType *element) + async command error_t FIFOQueue.peek(FIFOQueue_t *theQueue, elemType *element) __attribute((reentrant)) { error_t myResult = FAIL; elemType *buf = (elemType*)theQueue->buffer; @@ -99,7 +101,7 @@ return myResult; } - async command bool FIFOQueue.isFull(FIFOQueue_t *theQueue) + async command bool FIFOQueue.isFull(FIFOQueue_t *theQueue) __attribute((reentrant)) { bool isFull; @@ -108,7 +110,7 @@ return isFull; } - async command bool FIFOQueue.isEmpty(FIFOQueue_t *theQueue) + async command bool FIFOQueue.isEmpty(FIFOQueue_t *theQueue) __attribute((reentrant)) { if (theQueue->bufferCount) { return FALSE; @@ -116,7 +118,7 @@ return TRUE; } - async command uint8_t FIFOQueue.elementCount(FIFOQueue_t *theQueue) + async command uint8_t FIFOQueue.elementCount(FIFOQueue_t *theQueue) __attribute((reentrant)) { return theQueue->bufferCount; } Modified: trunk/diku/tiny15four/tos/lib/tools/SimpleBufferManM.nc =================================================================== --- trunk/diku/tiny15four/tos/lib/tools/SimpleBufferManM.nc 2009-09-06 18:36:25 UTC (rev 1077) +++ trunk/diku/tiny15four/tos/lib/tools/SimpleBufferManM.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -110,7 +110,7 @@ return SUCCESS; } - async command error_t BufferMng.claim( uint8_t size, uint8_t **buffer ) + async command error_t BufferMng.claim( uint8_t size, uint8_t **buffer ) __attribute((reentrant)) { FIFOQueue_t *freeQueue; @@ -120,7 +120,7 @@ return call Queue.dequeue(freeQueue, buffer); } - async command error_t BufferMng.release( uint8_t size, uint8_t *buffer ) + async command error_t BufferMng.release( uint8_t size, uint8_t *buffer ) __attribute((reentrant)) { FIFOQueue_t *freeQueue; Added: trunk/diku/tiny15four/tos/platforms/cc2430em/CC2430ClockConfig.h =================================================================== --- trunk/diku/tiny15four/tos/platforms/cc2430em/CC2430ClockConfig.h (rev 0) +++ trunk/diku/tiny15four/tos/platforms/cc2430em/CC2430ClockConfig.h 2009-09-06 23:45:12 UTC (rev 1078) @@ -0,0 +1,45 @@ +/* Copyright (c) 2008, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + * + * This file sets up the default system clock, timer tick rate and UART baud rate. + * All settings can be overridden at application level. + */ + +#ifndef _H_CC2430CLOCKCONFIG_H +#define _H_CC2430CLOCKCONFIG_H + + #warning Local clock config included. + + #define SYSCLK SYSCLK_32MHZ + #define OSC32K OSC32K_RC_OSC + #define TIMER_TICK TIMER_TICK_2MHZ + #define USART_BAUD_RATE B38400 + +#endif + Added: trunk/diku/tiny15four/tos/platforms/cc2430em/PlatformInitC.nc =================================================================== --- trunk/diku/tiny15four/tos/platforms/cc2430em/PlatformInitC.nc (rev 0) +++ trunk/diku/tiny15four/tos/platforms/cc2430em/PlatformInitC.nc 2009-09-06 23:45:12 UTC (rev 1078) @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +configuration PlatformInitC +{ + provides + { + interface Init; + } + uses + { + interface Boot; + } +} +implementation +{ + components NoPlatformInitP; + + Init = NoPlatformInitP.Init; + NoPlatformInitP.Boot = Boot; +} \ No newline at end of file Added: trunk/diku/tiny15four/tos/platforms/cc2430em/platform.t15f =================================================================== --- trunk/diku/tiny15four/tos/platforms/cc2430em/platform.t15f (rev 0) +++ trunk/diku/tiny15four/tos/platforms/cc2430em/platform.t15f 2009-09-06 23:45:12 UTC (rev 1078) @@ -0,0 +1,5 @@ +# Include platform dependent code. +PFLAGS += -I$(TINY15FOUR_DIR)/tos/chips/cc2430 \ + -I$(TINY15FOUR_DIR)/tos/chips/cc2430/phy \ + -I$(TINY15FOUR_DIR)/tos/chips/cc2430/phy/interfaces \ + -DBIG_ENDIAN_BYTE_ORDERING Added: trunk/diku/tiny15four/tos/platforms/cc2430em/time.h =================================================================== --- trunk/diku/tiny15four/tos/platforms/cc2430em/time.h (rev 0) +++ trunk/diku/tiny15four/tos/platforms/cc2430em/time.h 2009-09-06 23:45:12 UTC (rev 1078) @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2008, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +#ifndef _TIME_H_ +#define _TIME_H_ + + typedef uint32_t time_t; + +#endif \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-09-06 18:36:57
|
Revision: 1077 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1077&view=rev Author: qzban Date: 2009-09-06 18:36:25 +0000 (Sun, 06 Sep 2009) Log Message: ----------- Mangle script update. Reentrant keyword now definitely works. Modified Paths: -------------- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl trunk/diku/mcs51/support/make/mcs51/mcs51.rules Removed Paths: ------------- trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl Modified: trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-09-06 18:07:41 UTC (rev 1076) +++ trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-09-06 18:36:25 UTC (rev 1077) @@ -72,6 +72,15 @@ my $line_no = 0; my $schedulerBasicReentrant = 0; +# Parenthesis levels. +my $bracketLevel = 0; +my $braceLevel = 0; +my $parenthesesLevel = 0; + +my @reentrantFunctions = (); +my @input = (); +my $output = ""; + GetOptions( 'keil' => \$KEIL, 'sdcc' => \$SDCC, @@ -84,27 +93,33 @@ } open(FILE,"<$file") or die "no such file $file\n"; -while(<FILE>) { - $line_no++; - # If on the first line, print some header. It's in the while loop so if - # this script is invoked with -i, the correct things still happen. - # NOTE: This was broken by SMAC! - if( $. == 1 ) { - print <<"EOF"; +@input = <FILE>; -#define MANGLED_NESC_APP_C -EOF - } +# Find names of all reentrant functions. +foreach (@input) { + if (/([^\s]+?)\(.*?\).*?\s+__attribute(?:__)?\(\(.*?(?:__)?reentrant(?:__)?.*\)\).*?\;/g) { + my $func = $1; + $func =~ s/\$/__/g; + push(@reentrantFunctions, "$func"); + printf STDERR "Found reentrant function: '%s'\n",$func; + } +} +# Write header stuff. +$output .= "#define MANGLED_NESC_APP_C\n"; + +foreach(@input) { + $line_no++; + # # Skip lines that start with // and lines that are within a comment # - if ($_ =~ /^\/\//) { print $_; next;} + if ($_ =~ /^\/\//) { doneProcessing($_); next;} if ($_ =~ /\*\//) { $comment_level--; } - if ($comment_level > 0) { print $_; next; } + if ($comment_level > 0) { doneProcessing($_); next; } if ($_ =~ /\/\*/) { $comment_level++; } # @@ -298,6 +313,19 @@ } if ($KEIL) { + # Append the "reentrant" keyword to function prototypes as well. + if (!$braceLevel && !m{reentrant}g) { + # my $i=0; + foreach my $reentrantFunc (@reentrantFunctions) { + my $funcName = quotemeta($reentrantFunc); + if (m{\s+$funcName\s*\(}g) { + s{([^\;]*)}{$1 reentrant}; + printf STDERR "Fixed reentrant function prototype: '%s'\n",$funcName; + } + # $i++; + } + } + # Make the TinyOS task poster function reentrant as well. # NOTE: This will not work if the BasicScheduler is replaced. s{(error_t\s*SchedulerBasicP__TaskBasic__postTask\s*\(\s*uint8_t\s*id\s*\))}{$1 reentrant}; @@ -553,51 +581,51 @@ # } # name; - if ($typedef_struct_lines) { - # Reached last line i typedef +# if ($typedef_struct_lines) { + # Reached last line in typedef # The ; might not be on the same line as the } - if (m{.*\}.*}) { # Found the end } of the typedef - $typedef_struct_closed = 1; - if ( $typedef_struct_lines == 1) { - $typedef_struct_empty = 1; - } - } - $typedef_struct_lines++; - $typedef_struct = $typedef_struct . $_; +# if (m{.*\}.*}) { # Found the end } of the typedef +# $typedef_struct_closed = 1; +# if ( $typedef_struct_lines == 1) { +# $typedef_struct_empty = 1; +# } +# } +# $typedef_struct_lines++; +# $typedef_struct = $typedef_struct . $_; # look for ";" - if ($typedef_struct_closed==1 && m{(^.*\s+(\w+))?;} ) { - my $identifyer = ""; +# if ($typedef_struct_closed==1 && m{(^.*\s+(\w+))?;} ) { +# my $identifyer = ""; # This fails if the identifier is right after ; fortunately it isn't # for our lines - if (defined($1) && - $1 ne "") { - $identifyer = $1; - } +# if (defined($1) && +# $1 ne "") { +# $identifyer = $1; +# } # Remember the name of the empty struct - we need this to # kill more lines that use this name later... - $typedef_struct_ident_all{$identifyer} = 1; + # $typedef_struct_ident_all{$identifyer} = 1; # Remove the empty struct - if ($typedef_struct_empty){ - $typedef_struct_empty_ident{$identifyer} = 1; +# if ($typedef_struct_empty){ +# $typedef_struct_empty_ident{$identifyer} = 1; - my @list = split(/\n/, $typedef_struct); - $_ = ""; +# my @list = split(/\n/, $typedef_struct); +# $_ = ""; # Comments in comments are bad mkay - $_ = $_ . "/* Empty struct $identifyer removed \n*/"; - foreach my $line (@list) { - if ($line =~ /\/\/.*/) { - $_ = $_ . $line; - } else { - $_ = $_ . "//" . $line . "\n"; - } - } - } else { # The struct was not empty... - $_ = $typedef_struct; - } +# $_ = $_ . "/* Empty struct $identifyer removed \n*/"; +# foreach my $line (@list) { +# if ($line =~ /\/\/.*/) { +# $_ = $_ . $line; +# } else { +# $_ = $_ . "//" . $line . "\n"; +# } +# } +# } else { # The struct was not empty... +# $_ = $typedef_struct; +# } #$_ = $_ . "/*YYYYY $identifyer*/"; #if ($identifyer eq "in_queue_item_t") { @@ -607,38 +635,38 @@ # $_ = $_ . "//HOHO"; #} - $typedef_struct_closed = 0; - $typedef_struct_lines = 0; - $typedef_struct_empty = 0; - # we are done - don't match any more! - print $_; - next; - } else { # Output the whole structure at once! - $_ = ""; +# $typedef_struct_closed = 0; +# $typedef_struct_lines = 0; +# $typedef_struct_empty = 0; + # we are done - don't match any more! +# doneProcessing($_); +# next; +# } else { # Output the whole structure at once! +# $_ = ""; # $_ = "$typedef_struct_empty $typedef_struct_closed $typedef_struct_lines" . $_; - } - } +# } +# } # Match beginning of a "typedef struct" - if( /^\s*(?:typedef\s+)(?:nx_)?struct ((?:\w|_)+) {/) { +# if( /^\s*(?:typedef\s+)(?:nx_)?struct ((?:\w|_)+) {/) { # we are not looking for one line typedef struct - if (/\}.*;/) { - } else { - $typedef_struct = $_; - $typedef_struct_ident = $1; - $_ = ""; - $typedef_struct_lines = 1; - } - } +# if (/\}.*;/) { +# } else { +# $typedef_struct = $_; +# $typedef_struct_ident = $1; +# $_ = ""; +# $typedef_struct_lines = 1; +# } +# } # After tossing the empty timer typedef stucts we need to toss these typedefs # as well: # typedef TMilli TimerTesterP$Timer$precision_tag; - if (/^typedef\s+(\w+)\s+(.)+;.*/) { - my $identifyer = $1; - if (defined($typedef_struct_empty_ident{$identifyer})) { - $_ = "//" . $_; - } - } +# if (/^typedef\s+(\w+)\s+(.)+;.*/) { +# my $identifyer = $1; +# if (defined($typedef_struct_empty_ident{$identifyer})) { +# $_ = "//" . $_; +# } +# } # In addition to the empty "typedef struct" nescc creates some empty "structs" if( /^struct __nesc_attr_\w+ {/ ) { @@ -650,9 +678,26 @@ chomp($_); $_ = $_ . "*/\n"; } - - print; + + doneProcessing($_); +} +print $output; + +close(FILE); + + +sub doneProcessing { + + my $line = $_[0]; + + # Update parentheses levels. + $braceLevel += ($line =~ m{\{}g); + $braceLevel -= ($line =~ m{\}}g); + $bracketLevel += $line =~ m{\[}g; + $bracketLevel -= $line =~ m{\]}g; + $parenthesesLevel += $line =~ m{\(}g; + $parenthesesLevel -= $line =~ m{\)}g; + + $output .= $line; } - -close(FILE); Modified: trunk/diku/mcs51/support/make/mcs51/mcs51.rules =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mcs51.rules 2009-09-06 18:07:41 UTC (rev 1076) +++ trunk/diku/mcs51/support/make/mcs51/mcs51.rules 2009-09-06 18:36:25 UTC (rev 1077) @@ -113,9 +113,9 @@ mv $(APP_C) $(BUILDDIR)/app.preMangle.c perl -w $(MCS51_MAKE_PATH)/mcs51/mangleAppC.pl --$(MCS51_COMPILER) --file=$(BUILDDIR)/app.preMangle.c > $(APP_C) -reentrant: mangle - mv $(APP_C) $(BUILDDIR)/app.postMangle.c - perl -w $(MCS51_MAKE_PATH)/mcs51/prototypeMangler.pl --file=$(BUILDDIR)/app.postMangle.c > $(APP_C) +#reentrant: mangle +# mv $(APP_C) $(BUILDDIR)/app.postMangle.c +# perl -w $(MCS51_MAKE_PATH)/mcs51/prototypeMangler.pl --file=$(BUILDDIR)/app.postMangle.c > $(APP_C) ####### # IAR rules @@ -150,7 +150,7 @@ # Keil rules # Build to .hex using $(MCS51_KEIL_SCRIPT) from -keil: reentrant $(BUILDDIR)/startup.OBJ $(BUILDDIR)/$(KEIL_BAT_SCRIPT) +keil: mangle $(BUILDDIR)/startup.OBJ $(BUILDDIR)/$(KEIL_BAT_SCRIPT) cd $(BUILDDIR) $(OSTYPE) && $(MCS51_WINE_KEIL) ./$(MCS51_KEIL_SCRIPT) @bash -c "if [ -f $(COMPONENT).s ]; then mv $(COMPONENT).s build/$(PLATFORM)/; fi" @echo " compiled $(COMPONENT) to a $(PLATFORM) binary" Deleted: trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl =================================================================== --- trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl 2009-09-06 18:07:41 UTC (rev 1076) +++ trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl 2009-09-06 18:36:25 UTC (rev 1077) @@ -1,41 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; -use Getopt::Long; - -my $file; -my $content; -my @prototypes = (); - -GetOptions( - 'file=s' => \$file, -); - -open($content,"<$file") or die "no such file $file\n"; - -my $text = do { local $/; <$content> }; - -while ($text =~ /([^\s]+?\(.*?\)).*?\s+reentrant.*?\;/g) { - my $func = $1; - if (!($func =~ /SchedulerBasicP__TaskBasic__postTask/)) { - push(@prototypes, "$func"); - } -} - -my $i=0; -foreach (@prototypes) { - my $func = quotemeta($prototypes[$i]); - - printf STDERR "Checking function: '%s'\n",$prototypes[$i]; - - $text =~ s/$func((?!reentrant).)*\n/$prototypes[$i] reentrant $1\n/g; - - #while ($text =~ /$func\s*(?:\;)?\s*\n/g) { - # print STDERR "Found: $&\n\n\n"; - #} - - $i++; -} - -print $text; -close($content); \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mle...@us...> - 2009-09-06 18:07:55
|
Revision: 1076 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1076&view=rev Author: mleopold Date: 2009-09-06 18:07:41 +0000 (Sun, 06 Sep 2009) Log Message: ----------- Update plan Modified Paths: -------------- trunk/diku/mcs51/doc/ChangeLog Modified: trunk/diku/mcs51/doc/ChangeLog =================================================================== --- trunk/diku/mcs51/doc/ChangeLog 2009-09-06 14:04:28 UTC (rev 1075) +++ trunk/diku/mcs51/doc/ChangeLog 2009-09-06 18:07:41 UTC (rev 1076) @@ -13,8 +13,11 @@ * USBSerialEcho warns that it only works on platforms with USB * c8051F340TB uninitialized variable in PlatformP * Added mcs51_env_check.sh to check env variables - * New McuSleepC using the 8051 "idle" mode + * Support rudimentary "idle" sleep mode using New McuSleepC + * Added null-task ensuring that at least one task is available +*Jan: settings.h noget? + 0.1 pre4 * .platform updated to include all library directories * PlatformLedsC replaces HalPlatformLedsC @@ -62,17 +65,19 @@ 0.1 CC2430 Cleanup clock control + PlatformC - Runtime configurable clock (for low-power modes) + Sleep modes + - Hvad g\xF8r TinyOS UartC (kompatibilitet m. TEP113) SerialByteComm, SerialFlush Serial Stack: eksisterende kode afhænger af den != UartC PlatformSerialC: UartStream, UartByte, ... + SDCC virkende for simple programmer + Move Jan debug libraries to common 0.2 Timer precision as advertized - Sleep modes SimpleMac idle-power-consumption problem + ActiveMessage Stack, built using 802.15.4 Phy* layers Later - Separate CC2430 code into a common ChipCon-8051 ancester + Separate CC2430 code into a common ChipCon-8051 ancestor Regression testing - AM Stack - Acurate timers (pending final silicon rev.) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-09-06 14:05:02
|
Revision: 1075 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1075&view=rev Author: qzban Date: 2009-09-06 14:04:28 +0000 (Sun, 06 Sep 2009) Log Message: ----------- Added null task to ensure that the task list always contains at least one task. Modified Paths: -------------- trunk/diku/mcs51/tos/platforms/c8051F340TB/PlatformP.nc trunk/diku/mcs51/tos/platforms/cc2430em/PlatformP.nc trunk/diku/mcs51/tos/platforms/nRF24E1_EVBOARD/PlatformP.nc trunk/diku/mcs51/tos/platforms/nano/PlatformLedsC.nc Modified: trunk/diku/mcs51/tos/platforms/c8051F340TB/PlatformP.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/c8051F340TB/PlatformP.nc 2009-08-19 21:02:49 UTC (rev 1074) +++ trunk/diku/mcs51/tos/platforms/c8051F340TB/PlatformP.nc 2009-09-06 14:04:28 UTC (rev 1075) @@ -129,5 +129,13 @@ return SUCCESS; } + /** + * We need at least one task to make sure that the task list is never empty. + * Else we confuse the compiler. + */ + task void nullTask() + { + } + default command error_t LedsInit.init() { return SUCCESS; } } Modified: trunk/diku/mcs51/tos/platforms/cc2430em/PlatformP.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/cc2430em/PlatformP.nc 2009-08-19 21:02:49 UTC (rev 1074) +++ trunk/diku/mcs51/tos/platforms/cc2430em/PlatformP.nc 2009-09-06 14:04:28 UTC (rev 1075) @@ -133,5 +133,13 @@ return SUCCESS; } + /** + * We need at least one task to make sure that the task list is never empty. + * Else we confuse the compiler. + */ + task void nullTask() + { + } + default command error_t LedsInit.init() { return SUCCESS; } } Modified: trunk/diku/mcs51/tos/platforms/nRF24E1_EVBOARD/PlatformP.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/nRF24E1_EVBOARD/PlatformP.nc 2009-08-19 21:02:49 UTC (rev 1074) +++ trunk/diku/mcs51/tos/platforms/nRF24E1_EVBOARD/PlatformP.nc 2009-09-06 14:04:28 UTC (rev 1075) @@ -48,6 +48,14 @@ return SUCCESS; } + /** + * We need at least one task to make sure that the task list is never empty. + * Else we confuse the compiler. + */ + task void nullTask() + { + } + default command error_t LedsInit.init() { return SUCCESS; } } Modified: trunk/diku/mcs51/tos/platforms/nano/PlatformLedsC.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/nano/PlatformLedsC.nc 2009-08-19 21:02:49 UTC (rev 1074) +++ trunk/diku/mcs51/tos/platforms/nano/PlatformLedsC.nc 2009-09-06 14:04:28 UTC (rev 1075) @@ -32,6 +32,7 @@ /** * * @author Martin Leopold + * @author Jan Flora */ configuration PlatformLedsC @@ -43,15 +44,20 @@ } implementation { - components HplMcs51GeneralIOC, - PlatformP, - new NoPinC(); + //components HplMcs51GeneralIOC, + components HplCC2430GeneralIOC, + PlatformP; + //new NoPinC(); // Let LedsP (from system) handle the Led init... Init = PlatformP.LedsInit; - Led0 = NoPinC; - Led1 = NoPinC; - Led2 = NoPinC; + // NOTE: This will only work with an external leds hw module.. + Led0 = HplCC2430GeneralIOC.P01; + Led1 = HplCC2430GeneralIOC.P04; + Led2 = HplCC2430GeneralIOC.P05; + //Led0 = NoPinC; + //Led1 = NoPinC; + //Led2 = NoPinC; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-08-19 21:03:19
|
Revision: 1074 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1074&view=rev Author: qzban Date: 2009-08-19 21:02:49 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Excessive __attribute deletion fix Modified Paths: -------------- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl Modified: trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-08-19 20:55:09 UTC (rev 1073) +++ trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-08-19 21:02:49 UTC (rev 1074) @@ -296,19 +296,22 @@ s{(.*)__attribute\(\((reentrant)\)\)([^\;\n]*)}{$1$3 __attribute__((__$2__))}; s{(.*)__attribute(?:__)?\(\((.*?)(?:__)?reentrant(?:__)?,?(.*)\)\)(.*)}{$1reentrant __attribute__(($2$3))$4}; } - # Make the TinyOS task poster function reentrant as well. - # NOTE: This will not work if the BasicScheduler is replaced. - s{(error_t\s*SchedulerBasicP__TaskBasic__postTask\s*\(\s*uint8_t\s*id\s*\))}{$1 reentrant}; - - if ($schedulerBasicReentrant) { - if (m{\;}) { - $schedulerBasicReentrant = 0; - s{\;}{ reentrant\;}; - } - } - if (m{error_t\s*SchedulerBasicP__TaskBasic__postTask} && !m{reentrant}) { - $schedulerBasicReentrant = 1; + if ($KEIL) { + # Make the TinyOS task poster function reentrant as well. + # NOTE: This will not work if the BasicScheduler is replaced. + s{(error_t\s*SchedulerBasicP__TaskBasic__postTask\s*\(\s*uint8_t\s*id\s*\))}{$1 reentrant}; + + if ($schedulerBasicReentrant) { + if (m{\;}) { + $schedulerBasicReentrant = 0; + s{\;}{ reentrant\;}; + } + } + + if (m{error_t\s*SchedulerBasicP__TaskBasic__postTask} && !m{reentrant}) { + $schedulerBasicReentrant = 1; + } } # @@ -332,8 +335,6 @@ if (! (m{^.*/\*} || # /* style comment m{^.*//})){ # // style comment - #s{(__attribute__\s*\(\(.*\)\))}{/*$1*/}; - #s{(__attribute\s*\(\(.*\)\))}{/*$1*/}; s{(__attribute(?:__)?\s*\(\(.*?\)\))}{/*$1*/}g; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-08-19 20:55:35
|
Revision: 1073 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1073&view=rev Author: qzban Date: 2009-08-19 20:55:09 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Mangle script update. reentrant now works (maybe). Modified Paths: -------------- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl trunk/diku/mcs51/support/make/mcs51/mcs51.rules trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl Modified: trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-08-19 19:10:20 UTC (rev 1072) +++ trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-08-19 20:55:09 UTC (rev 1073) @@ -70,6 +70,7 @@ my $typedef_struct_closed = 0; my %typedef_struct_empty_ident = (); my $line_no = 0; +my $schedulerBasicReentrant = 0; GetOptions( 'keil' => \$KEIL, @@ -292,12 +293,24 @@ # if($KEIL && ! m{/\*(?:.*?)\;\*/}) { + s{(.*)__attribute\(\((reentrant)\)\)([^\;\n]*)}{$1$3 __attribute__((__$2__))}; s{(.*)__attribute(?:__)?\(\((.*?)(?:__)?reentrant(?:__)?,?(.*)\)\)(.*)}{$1reentrant __attribute__(($2$3))$4}; } # Make the TinyOS task poster function reentrant as well. # NOTE: This will not work if the BasicScheduler is replaced. s{(error_t\s*SchedulerBasicP__TaskBasic__postTask\s*\(\s*uint8_t\s*id\s*\))}{$1 reentrant}; + if ($schedulerBasicReentrant) { + if (m{\;}) { + $schedulerBasicReentrant = 0; + s{\;}{ reentrant\;}; + } + } + + if (m{error_t\s*SchedulerBasicP__TaskBasic__postTask} && !m{reentrant}) { + $schedulerBasicReentrant = 1; + } + # # Remove any remaining gcc style attributes # Modified: trunk/diku/mcs51/support/make/mcs51/mcs51.rules =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mcs51.rules 2009-08-19 19:10:20 UTC (rev 1072) +++ trunk/diku/mcs51/support/make/mcs51/mcs51.rules 2009-08-19 20:55:09 UTC (rev 1073) @@ -106,9 +106,6 @@ ifdef WIRING_CHECK_FILE @nescc-wiring $(WIRING_CHECK_FILE) endif - # Fix __attribute placement that ncc fucked up. - mv $(APP_C) $(BUILDDIR)/app.nccFix.c - perl -pe 's/(.*)__attribute\(\((reentrant)\)\)([^\;\n]*)/$$1$$3 __attribute__((__$$2__))/g' $(BUILDDIR)/app.nccFix.c > $(APP_C) @echo " compiled $(COMPONENT) to $(APP_C)" .PHONY: mangle Modified: trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl =================================================================== --- trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl 2009-08-19 19:10:20 UTC (rev 1072) +++ trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl 2009-08-19 20:55:09 UTC (rev 1073) @@ -15,8 +15,11 @@ my $text = do { local $/; <$content> }; -while ($text =~ /(.*?)\s*reentrant.*?\;/g) { - push(@prototypes, "$1"); +while ($text =~ /([^\s]+?\(.*?\)).*?\s+reentrant.*?\;/g) { + my $func = $1; + if (!($func =~ /SchedulerBasicP__TaskBasic__postTask/)) { + push(@prototypes, "$func"); + } } my $i=0; @@ -24,7 +27,7 @@ my $func = quotemeta($prototypes[$i]); printf STDERR "Checking function: '%s'\n",$prototypes[$i]; - + $text =~ s/$func((?!reentrant).)*\n/$prototypes[$i] reentrant $1\n/g; #while ($text =~ /$func\s*(?:\;)?\s*\n/g) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-08-19 19:10:44
|
Revision: 1072 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1072&view=rev Author: qzban Date: 2009-08-19 19:10:20 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Minor fix Modified Paths: -------------- trunk/diku/mcs51/tos/chips/cc2430/pins/HplCC2430GeneralIOC.nc Modified: trunk/diku/mcs51/tos/chips/cc2430/pins/HplCC2430GeneralIOC.nc =================================================================== --- trunk/diku/mcs51/tos/chips/cc2430/pins/HplCC2430GeneralIOC.nc 2009-08-19 18:59:44 UTC (rev 1071) +++ trunk/diku/mcs51/tos/chips/cc2430/pins/HplCC2430GeneralIOC.nc 2009-08-19 19:10:20 UTC (rev 1072) @@ -74,7 +74,7 @@ inline async command bool name.get() { return ( pin != 0); } \ inline async command void name.set() { pin = 1; } \ inline async command void name.clr() { pin = 0; } \ - async command void name.toggle() { atomic { pin = ~pin; } } \ + async command void name.toggle() { atomic { pin = (pin)?0:1; } } \ inline async command bool name.isInput() { IS_IO_PIN_INPUT(pin_dir, pin_dir_bit); } \ inline async command bool name.isOutput() { IS_IO_PIN_OUTPUT(pin_dir, pin_dir_bit); } \ inline async command void name.makeInput() { MAKE_IO_PIN_INPUT (pin_dir, pin_dir_bit); } \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-08-19 19:00:00
|
Revision: 1071 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1071&view=rev Author: qzban Date: 2009-08-19 18:59:44 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Added UL to constants Modified Paths: -------------- trunk/diku/mcs51/tos/chips/cc2430/CC2430Clock.h Modified: trunk/diku/mcs51/tos/chips/cc2430/CC2430Clock.h =================================================================== --- trunk/diku/mcs51/tos/chips/cc2430/CC2430Clock.h 2009-08-19 18:56:13 UTC (rev 1070) +++ trunk/diku/mcs51/tos/chips/cc2430/CC2430Clock.h 2009-08-19 18:59:44 UTC (rev 1071) @@ -55,35 +55,35 @@ }; #define BAUD_E(rate) ( \ - (rate==2400) ? 6 + SYSCLK : \ - (rate==4800) ? 7 + SYSCLK : \ - (rate==9600) ? 8 + SYSCLK : \ - (rate==14400) ? 8 + SYSCLK : \ - (rate==19200) ? 9 + SYSCLK : \ - (rate==28800) ? 9 + SYSCLK : \ - (rate==38400) ? 10 + SYSCLK : \ - (rate==57600) ? 10 + SYSCLK : \ - (rate==76800) ? 11 + SYSCLK : \ - (rate==115200) ? 11 + SYSCLK : \ - (rate==153600) ? 12 + SYSCLK : \ - (rate==230400) ? 12 + SYSCLK : \ - (rate==307200) ? 13 + SYSCLK : \ + (rate==2400UL) ? 6 + SYSCLK : \ + (rate==4800UL) ? 7 + SYSCLK : \ + (rate==9600UL) ? 8 + SYSCLK : \ + (rate==14400UL) ? 8 + SYSCLK : \ + (rate==19200UL) ? 9 + SYSCLK : \ + (rate==28800UL) ? 9 + SYSCLK : \ + (rate==38400UL) ? 10 + SYSCLK : \ + (rate==57600UL) ? 10 + SYSCLK : \ + (rate==76800UL) ? 11 + SYSCLK : \ + (rate==115200UL) ? 11 + SYSCLK : \ + (rate==153600UL) ? 12 + SYSCLK : \ + (rate==230400UL) ? 12 + SYSCLK : \ + (rate==307200UL) ? 13 + SYSCLK : \ 0 ) #define BAUD_M(rate) ( \ - (rate==2400) ? 59 : \ - (rate==4800) ? 59 : \ - (rate==9600) ? 59 : \ - (rate==14400) ? 216 : \ - (rate==19200) ? 59 : \ - (rate==28800) ? 216 : \ - (rate==38400) ? 59 : \ - (rate==57600) ? 216 : \ - (rate==76800) ? 59 : \ - (rate==115200) ? 216 : \ - (rate==153600) ? 59 : \ - (rate==230400) ? 216 : \ - (rate==307200) ? 59 : \ + (rate==2400UL) ? 59 : \ + (rate==4800UL) ? 59 : \ + (rate==9600UL) ? 59 : \ + (rate==14400UL) ? 216 : \ + (rate==19200UL) ? 59 : \ + (rate==28800UL) ? 216 : \ + (rate==38400UL) ? 59 : \ + (rate==57600UL) ? 216 : \ + (rate==76800UL) ? 59 : \ + (rate==115200UL) ? 216 : \ + (rate==153600UL) ? 59 : \ + (rate==230400UL) ? 216 : \ + (rate==307200UL) ? 59 : \ 0 ) #endif \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-08-19 18:56:43
|
Revision: 1070 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1070&view=rev Author: qzban Date: 2009-08-19 18:56:13 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Usart update Modified Paths: -------------- trunk/diku/mcs51/tos/chips/cc2430/usart/HalCC2430SimpleUartP.nc Modified: trunk/diku/mcs51/tos/chips/cc2430/usart/HalCC2430SimpleUartP.nc =================================================================== --- trunk/diku/mcs51/tos/chips/cc2430/usart/HalCC2430SimpleUartP.nc 2009-08-19 17:38:01 UTC (rev 1069) +++ trunk/diku/mcs51/tos/chips/cc2430/usart/HalCC2430SimpleUartP.nc 2009-08-19 18:56:13 UTC (rev 1070) @@ -1,4 +1,4 @@ -/* +/** * Copyright (c) 2007 University of Copenhagen * All rights reserved. * @@ -32,6 +32,7 @@ /** * * @author Martin Leopold <le...@di...> + * @author Jan Flora <jan...@di...> */ #include <ioCC2430.h> @@ -39,78 +40,98 @@ module HalCC2430SimpleUartP { - provides { - interface Init; - interface SerialByteComm as uart0; - } + provides + { + interface Init; + interface SerialByteComm as uart0; + } } implementation { - uint8_t volatile UTX0IE __attribute((sbitAT0x9C)); - - command error_t Init.init() - { - // Make Keil do the right stuff. - ser_rate_t fakeBaud = USART_BAUD_RATE; - uint32_t baud = fakeBaud*75ul; + //uint8_t volatile UTX0IE __attribute((sbitAT0x9C)); + bool busy = FALSE; + + command error_t Init.init() + { + // Make Keil do the right stuff. + ser_rate_t fakeBaud = USART_BAUD_RATE; + uint32_t baud = fakeBaud*75ul; - // PERCFG selects beween alternative pin mappings for the - // peripherals PERCFG.U0CFG == PERCFG.U0CFG select Uart0 as part - // of port0 (U0CFG=0) or port1 (U0CFG=1) - // P0.2 = rx P0.3 = tx - PERCFG &= ~0x1u; + // PERCFG selects beween alternative pin mappings for the + // peripherals PERCFG.U0CFG == PERCFG.U0CFG select Uart0 as part + // of port0 (U0CFG=0) or port1 (U0CFG=1) + // P0.2 = rx P0.3 = tx + PERCFG &= ~0x1u; - // UART_SETUP(0, 57600, HIGH_STOP); - P0_ALT |= 0x0Cu; // Aka P0SEL + // UART_SETUP(0, 57600, HIGH_STOP); + P0_ALT |= 0x0Cu; // Aka P0SEL - // Configure baud rate. - U0GCR = BAUD_E(baud); - U0BAUD = BAUD_M(baud); + // Configure baud rate. + U0GCR = BAUD_E(baud); + U0BAUD = BAUD_M(baud); - U0CSR |= 0x80u | 0x40u; // U0CSR.Mode=1 | U0CSR.ReceiveEnable=1 - U0UCR |= (0x2u | 0x80u); //((HIGH_STOP) | FLUSH) + U0CSR |= 0x80u | 0x40u; // U0CSR.Mode=1 | U0CSR.ReceiveEnable=1 + U0UCR |= (0x2u | 0x80u); //((HIGH_STOP) | FLUSH) - // Clear any pending interrupts flags - UTX0IF = 0; - URX0IF = 0; + // Clear any pending interrupts flags + UTX0IF = 0; + URX0IF = 0; - // Enable the receive interrupt - URX0IE = 1; + // Disable the transmit interrupt + IEN2 &= ~_BV(CC2430_IEN2_UTX0IE); - return SUCCESS; - } - - async command error_t uart0.put(uint8_t data) - { - // Enable transmit interrupt. - IEN2 |= _BV(CC2430_IEN2_UTX0IE); - //IEN2 &= ~_BV(CC2430_IEN2_UTX0IE); - //UTX0IE = 0; //IEN2 |= 1<<2; // UTX0IE = 1 + // Enable the receive interrupt + URX0IE = 1; + + return SUCCESS; + } + + async command error_t uart0.put(uint8_t data) __attribute((reentrant)) + { + bool wasBusy; - U0BUF = data; - return SUCCESS; - } + atomic { + wasBusy = busy; + busy = TRUE; + } - MCS51_INTERRUPT(SIG_URX0) - { - //URX0 complete interrupt - URX0IF = 0; - signal uart0.get(U0BUF); - } + // Check if the UART is free. + if (wasBusy) return EBUSY; + // Clear the tx interrupt flag and + // enable the tx interrupt. + UTX0IF = 0; + IEN2 |= _BV(CC2430_IEN2_UTX0IE); - MCS51_INTERRUPT(SIG_UTX0) - { - // TRX0 complete interrupt - IEN2 &= ~_BV(CC2430_IEN2_UTX0IE); - UTX0IF = 0; - signal uart0.putDone(); - } + // Write data to the UART. + U0BUF = data; + return SUCCESS; + } - /** - * Default events - */ - default async event void uart0.get(uint8_t data) { return; } + MCS51_INTERRUPT(SIG_UTX0) + { + // Clear the tx interrupt flag and disable + // the tx interrupt. + UTX0IF = 0; + IEN2 &= ~_BV(CC2430_IEN2_UTX0IE); - default async event void uart0.putDone() { return; } + // Release the resource. + atomic busy = FALSE; + + signal uart0.putDone(); + } + + MCS51_INTERRUPT(SIG_URX0) + { + // Clear the rx interrupt flag. + URX0IF = 0; + + signal uart0.get(U0BUF); + } + + /** + * Default events + */ + default async event void uart0.get(uint8_t data) { return; } + default async event void uart0.putDone() { return; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-08-19 17:39:44
|
Revision: 1069 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1069&view=rev Author: qzban Date: 2009-08-19 17:38:01 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Added reentrant keyword support Modified Paths: -------------- trunk/diku/mcs51/support/make/mcs51/inline.extra trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl trunk/diku/mcs51/support/make/mcs51/mcs51.rules trunk/diku/mcs51/support/make/mcs51/startup.a51 trunk/diku/mcs51/support/make/mcs51/utah-inliner.pl Added Paths: ----------- trunk/diku/mcs51/support/make/mcs51/cilly.asm.darwin.8051.exe trunk/diku/mcs51/support/make/mcs51/cilly.utah.darwin.8051.exe trunk/diku/mcs51/support/make/mcs51/cilly.utah.linux.8051.exe trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl Removed Paths: ------------- trunk/diku/mcs51/support/make/mcs51/cilly.utah.linux.8051.valueset.may.exe Added: trunk/diku/mcs51/support/make/mcs51/cilly.asm.darwin.8051.exe =================================================================== (Binary files differ) Property changes on: trunk/diku/mcs51/support/make/mcs51/cilly.asm.darwin.8051.exe ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: trunk/diku/mcs51/support/make/mcs51/cilly.utah.darwin.8051.exe =================================================================== (Binary files differ) Property changes on: trunk/diku/mcs51/support/make/mcs51/cilly.utah.darwin.8051.exe ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Copied: trunk/diku/mcs51/support/make/mcs51/cilly.utah.linux.8051.exe (from rev 1066, trunk/diku/mcs51/support/make/mcs51/cilly.utah.linux.8051.valueset.may.exe) =================================================================== (Binary files differ) Property changes on: trunk/diku/mcs51/support/make/mcs51/cilly.utah.linux.8051.exe ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Added: svn:mergeinfo + Deleted: trunk/diku/mcs51/support/make/mcs51/cilly.utah.linux.8051.valueset.may.exe =================================================================== (Binary files differ) Modified: trunk/diku/mcs51/support/make/mcs51/inline.extra =================================================================== --- trunk/diku/mcs51/support/make/mcs51/inline.extra 2009-03-26 22:56:57 UTC (rev 1068) +++ trunk/diku/mcs51/support/make/mcs51/inline.extra 2009-08-19 17:38:01 UTC (rev 1069) @@ -1,4 +1,5 @@ BUILD_DEPS += inline_target exe +BUILD_HOST = $(shell uname -s) ifndef INLINE_FLAGS INLINE_FLAGS = --8051 --auto --clean --shorten @@ -7,9 +8,10 @@ .PHONY: inline inline_target: ncc @echo " Inlining $(BUILDDIR)/app.preInline.c to $(APP_C)" + @echo " Build host is: $(BUILD_HOST)" cp $(APP_C) $(BUILDDIR)/app.preInline.c # $(MCS51_MAKE_PATH)/mcs51/cilly.utah.linux.8051.valueset.may.exe --out $(APP_C) $(CIL_FLAGS) $(BUILDDIR)/app.preInline.c - $(MCS51_MAKE_PATH)/mcs51/utah-inliner.pl --cilly-path=$(MCS51_MAKE_PATH)/mcs51 $(INLINE_FLAGS) --out=$(APP_C) $(BUILDDIR)/app.preInline.c + $(MCS51_MAKE_PATH)/mcs51/utah-inliner.pl --$(BUILD_HOST) --cilly-path=$(MCS51_MAKE_PATH)/mcs51 $(INLINE_FLAGS) --out=$(APP_C) $(BUILDDIR)/app.preInline.c @mv $(APP_C) $(APP_C).tmp @echo "/* Inline flags $(INLINE_FLAGS) */" > $(APP_C) @cat $(APP_C).tmp >> $(APP_C) Modified: trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-03-26 22:56:57 UTC (rev 1068) +++ trunk/diku/mcs51/support/make/mcs51/mangleAppC.pl 2009-08-19 17:38:01 UTC (rev 1069) @@ -271,23 +271,34 @@ # http://www.keil.com/support/man/docs/c51/c51_le_interruptfuncs.htm # http://sdcc.sourceforge.net/doc/sdccman.html/node64.html - if(m{^\s*(?:void\s+)?__attribute(?:__)?\(\((?:__)?interrupt(?:__)?\)\)\s+(?:void\s+)?([_[:alpha:]]+)(\d+)\s*\(\s*void\s*\)}&& + if(m{^\s*(?:void\s+)?__attribute(?:__)?\(\((.*?)(?:__)?interrupt(?:__)?,?(.*)\)\)\s+(?:void\s+)?([_[:alpha:]]+)(\d+)\s*\(\s*void\s*\)}&& $_ !~ m{;}) { - my $int_no=$2; my $func_name=$1; - if ( $KEIL ) {$_ = "void $func_name$int_no(void) interrupt $int_no\n"; } + my $remaining_attrs = "$1$2"; my $int_no=$4; my $func_name=$3; + if ( $KEIL ) {$_ = "void $func_name$int_no(void) interrupt $int_no __attribute(($remaining_attrs))\n"; } if ( $SDCC ) {$_ = "void $func_name$int_no(void) __interrupt ($int_no)\n"; } if ( $IAR ) { my $intAddress = 3 + (8 * $int_no); $_ = "#pragma vector = $intAddress\n"; - $_ = $_ . "__interrupt void $func_name$int_no(void) \n"; + $_ = $_ . "__interrupt void $func_name$int_no(void)\n"; } } # Remove function prototypes # (for some reason nesc doesn't produce prototypes and function defs the same way.. - s{^(\s*void\s+__vector_\d+\s*\(\s*void\s*\)\s+__attribute(?:__)?\(\((?:__)?interrupt(?:__)?\)\)\s*\;)}{/*$1*/}; + s{^(\s*void(?:.*?)__vector_\d+\s*\(\s*void\s*\)\s+__attribute(?:__)?\(\((?:.*?)(?:__)?interrupt(?:__)?,?(?:.*)\)\)\s*\;)}{/*$1*/}; # +# Handle reentrant functions +# + + if($KEIL && ! m{/\*(?:.*?)\;\*/}) { + s{(.*)__attribute(?:__)?\(\((.*?)(?:__)?reentrant(?:__)?,?(.*)\)\)(.*)}{$1reentrant __attribute__(($2$3))$4}; + } + # Make the TinyOS task poster function reentrant as well. + # NOTE: This will not work if the BasicScheduler is replaced. + s{(error_t\s*SchedulerBasicP__TaskBasic__postTask\s*\(\s*uint8_t\s*id\s*\))}{$1 reentrant}; + +# # Remove any remaining gcc style attributes # @@ -303,11 +314,14 @@ # First check if the line has been uncommmented sinces comments in comments # are a nono... + # Remove empty attributes (a leftover from reentrant and interrupt handling). + s{(__attribute(?:__)?\s*\(\(\)\))}{}g; + if (! (m{^.*/\*} || # /* style comment m{^.*//})){ # // style comment #s{(__attribute__\s*\(\(.*\)\))}{/*$1*/}; #s{(__attribute\s*\(\(.*\)\))}{/*$1*/}; - s{(__attribute(?:__)?\s*\(\(.*\)\))}{/*$1*/}; + s{(__attribute(?:__)?\s*\(\(.*?\)\))}{/*$1*/}g; } # Modified: trunk/diku/mcs51/support/make/mcs51/mcs51.rules =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mcs51.rules 2009-03-26 22:56:57 UTC (rev 1068) +++ trunk/diku/mcs51/support/make/mcs51/mcs51.rules 2009-08-19 17:38:01 UTC (rev 1069) @@ -106,6 +106,9 @@ ifdef WIRING_CHECK_FILE @nescc-wiring $(WIRING_CHECK_FILE) endif + # Fix __attribute placement that ncc fucked up. + mv $(APP_C) $(BUILDDIR)/app.nccFix.c + perl -pe 's/(.*)__attribute\(\((reentrant)\)\)([^\;\n]*)/$$1$$3 __attribute__((__$$2__))/g' $(BUILDDIR)/app.nccFix.c > $(APP_C) @echo " compiled $(COMPONENT) to $(APP_C)" .PHONY: mangle @@ -113,6 +116,9 @@ mv $(APP_C) $(BUILDDIR)/app.preMangle.c perl -w $(MCS51_MAKE_PATH)/mcs51/mangleAppC.pl --$(MCS51_COMPILER) --file=$(BUILDDIR)/app.preMangle.c > $(APP_C) +reentrant: mangle + mv $(APP_C) $(BUILDDIR)/app.postMangle.c + perl -w $(MCS51_MAKE_PATH)/mcs51/prototypeMangler.pl --file=$(BUILDDIR)/app.postMangle.c > $(APP_C) ####### # IAR rules @@ -147,7 +153,7 @@ # Keil rules # Build to .hex using $(MCS51_KEIL_SCRIPT) from -keil: mangle $(BUILDDIR)/startup.OBJ $(BUILDDIR)/$(KEIL_BAT_SCRIPT) +keil: reentrant $(BUILDDIR)/startup.OBJ $(BUILDDIR)/$(KEIL_BAT_SCRIPT) cd $(BUILDDIR) $(OSTYPE) && $(MCS51_WINE_KEIL) ./$(MCS51_KEIL_SCRIPT) @bash -c "if [ -f $(COMPONENT).s ]; then mv $(COMPONENT).s build/$(PLATFORM)/; fi" @echo " compiled $(COMPONENT) to a $(PLATFORM) binary" Added: trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl =================================================================== --- trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl (rev 0) +++ trunk/diku/mcs51/support/make/mcs51/prototypeMangler.pl 2009-08-19 17:38:01 UTC (rev 1069) @@ -0,0 +1,38 @@ +#!/usr/bin/perl +use strict; +use warnings; +use Getopt::Long; + +my $file; +my $content; +my @prototypes = (); + +GetOptions( + 'file=s' => \$file, +); + +open($content,"<$file") or die "no such file $file\n"; + +my $text = do { local $/; <$content> }; + +while ($text =~ /(.*?)\s*reentrant.*?\;/g) { + push(@prototypes, "$1"); +} + +my $i=0; +foreach (@prototypes) { + my $func = quotemeta($prototypes[$i]); + + printf STDERR "Checking function: '%s'\n",$prototypes[$i]; + + $text =~ s/$func((?!reentrant).)*\n/$prototypes[$i] reentrant $1\n/g; + + #while ($text =~ /$func\s*(?:\;)?\s*\n/g) { + # print STDERR "Found: $&\n\n\n"; + #} + + $i++; +} + +print $text; +close($content); \ No newline at end of file Modified: trunk/diku/mcs51/support/make/mcs51/startup.a51 =================================================================== --- trunk/diku/mcs51/support/make/mcs51/startup.a51 2009-03-26 22:56:57 UTC (rev 1068) +++ trunk/diku/mcs51/support/make/mcs51/startup.a51 2009-08-19 17:38:01 UTC (rev 1069) @@ -65,7 +65,7 @@ ; <h> Stack Space for reentrant functions in the LARGE model. ; <q> XBPSTACK: Enable LARGE model reentrant stack ; <i> Stack space for reentrant functions in the LARGE model. -XBPSTACK EQU 0 ; set to 1 if large reentrant is used. +XBPSTACK EQU 1 ; set to 1 if large reentrant is used. ; <o> XBPSTACKTOP: End address of LARGE model stack <0x0-0xFFFF> ; <i> Set the top of the stack to the highest location. XBPSTACKTOP EQU 0xFFFF +1 ; default 0FFFFH+1 Modified: trunk/diku/mcs51/support/make/mcs51/utah-inliner.pl =================================================================== --- trunk/diku/mcs51/support/make/mcs51/utah-inliner.pl 2009-03-26 22:56:57 UTC (rev 1068) +++ trunk/diku/mcs51/support/make/mcs51/utah-inliner.pl 2009-08-19 17:38:01 UTC (rev 1069) @@ -68,6 +68,11 @@ $machine = "cygwin"; next; } + + if ($arg eq "--Darwin") { + $machine = "darwin"; + next; + } # destination type ########################################################## @@ -161,7 +166,7 @@ } #--forceRLArgEval my $command = - $path . "cilly.utah.${machine}.${type}.valueset.may.exe" ." ". + $path . "cilly.utah.${machine}.${type}.exe" ." ". "${fold} ${lines} --out ${output} " . " " . "--doinliner ${inlining} ${clean} ${shorten}" . " " . "${vectors} $cilly_args ${input}"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mle...@us...> - 2009-03-26 22:57:14
|
Revision: 1068 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1068&view=rev Author: mleopold Date: 2009-03-26 22:56:57 +0000 (Thu, 26 Mar 2009) Log Message: ----------- Added noted on beacon frames Modified Paths: -------------- trunk/diku/common/lib/simplemac/README Modified: trunk/diku/common/lib/simplemac/README =================================================================== --- trunk/diku/common/lib/simplemac/README 2009-03-25 19:24:11 UTC (rev 1067) +++ trunk/diku/common/lib/simplemac/README 2009-03-26 22:56:57 UTC (rev 1068) @@ -2,8 +2,11 @@ ========= An minimalistic interface to access 802.15.4 like radios (without the -802.15.4 protocol layer. It transmits packes using simple abstractions: +802.15.4 protocol layer. Packets are broadcast to all listening nodes, +using beacon frames in order to circumvent 802.15.4 addressing. +It transmits packes using simple abstractions: + interface SimpleMac { command error_t sendPacket(packet_t *packet); event void sendPacketDone(packet_t *packet, error_t result); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-03-25 19:24:41
|
Revision: 1067 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1067&view=rev Author: qzban Date: 2009-03-25 19:24:11 +0000 (Wed, 25 Mar 2009) Log Message: ----------- Small changes to tiny15four special build file for CC2430 + added nullTask to the nano platform Modified Paths: -------------- trunk/diku/mcs51/support/make/mcs51/CC2430-F128-TINY15FOUR.bat trunk/diku/mcs51/tos/platforms/nano/PlatformP.nc Modified: trunk/diku/mcs51/support/make/mcs51/CC2430-F128-TINY15FOUR.bat =================================================================== --- trunk/diku/mcs51/support/make/mcs51/CC2430-F128-TINY15FOUR.bat 2009-03-25 19:20:04 UTC (rev 1066) +++ trunk/diku/mcs51/support/make/mcs51/CC2430-F128-TINY15FOUR.bat 2009-03-25 19:24:11 UTC (rev 1067) @@ -18,6 +18,6 @@ rem Link using LX51 which should contain some optimisations... rem LX51 is only available in the "professional edition" -C:\Keil\C51\BIN\LX51.EXE "startup.obj", "app.obj" TO "app" PRINT (app.map) CLASSES( CODE(C:0x0100-C:0xFFFF), CONST(C:0x0100-C:0xFFFF), XDATA(X:0xE000-X:0xFF00), IDATA(I:0-I:0xFF)) REGFILE(app.reg) NOOVERLAY +C:\Keil\C51\BIN\LX51.EXE "startup.obj", "app.obj" TO "app" PRINT (app.map) CLASSES(XDATA(X:0xE000-X:0xFF00), IDATA(I:0-I:0xFF)) REGFILE(app.reg) NOOVERLAY C:\Keil\C51\BIN\OHX51.EXE "app" Modified: trunk/diku/mcs51/tos/platforms/nano/PlatformP.nc =================================================================== --- trunk/diku/mcs51/tos/platforms/nano/PlatformP.nc 2009-03-25 19:20:04 UTC (rev 1066) +++ trunk/diku/mcs51/tos/platforms/nano/PlatformP.nc 2009-03-25 19:24:11 UTC (rev 1067) @@ -152,5 +152,13 @@ return SUCCESS; } + /** + * We need at least one task to make sure that the task list is never empty. + * Else we confuse the compiler. + */ + task void nullTask() + { + } + default command error_t LedsInit.init() { return SUCCESS; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-03-25 19:20:36
|
Revision: 1066 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1066&view=rev Author: qzban Date: 2009-03-25 19:20:04 +0000 (Wed, 25 Mar 2009) Log Message: ----------- Minor changes to allow changing the UART speed at application level. Modified Paths: -------------- trunk/diku/freescale/tos/chips/hcs08/uart/Hcs08SerialByteCommP.nc trunk/diku/freescale/tos/chips/hcs08/uart/Hcs08UartP.nc trunk/diku/freescale/tos/platforms/dig528/hardware.h trunk/diku/freescale/tos/platforms/dig528/include/stdlib.h Added Paths: ----------- trunk/diku/freescale/tos/chips/hcs08/uart/serial.h Modified: trunk/diku/freescale/tos/chips/hcs08/uart/Hcs08SerialByteCommP.nc =================================================================== --- trunk/diku/freescale/tos/chips/hcs08/uart/Hcs08SerialByteCommP.nc 2009-03-25 19:09:14 UTC (rev 1065) +++ trunk/diku/freescale/tos/chips/hcs08/uart/Hcs08SerialByteCommP.nc 2009-03-25 19:20:04 UTC (rev 1066) @@ -28,6 +28,9 @@ * @author Tor Petterson <mo...@di...> */ +// Allow application specific serial.h to override baud rate settings. +#include <serial.h> + generic module Hcs08SerialByteCommP() { provides interface StdControl; Modified: trunk/diku/freescale/tos/chips/hcs08/uart/Hcs08UartP.nc =================================================================== --- trunk/diku/freescale/tos/chips/hcs08/uart/Hcs08UartP.nc 2009-03-25 19:09:14 UTC (rev 1065) +++ trunk/diku/freescale/tos/chips/hcs08/uart/Hcs08UartP.nc 2009-03-25 19:20:04 UTC (rev 1066) @@ -36,6 +36,7 @@ */ #include <Timer.h> +#include "serial.h" generic module Hcs08UartP(){ Added: trunk/diku/freescale/tos/chips/hcs08/uart/serial.h =================================================================== --- trunk/diku/freescale/tos/chips/hcs08/uart/serial.h (rev 0) +++ trunk/diku/freescale/tos/chips/hcs08/uart/serial.h 2009-03-25 19:20:04 UTC (rev 1066) @@ -0,0 +1,9 @@ +#ifndef __SERIAL_H_ +#define __SERIAL_H_ + + #ifndef PLATFORM_BAUDRATE + #define PLATFORM_BAUDRATE 38400U + #define PLATFORM_BYTETIME 208U + #endif + +#endif \ No newline at end of file Modified: trunk/diku/freescale/tos/platforms/dig528/hardware.h =================================================================== --- trunk/diku/freescale/tos/platforms/dig528/hardware.h 2009-03-25 19:09:14 UTC (rev 1065) +++ trunk/diku/freescale/tos/platforms/dig528/hardware.h 2009-03-25 19:20:04 UTC (rev 1066) @@ -2,11 +2,6 @@ #define __HARDWARE_H__ /* Include our CPU definitions */ #include <hcs08hardware.h> -// The baudrate to be used by the serial ports -enum { - PLATFORM_BAUDRATE = 38400, - PLATFORM_BYTETIME = 208 -}; #endif // _H_hardware_h Modified: trunk/diku/freescale/tos/platforms/dig528/include/stdlib.h =================================================================== --- trunk/diku/freescale/tos/platforms/dig528/include/stdlib.h 2009-03-25 19:09:14 UTC (rev 1065) +++ trunk/diku/freescale/tos/platforms/dig528/include/stdlib.h 2009-03-25 19:20:04 UTC (rev 1066) @@ -14,8 +14,4 @@ return s; } - #ifndef NULL - #define NULL ((void *) 0) - #endif - #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qz...@us...> - 2009-03-25 19:09:48
|
Revision: 1065 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1065&view=rev Author: qzban Date: 2009-03-25 19:09:14 +0000 (Wed, 25 Mar 2009) Log Message: ----------- Major changes to both drivers, applications and tools. There are still issues needing to be resolved. Problems exists with ACKing on the DIG528 platform and there seems to be stack overflow problems on CC2430... Modified Paths: -------------- trunk/diku/tiny15four/apps/non_beacon_test/ping/pingM.nc trunk/diku/tiny15four/apps/non_beacon_test/pong/pongM.nc trunk/diku/tiny15four/apps/p2p_test/ping/pingM.nc trunk/diku/tiny15four/apps/p2p_test/pong/pongM.nc trunk/diku/tiny15four/apps/radioTest/RadioTestC.nc trunk/diku/tiny15four/apps/radioTest/RadioTestP.nc trunk/diku/tiny15four/support/make/freescale802154.extra trunk/diku/tiny15four/tos/chips/cc2430/Tiny15FourPhyC.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/MacTimerP.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/PhyAttributes.h trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430CspHandlerP.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430InterruptHandlerP.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyAttributesP.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyControlP.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyInitP.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyReceiveP.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyTransmitP.nc trunk/diku/tiny15four/tos/chips/cc2430/phy/interfaces/cc2430CspTransmit.nc trunk/diku/tiny15four/tos/chips/mc13192/PhyAttributes.h trunk/diku/tiny15four/tos/chips/mc13192/Tiny15FourPhyC.nc trunk/diku/tiny15four/tos/chips/mc13192/mc13192Const.h trunk/diku/tiny15four/tos/chips/mc13192/mc13192Filters.h trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyDriverM.nc trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyInterrupt.nc trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyInterruptM.nc trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyTimerM.nc trunk/diku/tiny15four/tos/chips/mc13192/mc13192RadioInitM.nc trunk/diku/tiny15four/tos/chips/mc9s08gb60/HPLTimerP.nc trunk/diku/tiny15four/tos/chips/mc9s08gb60/HplSpiP.nc trunk/diku/tiny15four/tos/interfaces/debug/CommandInterpreter.nc trunk/diku/tiny15four/tos/interfaces/phy/PhyAttributes.nc trunk/diku/tiny15four/tos/lib/Tiny15FourC.nc trunk/diku/tiny15four/tos/lib/debug/BufferedUartP.nc trunk/diku/tiny15four/tos/lib/debug/CommandInterpreterP.nc trunk/diku/tiny15four/tos/lib/debug/ConsoleP.nc trunk/diku/tiny15four/tos/lib/freescale802154/Freescale802154M.nc trunk/diku/tiny15four/tos/lib/freescale802154/Tiny15FourC.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/McpsDataIndicationM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/McpsDataRequestConfirmM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/MlmeAssociateIndicationResponseM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/MlmeAssociateRequestConfirmM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/MlmeBeaconNotifyIndicationM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/MlmeCommStatusIndicationM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/MlmeDisassociateIndicationM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/MlmeDisassociateRequestConfirmM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/MlmeGtsIndicationM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/MlmeOrphanIndicationResponseM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/MlmePollRequestConfirmM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/MlmeRxEnableRequestConfirmM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/PanDescriptorM.nc trunk/diku/tiny15four/tos/lib/freescale802154/macApi/PibAttributeM.nc trunk/diku/tiny15four/tos/lib/mac/AssociateM.nc trunk/diku/tiny15four/tos/lib/mac/BeaconTrackerM.nc trunk/diku/tiny15four/tos/lib/mac/CsmaM.nc trunk/diku/tiny15four/tos/lib/mac/MacPibDatabaseM.nc trunk/diku/tiny15four/tos/lib/mac/ScanServiceM.nc trunk/diku/tiny15four/tos/lib/mac/StartM.nc trunk/diku/tiny15four/tos/lib/mac/Tiny15FourMacC.nc trunk/diku/tiny15four/tos/lib/tools/FIFOQueueM.nc trunk/diku/tiny15four/tos/lib/tools/SimpleBufferManM.nc trunk/diku/tiny15four/tos/lib/tools/endianconv.h Added Paths: ----------- trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyFilteringP.nc trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyFilteringP.nc trunk/diku/tiny15four/tos/interfaces/phy/PhyFiltering.nc trunk/diku/tiny15four/tos/lib/freescale802154/UartControlP.nc trunk/diku/tiny15four/tos/platforms/dig528/serial.h Removed Paths: ------------- trunk/diku/tiny15four/tos/lib/freescale802154/endianconv.h Modified: trunk/diku/tiny15four/apps/non_beacon_test/ping/pingM.nc =================================================================== --- trunk/diku/tiny15four/apps/non_beacon_test/ping/pingM.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/apps/non_beacon_test/ping/pingM.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -83,6 +83,8 @@ TOSH_ASSIGN_PIN(PROFILING9, B, 1); #endif + uint8_t myAddr[8] = {0x00, 0x50, 0xC2, 0x37, 0xB0, 0x01, 0x00, 0x1D}; + uint8_t logicalChannel; uint16_t myPanId; uint16_t myShortAddr; @@ -99,6 +101,9 @@ command error_t Init.init() { + // Setup extended address for the device. + NTOUH64(myAddr, aExtendedAddress); + #ifdef PROFILING // Setup profiling pins as output pins. TOSH_MAKE_PROFILING1_OUTPUT(); @@ -130,8 +135,6 @@ event void Boot.booted() { - uint8_t myAddr[8] = {0x1D, 0x00, 0x01, 0xB0, 0x37, 0xC2, 0x50, 0x00}; - memcpy(aExtendedAddress, myAddr, 8); call CommandInterpreter.prompt(); } @@ -345,7 +348,7 @@ call MlmeScanRequestConfirm.setScanChannels(request,0x0000F000); call MlmeScanRequestConfirm.setScanDuration(request,6); - if (call MlmeRequestConfirmScan.request(request)) + if (SUCCESS == call MlmeRequestConfirmScan.request(request)) { DBG_STR("Starting scan...",1); } Modified: trunk/diku/tiny15four/apps/non_beacon_test/pong/pongM.nc =================================================================== --- trunk/diku/tiny15four/apps/non_beacon_test/pong/pongM.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/apps/non_beacon_test/pong/pongM.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -84,6 +84,8 @@ TOSH_ASSIGN_PIN(PROFILING9, B, 1); #endif + uint8_t myAddr[8] = {0x00, 0x50, 0xC2, 0x37, 0xB0, 0x01, 0x03, 0x61}; + uint8_t logicalChannel = 12; uint16_t myPanId = 0xDEAD; uint16_t myShortAddr = 0x0001; @@ -101,6 +103,9 @@ command error_t Init.init() { + // Setup extended address for the device. + NTOUH64(myAddr, aExtendedAddress); + #ifdef PROFILING // Setup profiling pins as output pins. TOSH_MAKE_PROFILING1_OUTPUT(); @@ -134,8 +139,6 @@ event void Boot.booted() { - uint8_t myAddr[8] = {0x61, 0x03, 0x01, 0xB0, 0x37, 0xC2, 0x50, 0x00}; - memcpy(aExtendedAddress, myAddr, 8); call CommandInterpreter.prompt(); } Modified: trunk/diku/tiny15four/apps/p2p_test/ping/pingM.nc =================================================================== --- trunk/diku/tiny15four/apps/p2p_test/ping/pingM.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/apps/p2p_test/ping/pingM.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -1,4 +1,5 @@ -/* Copyright (c) 2007, Jan Flora <jan...@di...> +/** + * Copyright (c) 2007, Jan Flora <jan...@di...> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -95,6 +96,12 @@ command error_t Init.init() { + // Setup my address in the system. + NTOUH64(myExtAddress, aExtendedAddress); + + //uint8_t myAddr[8] = {0x1D, 0x00, 0x01, 0xB0, 0x37, 0xC2, 0x50, 0x00}; + //memcpy(aExtendedAddress, myAddr, 8); + #ifdef PROFILING // Setup profiling pins as output pins. TOSH_MAKE_PROFILING1_OUTPUT(); @@ -126,8 +133,6 @@ event void Boot.booted() { - uint8_t myAddr[8] = {0x1D, 0x00, 0x01, 0xB0, 0x37, 0xC2, 0x50, 0x00}; - memcpy(aExtendedAddress, myAddr, 8); call CommandInterpreter.prompt(); } @@ -177,6 +182,7 @@ post rxOn(); } else { DBG_STR("Ping failed.",1); + call CommandInterpreter.prompt(); } call McpsDataRequestConfirm.destroy(confirm); @@ -224,6 +230,7 @@ myMsduHandle++; } else { DBG_STR("Transmission of ping failed.",1); + call CommandInterpreter.prompt(); } // Clean up. @@ -251,6 +258,7 @@ } else { DBG_STRINT("Could not turn off receiver. Error was: ",status,1); } + call CommandInterpreter.prompt(); } call MlmeRxEnableRequestConfirm.destroy(confirm); @@ -282,6 +290,7 @@ DBG_STR("RxOn was requested",1); } else { DBG_STR("RxOn request failed",1); + call CommandInterpreter.prompt(); } } @@ -306,6 +315,7 @@ DBG_STR("RxOff was requested",1); } else { DBG_STR("RxOff request failed",1); + call CommandInterpreter.prompt(); } } Modified: trunk/diku/tiny15four/apps/p2p_test/pong/pongM.nc =================================================================== --- trunk/diku/tiny15four/apps/p2p_test/pong/pongM.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/apps/p2p_test/pong/pongM.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -95,6 +95,12 @@ command error_t Init.init() { + // Setup my address in the system. + NTOUH64(myExtAddress, aExtendedAddress); + + //uint8_t myAddr[8] = {0x61, 0x03, 0x01, 0xB0, 0x37, 0xC2, 0x50, 0x00}; + //memcpy(aExtendedAddress, myAddr, 8); + #ifdef PROFILING // Setup profiling pins as output pins. TOSH_MAKE_PROFILING1_OUTPUT(); @@ -128,8 +134,6 @@ event void Boot.booted() { - uint8_t myAddr[8] = {0x61, 0x03, 0x01, 0xB0, 0x37, 0xC2, 0x50, 0x00}; - memcpy(aExtendedAddress, myAddr, 8); call CommandInterpreter.prompt(); } @@ -178,6 +182,7 @@ DBG_STR("Ping reply transmitted.",1); } else { DBG_STR("Ping reply failed.",1); + call CommandInterpreter.prompt(); } call McpsDataRequestConfirm.destroy(confirm); @@ -222,6 +227,7 @@ myMsduHandle++; } else { DBG_STR("Transmission of ping reply failed.",1); + call CommandInterpreter.prompt(); } // Clean up. @@ -249,8 +255,8 @@ DBG_STRINT("Could not turn on receiver. Error was: ",status,1); } else { DBG_STRINT("Could not turn off receiver. Error was: ",status,1); - post pingReply(); } + call CommandInterpreter.prompt(); } call MlmeRxEnableRequestConfirm.destroy(confirm); @@ -283,6 +289,7 @@ DBG_STR("RxOn was requested",1); } else { DBG_STR("RxOn request failed",1); + call CommandInterpreter.prompt(); } } @@ -307,6 +314,7 @@ DBG_STR("RxOff was requested",1); } else { DBG_STR("RxOff request failed",1); + call CommandInterpreter.prompt(); } } Modified: trunk/diku/tiny15four/apps/radioTest/RadioTestC.nc =================================================================== --- trunk/diku/tiny15four/apps/radioTest/RadioTestC.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/apps/radioTest/RadioTestC.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -36,6 +36,7 @@ components MainC, Tiny15FourPhyC, DebugC, + PlatformInitC, RadioTestP, AsyncAlarmC; @@ -44,14 +45,17 @@ RadioTestP.CommandInterpreter -> DebugC.CommandInterpreter; RadioTestP.PhyReceive -> Tiny15FourPhyC.PhyReceive; RadioTestP.PhyTransmit -> Tiny15FourPhyC.PhyTransmit; + RadioTestP.PhyAttributes -> Tiny15FourPhyC.PhyAttributes; + RadioTestP.PhyFiltering -> Tiny15FourPhyC.PhyFiltering; + RadioTestP.LocalTime -> AsyncAlarmC.LocalTime; Tiny15FourPhyC.LocalTime -> AsyncAlarmC.LocalTime; Tiny15FourPhyC.Debug -> DebugC.Debug; AsyncAlarmC.Debug -> DebugC.Debug; - - MainC.SoftwareInit -> RadioTestP.Init; + + MainC.SoftwareInit -> PlatformInitC.Init; MainC.SoftwareInit -> AsyncAlarmC.Init; MainC.SoftwareInit -> Tiny15FourPhyC.Init; - + MainC.SoftwareInit -> RadioTestP.Init; } \ No newline at end of file Modified: trunk/diku/tiny15four/apps/radioTest/RadioTestP.nc =================================================================== --- trunk/diku/tiny15four/apps/radioTest/RadioTestP.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/apps/radioTest/RadioTestP.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -1,4 +1,5 @@ -/* Copyright (c) 2009, Jan Flora <jan...@di...> +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -37,9 +38,16 @@ uses { interface Boot; - interface Debug; + + interface PhyAttributes; + interface PhyFiltering; interface PhyReceive; interface PhyTransmit; + + interface LocalTime<time_t> as LocalTime; + + // Debugging + interface Debug; interface CommandInterpreter; } } @@ -51,54 +59,53 @@ uint8_t frameBuf[128]; txdata_t txData; char *payload = "abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrst"; + char dataFrame[] = {0x21, 0xCC, 0xFC, 0xFF, 0xFF, 0x61, 0x03, 0x01, 0xB0, 0x37, 0xC2, 0x50, 0x00, 0xFF, 0xFF, 0x1D, 0x00, 0x01, 0xB0, 0x37, 0xC2, 0x50, 0x00, 0x70, 0x69, 0x6E, 0x67, 0x00}; + uint8_t receiveAddr[] = {0x61, 0x03, 0x01, 0xB0, 0x37, 0xC2, 0x50, 0x00}; + uint8_t transmitAddr[] = {0x1D, 0x00, 0x01, 0xB0, 0x37, 0xC2, 0x50, 0x00}; + bool receiverOn = FALSE; + bool promiscuous = FALSE; + bool ccaEnabled = FALSE; + bool deferEnabled = FALSE; // Forward declaration. - void printRFStatus(); - void printFSMState(); - void printRXFifoCnt(); - void printVRState(); - void printT2Config(); + void togglePromiscuous(); + void transmitDataFrame(); void transmit(); void toggleReceiver(); + void toggleCca(); + void toggleDefer(); - task void dummyTask(){} - command error_t Init.init() { - uint32_t i = 0; - - call CommandInterpreter.addCommand("status", printRFStatus); - call CommandInterpreter.addCommand("fsm", printFSMState); - call CommandInterpreter.addCommand("fifo", printRXFifoCnt); - call CommandInterpreter.addCommand("vrstate", printVRState); call CommandInterpreter.addCommand("tx", transmit); call CommandInterpreter.addCommand("rx", toggleReceiver); - call CommandInterpreter.addCommand("t2conf", printT2Config); + call CommandInterpreter.addCommand("filter", togglePromiscuous); + call CommandInterpreter.addCommand("ackedtx", transmitDataFrame); + call CommandInterpreter.addCommand("cca", toggleCca); + call CommandInterpreter.addCommand("defer", toggleDefer); - // Wait so we get to see all output. - while (i<1000000) i++; - - DBG_STR("Init...",1); + // TODO: Implement the following tests: + // ACK-test + // Deferred transmit + // CCA-transmit + // Deferred CCA-transmit + // Energy detect + // Deferred receive return SUCCESS; } event void Boot.booted() { - uint32_t i = 0; - - // Wait so we get to see all output. - while (i<1000000) i++; - - DBG_STR("Booted...",1); + DBG_STR("Booted RadioTest...",1); // Prepare transmit. txData.txId = 1; txData.frame = payload; txData.length = 10; - txData.cca = TRUE; + txData.cca = FALSE; txData.immediateCommence = TRUE; txData.commenceTime = 0; @@ -109,19 +116,63 @@ void toggleReceiver() { if (receiverOn) { - DBG_STR("Turning off the receiver...",1); call PhyReceive.rxOff(); + DBG_STR("Receiver off...",1); receiverOn = FALSE; } else { - DBG_STR("Turning on the receiver...",1); + // Setup address filtering in the PHY. + call PhyFiltering.setExtendedAddress(receiveAddr); call PhyReceive.rxOn(0, TRUE); + DBG_STR("Receiver on...",1); receiverOn = TRUE; } + call CommandInterpreter.prompt(); } + void togglePromiscuous() + { + if (promiscuous) { + call PhyFiltering.setPromiscuousMode(FALSE); + DBG_STR("Promiscuous mode off...",1); + promiscuous = FALSE; + } else { + call PhyFiltering.setPromiscuousMode(TRUE); + DBG_STR("Promiscuous mode on...",1); + promiscuous = TRUE; + } + call CommandInterpreter.prompt(); + } + async event void PhyTransmit.txDone(phy_error_t error, uint8_t txId) { - DBG_STR("Transmission done...",1); + switch (txId) { + case 1: + DBG_STR("Transmission done...",1); + break; + case 2: + DBG_STR("Acked transmission done...",1); + break; + } + + switch (error) { + case PHY_SUCCESS: + DBG_STR("Status: PHY_SUCCESS",1); + break; + case PHY_CCA_FAIL: + DBG_STR("Status: PHY_CCA_FAIL",1); + break; + case PHY_DEADLINE_FAIL: + DBG_STR("Status: PHY_DEADLINE_FAIL",1); + break; + case PHY_ACK_FAIL: + DBG_STR("Status: PHY_ACK_FAIL",1); + break; + case PHY_TRX_BUSY: + DBG_STR("Status: PHY_TRX_BUSY",1); + break; + } + + call CommandInterpreter.prompt(); } async event uint8_t *PhyReceive.dataReady(rxdata_t *data) @@ -131,46 +182,50 @@ return data->frame; } - void printRFStatus() + void transmit() { - DBG_STRINT("RFStatus register: ",_CC2430_RFSTATUS,1); - call CommandInterpreter.prompt(); + txData.commenceTime = call LocalTime.getTime() + 0xF0; + + DBG_STR("Transmitting...",1); + call PhyTransmit.tx(&txData); } - void printFSMState() + void transmitDataFrame() { - DBG_STRINT("FSM state is: ",_CC2430_FSMSTATE,1); - call CommandInterpreter.prompt(); + txData.txId = 2; + txData.frame = dataFrame; + txData.length = 28; + txData.commenceTime = call LocalTime.getTime() + 0xF0; + + DBG_STR("Transmitting...",1); + call PhyTransmit.tx(&txData); } - void printRXFifoCnt() + void toggleCca() { - DBG_STRINT("RXFIFO count is: ",_CC2430_RXFIFOCNT,1); + if (ccaEnabled) { + txData.cca = FALSE; + DBG_STR("CCA mode off...",1); + ccaEnabled = FALSE; + } else { + txData.cca = TRUE; + DBG_STR("CCA mode on...",1); + ccaEnabled = TRUE; + } call CommandInterpreter.prompt(); } - void printVRState() + void toggleDefer() { - - if (_CC2430_RFPWR & _BV(CC2430_RFPWR_RREG_RADIO_PD)) { - DBG_STR("Voltage regulators are powered OFF",1); + if (deferEnabled) { + txData.immediateCommence = TRUE; + DBG_STR("Defer off...",1); + deferEnabled = FALSE; } else { - DBG_STR("Voltage regulators are powered ON",1); + txData.immediateCommence = FALSE; + DBG_STR("Defer on...",1); + deferEnabled = TRUE; } call CommandInterpreter.prompt(); } - - void printT2Config() - { - uint8_t test = T2CNF; - DBG_STRINT("Timer2 config is: ",test,1); - call CommandInterpreter.prompt(); - } - - void transmit() - { - DBG_STR("Transmitting...",1); - call PhyTransmit.tx(&txData); - call CommandInterpreter.prompt(); - } } \ No newline at end of file Modified: trunk/diku/tiny15four/support/make/freescale802154.extra =================================================================== --- trunk/diku/tiny15four/support/make/freescale802154.extra 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/support/make/freescale802154.extra 2009-03-25 19:09:14 UTC (rev 1065) @@ -50,7 +50,8 @@ -I$(TINY15FOUR_DIR)/tos/interfaces \ -I$(TINY15FOUR_DIR)/tos/interfaces/macApi \ -I$(TINY15FOUR_DIR)/tos/interfaces/tools \ - -I$(TINY15FOUR_DIR)/tos/interfaces/debug + -I$(TINY15FOUR_DIR)/tos/interfaces/debug \ + -DBIG_ENDIAN_BYTE_ORDERING export PFLAGS export NESC_FLAGS Modified: trunk/diku/tiny15four/tos/chips/cc2430/Tiny15FourPhyC.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/Tiny15FourPhyC.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/Tiny15FourPhyC.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -43,6 +43,7 @@ interface PhyTransmit; interface PhyEnergyDetect; interface PhyAttributes; + interface PhyFiltering; interface PhyControl; interface PhyReset; } @@ -58,6 +59,7 @@ cc2430InterruptHandlerP, cc2430PhyEnergyDetectP, cc2430PhyAttributesP, + cc2430PhyFilteringP, cc2430PhyReceiveP, cc2430PhyTransmitP, cc2430PhyControlP, @@ -119,6 +121,10 @@ PhyAttributes = cc2430PhyAttributesP.PhyAttributes; PhyReset = cc2430PhyAttributesP.PhyReset; + // Phy filtering. + PhyFiltering = cc2430PhyFilteringP.PhyFiltering; + PhyReset = cc2430PhyFilteringP.PhyReset; + // Phy control. PhyControl = cc2430PhyControlP.PhyControl; cc2430PhyControlP.Debug = Debug; Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/MacTimerP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/MacTimerP.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/MacTimerP.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -90,12 +90,9 @@ T2CNF &= ~_BV(CC2430_T2CNF_SYNC); // Start the mac timer - T2CNF |= _BV(CC2430_T2CNF_RUN); - - t2conf = T2PEROF2; - DBG_STRINT("Timer 2 PEROF2 is: ",t2conf,1); - - return SUCCESS; + T2CNF |= _BV(CC2430_T2CNF_RUN); + + return SUCCESS; } async command uint16_t MacCounter.getTime() Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/PhyAttributes.h =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/PhyAttributes.h 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/PhyAttributes.h 2009-03-25 19:09:14 UTC (rev 1065) @@ -35,5 +35,7 @@ uint32_t phySupportedChannels = 0x07FFF800; uint8_t phyContentionWindow = 1; uint8_t phyTransmitPower = 0; + bool phyPromiscuousMode = FALSE; + bool (*macFilter)(uint8_t*) = NULL; #endif Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430CspHandlerP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430CspHandlerP.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430CspHandlerP.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -57,10 +57,11 @@ uint8_t contentionWindow = 1; uint8_t operation; - #define CSP_OP_ED 1 - #define CSP_OP_TX 2 - #define CSP_OP_RX 3 - #define CSP_OP_RND 4 + #define CSP_OP_ED 1 + #define CSP_OP_TX 2 + #define CSP_OP_CCA_TX 3 + #define CSP_OP_RX 4 + #define CSP_OP_RND 5 command error_t Init.init() { @@ -69,6 +70,10 @@ RFIM |= _BV(CC2430_RFIM_CSP_STOP); RFIM |= _BV(CC2430_RFIM_CSP_INT); + RFIF &= ~_BV(CC2430_RFIF_CSP_WT); + RFIF &= ~_BV(CC2430_RFIF_CSP_STOP); + RFIF &= ~_BV(CC2430_RFIF_CSP_INT); + return SUCCESS; } @@ -79,11 +84,14 @@ command void EnergyDetect.performEnergyDetect() { - operation = CSP_OP_ED; - + // Reset operation type + atomic operation = 0; + // Clear CSP program memory. _CC2430_CSPT = 0xFF; RFST = ISSTOP; + + atomic operation = CSP_OP_ED; // Bring the radio into receive state. if (!(FSM_STATE_RX_SEARCH() || FSM_STATE_RX_ACTIVE())) { @@ -122,14 +130,18 @@ command void Transmit.initTx() { - operation = CSP_OP_TX; - + // Reset operation type + atomic operation = 0; + // Clear CSP program memory. _CC2430_CSPX = 0x0; - _CC2430_CSPZ = 0x0; + _CC2430_CSPY = 0x0; _CC2430_CSPT = 0xFF; RFST = ISSTOP; + // Set operation type. + atomic operation = CSP_OP_TX; + // Wait for CSPX symbol periods before starting the operation. // If the "deferredTx" command is not called, CSPX will be zero // and the instruction will be skipped. @@ -138,10 +150,12 @@ command void Transmit.ccaTx() { - // Load contention window size into CSPY. - _CC2430_CSPY = phyContentionWindow; - _CC2430_CSPZ = 0x1; + // Set operation type. + atomic operation = CSP_OP_CCA_TX; + // Load contention window size into CSPZ. + _CC2430_CSPZ = phyContentionWindow; + // Put the radio in receive state // TODO: Is it necessary to go into idle state first? RFST = SRFOFF; @@ -158,23 +172,25 @@ RFST = WAITW(8); // Check if the CCA is valid. If not, transmission fails. - RFST = SKIP(1, C_CCA_IS_VALID); + RFST = SKIP(2, C_CCA_IS_VALID); + RFST = INT; RFST = SSTOP; // Repeat the CCA process until contention window size is reached. - RFST = DECY; - RFST = RPT(C_CSPY_IS_NON_ZERO); - - // Decrement CSPZ to indicate that the CCA process was successful. RFST = DECZ; + RFST = RPT(C_CSPZ_IS_NON_ZERO); } - + //uint32_t start,end; command void Transmit.startDeferredTx(uint32_t timestamp) { - // Tell the MCU that it is time to write the frame to the TXFIFO. - //RFST = INT; // Start the transmission process. This takes 12 symbol periods. RFST = STXON; + + // Wait for the transmission to finish. + RFST = WHILE(C_SFD_IS_ACTIVE); + RFST = WHILE(C_SFD_IS_INACTIVE); + RFST = WHILE(C_SFD_IS_ACTIVE); + RFST = INCY; // Calculate number of symbols to defer the transmission _CC2430_CSPX = (timestamp - call LocalTime.getTime())-12; @@ -192,16 +208,23 @@ command void Transmit.startTx() { - // Tell the MCU that it is time to write the frame to the TXFIFO. - //RFST = INT; // Start the transmission process. This takes 12 symbol periods. RFST = STXON; + + // Wait for the transmission to finish. + RFST = WHILE(C_SFD_IS_ACTIVE); + RFST = WHILE(C_SFD_IS_INACTIVE); + RFST = WHILE(C_SFD_IS_ACTIVE); + RFST = INCY; + RFST = ISSTART; + //start = call LocalTime.getTime(); } command void Receive.startDeferredRx(uint32_t timestamp) { - operation = CSP_OP_RX; + // Reset operation type + atomic operation = 0; // Clear CSP program memory. _CC2430_CSPX = 0x0; @@ -215,6 +238,9 @@ // Calculate number of symbols to defer the transmission _CC2430_CSPX = (timestamp - call LocalTime.getTime())-12; + // Set operation type. + atomic operation = CSP_OP_RX; + RFST = ISSTART; // Check for boundary condition: Has a MAC timer overflow @@ -232,19 +258,22 @@ if (!operation) return; switch(operation) { + case CSP_OP_TX: + case CSP_OP_CCA_TX: + if (_CC2430_CSPY) { + // TX operation has completed. + atomic operation = 0; + /*end = call LocalTime.getTime(); + DBG_STRINT("Start was: ",start,1); + DBG_STRINT("End was: ",end,1);*/ + signal Transmit.txDone(); + } + break; case CSP_OP_ED: atomic operation = 0; // Read out and return the RSSI value. signal EnergyDetect.energyDetectDone((int8_t)_CC2430_RSSIL); break; - case CSP_OP_TX: - // Check CSPZ for return value. - if (_CC2430_CSPZ) { - atomic operation = 0; - // The transmit operation failed CCA. - signal Transmit.failedCca(); - } - break; case CSP_OP_RND: atomic operation = 0; // Return the generated random number. @@ -255,18 +284,14 @@ async event void CspInterrupt.interrupted() { - //uint32_t before, after; // Fast return if no operation was selected. if (!operation) return; switch(operation) { - case CSP_OP_TX: - //before = call LocalTime.getTime(); - // Worst case, this write takes 52 symbol periods. - signal Transmit.writeFrame(); - //after = call LocalTime.getTime(); - //DBG_STRINT("Time before write: ",before,1); - //DBG_STRINT("Time after write: ",after,1); + case CSP_OP_CCA_TX: + // The transmit operation failed CCA. + atomic operation = 0; + signal Transmit.failedCca(); break; } } @@ -282,9 +307,9 @@ DBG_STR("failedCca event not connected..",1); } - default async event void Transmit.writeFrame() + default async event void Transmit.txDone() { - DBG_STR("writeFrame event not connected..",1); + DBG_STR("txDone event not connected..",1); } default event void Random.randomDone(uint8_t rand) Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430InterruptHandlerP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430InterruptHandlerP.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430InterruptHandlerP.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -82,43 +82,43 @@ MCS51_INTERRUPT(SIG_RF) { // RF interrupt handler. - if (RFIF & _BV(CC2430_RFIF_RREG_ON)) { + if ((RFIM & _BV(CC2430_RFIM_RREG_PD)) && (RFIF & _BV(CC2430_RFIF_RREG_ON))) { // RF Voltage regulator has turned on. } - if (RFIF & _BV(CC2430_RFIF_TXDONE)) { + if ((RFIM & _BV(CC2430_RFIM_TXDONE)) && (RFIF & _BV(CC2430_RFIF_TXDONE))) { // Transmission completed. // Clear interrupt flag. RFIF &= ~_BV(CC2430_RFIF_TXDONE); signal TxInterrupt.txDone(); } - if (RFIF & _BV(CC2430_RFIF_FIFOP)) { + if ((RFIM & _BV(CC2430_RFIM_FIFOP)) && (RFIF & _BV(CC2430_RFIF_FIFOP))) { // Number of bytes in RXFIFO is above threshold. // Clear interrupt flag. RFIF &= ~_BV(CC2430_RFIF_FIFOP); signal RxInterrupt.dataReady(); } - if (RFIF & _BV(CC2430_RFIF_SFD)) { + if ((RFIM & _BV(CC2430_RFIM_SFD)) && (RFIF & _BV(CC2430_RFIF_SFD))) { // SFD detected. // Clear interrupt flag. RFIF &= ~_BV(CC2430_RFIF_SFD); signal RxInterrupt.frameDetected(); } - if (RFIF & _BV(CC2430_RFIF_CCA)) { + if ((RFIM & _BV(CC2430_RFIM_CCA)) && (RFIF & _BV(CC2430_RFIF_CCA))) { // Channel is clear } - if (RFIF & _BV(CC2430_RFIF_CSP_WT)) { + if ((RFIM & _BV(CC2430_RFIM_CSP_WT)) && (RFIF & _BV(CC2430_RFIF_CSP_WT))) { // CSP wait condition is true. // Clear interrupt flag. RFIF &= ~_BV(CC2430_RFIF_CSP_WT); signal CspInterrupt.wait(); } - if (RFIF & _BV(CC2430_RFIF_CSP_STOP)) { + if ((RFIM & _BV(CC2430_RFIM_CSP_STOP)) && (RFIF & _BV(CC2430_RFIF_CSP_STOP))) { // CSP program execution stopped. // Clear interrupt flag. RFIF &= ~_BV(CC2430_RFIF_CSP_STOP); signal CspInterrupt.stopped(); } - if (RFIF & _BV(CC2430_RFIF_CSP_INT)) { + if ((RFIM & _BV(CC2430_RFIM_CSP_INT)) && (RFIF & _BV(CC2430_RFIF_CSP_INT))) { // CSP INT instruction was executed. // Clear interrupt flag. RFIF &= ~_BV(CC2430_RFIF_CSP_INT); Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyAttributesP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyAttributesP.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyAttributesP.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -40,8 +40,6 @@ } implementation { - // Phy attribute variables. - norace bool (*myFilter)(uint8_t*) = NULL; command void PhyReset.reset() { @@ -50,7 +48,6 @@ phySupportedChannels = 0x07FFF800; phyContentionWindow = 1; phyTransmitPower = 0; - myFilter = NULL; // Reset channel selection. call PhyAttributes.setChannel(phyCurChannel); @@ -101,18 +98,6 @@ return SUCCESS; } - command error_t PhyAttributes.setFilter(bool (*filter)(uint8_t*)) - { - myFilter = filter; - return SUCCESS; - } - - command error_t PhyAttributes.clearFilter() - { - myFilter = NULL; - return SUCCESS; - } - command uint32_t PhyAttributes.getSupportedChannels() { return phySupportedChannels; Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyControlP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyControlP.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyControlP.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -46,7 +46,9 @@ async command phy_error_t PhyControl.trxOff(bool force) { - DBG_STR("cc2430: PhyControl.trxOff not implemented...",1); + // Turn off the transciever. + RFST = ISRFOFF; + return PHY_SUCCESS; } Added: trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyFilteringP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyFilteringP.nc (rev 0) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyFilteringP.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -0,0 +1,104 @@ +/** + * Copyright (c) 2009, Jan Flora <jan...@di...> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the University of Copenhagen nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @author Jan Flora <jan...@di...> + */ + +module cc2430PhyFilteringP +{ + provides + { + interface PhyFiltering; + interface PhyReset; + } +} +implementation +{ + command void PhyReset.reset() + { + call PhyFiltering.clearMacFilter(); + call PhyFiltering.setPromiscuousMode(FALSE); + } + + command void PhyFiltering.setMacFilter(bool (*filter)(uint8_t*)) + { + macFilter = filter; + } + + command void PhyFiltering.clearMacFilter() + { + macFilter = NULL; + } + + command void PhyFiltering.setPromiscuousMode(bool promiscuous) + { + phyPromiscuousMode = promiscuous; + if (phyPromiscuousMode) { + // Disable frame filtering + _CC2430_MDMCTRL0H &= ~_BV(CC2430_MDMCTRL0H_ADDR_DECODE); + // Disable auto-ACK + _CC2430_MDMCTRL0L &= ~_BV(CC2430_MDMCTRL0L_AUTOACK); + } else { + // Enable frame filtering + _CC2430_MDMCTRL0H |= _BV(CC2430_MDMCTRL0H_ADDR_DECODE); + // Enable auto-ACK + _CC2430_MDMCTRL0L |= _BV(CC2430_MDMCTRL0L_AUTOACK); + } + } + + command void PhyFiltering.setPanId(uint8_t *pan) + { + _CC2430_PANID = *((uint16_t*)pan); + } + + command void PhyFiltering.setShortAddress(uint8_t *shortAddr) + { + _CC2430_SHORTADDR = *((uint16_t*)shortAddr); + } + + command void PhyFiltering.setExtendedAddress(uint8_t *extAddr) + { + _CC2430_IEEE_ADDR7 = extAddr[7]; + _CC2430_IEEE_ADDR6 = extAddr[6]; + _CC2430_IEEE_ADDR5 = extAddr[5]; + _CC2430_IEEE_ADDR4 = extAddr[4]; + _CC2430_IEEE_ADDR3 = extAddr[3]; + _CC2430_IEEE_ADDR2 = extAddr[2]; + _CC2430_IEEE_ADDR1 = extAddr[1]; + _CC2430_IEEE_ADDR0 = extAddr[0]; + } + + command void PhyFiltering.setPanCoordinator(bool coord) + { + if (coord) { + _CC2430_MDMCTRL0H |= _BV(CC2430_MDMCTRL0H_PAN_COORDINATOR); + } else { + _CC2430_MDMCTRL0H &= ~_BV(CC2430_MDMCTRL0H_PAN_COORDINATOR); + } + } +} \ No newline at end of file Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyInitP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyInitP.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyInitP.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -81,8 +81,8 @@ void setupRF() { - // disable address recognition - _CC2430_MDMCTRL0H &= ~_BV(CC2430_MDMCTRL0H_ADDR_DECODE); + // Enable address recognition + _CC2430_MDMCTRL0H |= _BV(CC2430_MDMCTRL0H_ADDR_DECODE); // Enable auto-crc _CC2430_MDMCTRL0L |= _BV(CC2430_MDMCTRL0L_AUTOCRC); @@ -92,5 +92,13 @@ // Set FIFOP threshold to max (0x7F) _CC2430_IOCFG0 = 0x7F; + + // Don't abort receive when a rxon strobe is issued. + _CC2430_FSMTC1 = 0x01; + + // Tuning adjustments for optimal radio performance. + // Taken from TI's own code. + _CC2430_RXCTRL0H = 0x32; + _CC2430_RXCTRL0L = 0xF5; } } \ No newline at end of file Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyReceiveP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyReceiveP.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyReceiveP.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -66,9 +66,15 @@ command error_t Init.init() { // Enable required interrupts. - //RFIM |= _BV(CC2430_RFIM_FIFOP); RFIM |= _BV(CC2430_RFIM_SFD); + // Clear interrupt flag. + RFIF &= ~_BV(CC2430_RFIF_SFD); + + // Flush the rx fifo + RFST = ISFLUSHRX; + RFST = ISFLUSHRX; + // setup DMA for reception dmaConfigRecv = call Dma.getConfig(); @@ -127,6 +133,9 @@ // FIFO Queue is empty. // Setup a DMA transfer to read the frame length. dmaReadFrameLength(); + } else { + // This is clearly an error. Empty the rx fifo. + RFST = ISFLUSHRX; } // A new frame reception has begun. Record the rx timestamp for later use. Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyTransmitP.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyTransmitP.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/cc2430PhyTransmitP.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -56,19 +56,27 @@ uint8_t *txQueueBuf[2]; FIFOQueue_t txQueue; bool waitingForAck = FALSE; + bool ackedTx = FALSE; dma_config_t * dmaConfigSend; + bool dmaDeferred = FALSE; + bool deferredAck = FALSE; uint8_t dmaLength = 0; + + void startDeferredDmaTransfer(); command error_t Init.init() { // Enable required interrupts. RFIM |= _BV(CC2430_RFIM_TXDONE); + // Clear interrupt flag. + RFIF &= ~_BV(CC2430_RFIF_TXDONE); + // Prepare transmission queue. call TxQueue.initQueue(&txQueue, txQueueBuf, 2); - /* setup DMA for send */ + // setup DMA for send dmaConfigSend = call Dma.getConfig(); dmaConfigSend->DESTADDR = (uint16_t) 0xDFD9; @@ -103,9 +111,13 @@ atomic { dmaDeferred = TRUE; dmaLength = data->length; + deferredAck = (data->frame[0] & 0x20); } } else { // TXFIFO is free. Initiate DMA transfer immediately. + RFST = ISFLUSHTX; + + atomic ackedTx = (data->frame[0] & 0x20); // Transfer length field to the FIFO buffer. RFD = (data->length+2); @@ -128,76 +140,48 @@ async event void TxInterrupt.txDone() { + + } + + async event void CspTransmit.txDone() + { txdata_t *data; - bool ack, dmaTransfer; - uint8_t len = 0; - atomic { - dmaTransfer = dmaDeferred; - dmaDeferred = FALSE; - len = dmaLength; - } + // Flush the rx fifo + RFST = ISFLUSHRX; + RFST = ISFLUSHRX; - if (dmaTransfer) { - // TXFIFO is now free. Initiate DMA transfer. - // Transfer length field to the FIFO buffer. - RFD = (len+2); - - // Initiate the DMA transfer. - call Dma.startTransfer(); - } - - call TxQueue.peek(&txQueue, &data); - ack = (data->frame[0] & 0x20); - - if (ack) { + if (ackedTx) { // We must wait for the recipient to acknowledge // the reception of the frame. - //RFST = ISRXON; // Wait for 54 symbol periods for the ACK frame to arrive. // We add 22 symbol periods to the wait interval so that an // ACK frame received after 54 symbol periods can be registered // and signalled by the rx module. call OverflowChannel.arm(0, call OverflowCounter.getTime()+76); atomic waitingForAck = TRUE; - } else { - // We are done. - call TxQueue.dequeue(&txQueue, &data); - signal PhyTransmit.txDone(PHY_SUCCESS, data->txId); + return; } + + // Start any pending DMA transfer. + startDeferredDmaTransfer(); + + // We are done. + call TxQueue.dequeue(&txQueue, &data); + signal PhyTransmit.txDone(PHY_SUCCESS, data->txId); } async event void CspTransmit.failedCca() { txdata_t *data; + + // Start any pending DMA transfer. + startDeferredDmaTransfer(); + call TxQueue.dequeue(&txQueue, &data); signal PhyTransmit.txDone(PHY_CCA_FAIL, data->txId); } - - async event void CspTransmit.writeFrame() - { -/* txdata_t *data; - uint8_t i; - uint8_t *frame; - - call TxQueue.peek(&txQueue, &data); - - // Transfer length field to the FIFO buffer. - RFD = (data->length+2); - // Initiate the DMA transfer. - call Dma.startTransfer(); - - // Write data to transmission buffer. - frame = data->frame; - RFD = (data->length+2); - for (i=0; i<data->length; i++) { - RFD = *frame++; - } - RFD = (0); - RFD = (0);*/ - } - async event void AckControl.AckReceived(uint8_t seqNum) { txdata_t *data; @@ -214,6 +198,9 @@ // Check if we are waiting for an ack frame. if (!wasWaitingForAck) return; + // Start any pending DMA transfer. + startDeferredDmaTransfer(); + // Get the tx data structure. call TxQueue.dequeue(&txQueue, &data); @@ -240,16 +227,42 @@ call OverflowChannel.stop(0); atomic waitingForAck = FALSE; + // Start any pending DMA transfer. + startDeferredDmaTransfer(); + call TxQueue.dequeue(&txQueue, &data); signal PhyTransmit.txDone(PHY_ACK_FAIL, data->txId); } + void startDeferredDmaTransfer() + { + bool dmaTransfer; + uint8_t len = 0; + + atomic { + dmaTransfer = dmaDeferred; + dmaDeferred = FALSE; + ackedTx = deferredAck; + len = dmaLength; + } + + if (dmaTransfer) { + // TXFIFO is now free. Initiate DMA transfer. + RFST = ISFLUSHTX; + + // Transfer length field to the FIFO buffer. + RFD = (len+2); + + // Initiate the DMA transfer. + call Dma.startTransfer(); + } + } + async event void Dma.transferDone() { // Write RSSI & LQI fields as 0. RFD = 0; RFD = 0; - //DBG_STR("Done transfering frame to tx buffer.",1); } default async event void PhyTransmit.txDone(phy_error_t error, uint8_t txId) Modified: trunk/diku/tiny15four/tos/chips/cc2430/phy/interfaces/cc2430CspTransmit.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/cc2430/phy/interfaces/cc2430CspTransmit.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/cc2430/phy/interfaces/cc2430CspTransmit.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -35,5 +35,5 @@ command void startDeferredTx(uint32_t timestamp); command void startTx(); async event void failedCca(); - async event void writeFrame(); + async event void txDone(); } \ No newline at end of file Modified: trunk/diku/tiny15four/tos/chips/mc13192/PhyAttributes.h =================================================================== --- trunk/diku/tiny15four/tos/chips/mc13192/PhyAttributes.h 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/mc13192/PhyAttributes.h 2009-03-25 19:09:14 UTC (rev 1065) @@ -1,4 +1,5 @@ -/* Copyright (c) 2006, Jan Flora <jan...@di...> +/** + * Copyright (c) 2006, Jan Flora <jan...@di...> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -24,9 +25,9 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - @author Jan Flora <jan...@di...> -*/ +/** + * @author Jan Flora <jan...@di...> + */ #ifndef _PHYATTRIBUTES_H_ #define _PHYATTRIBUTES_H_ @@ -36,4 +37,11 @@ uint8_t phyContentionWindow = 1; uint8_t phyTransmitPower = 0; + // Filtering + bool (*macFilter)(uint8_t*) = NULL; + bool phyPromiscuousMode = FALSE; + uint8_t *filterPanId; + uint8_t *filterShortAddr; + uint8_t *filterExtAddr; + bool filterIsPanCoord; #endif Modified: trunk/diku/tiny15four/tos/chips/mc13192/Tiny15FourPhyC.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/mc13192/Tiny15FourPhyC.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/mc13192/Tiny15FourPhyC.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -32,6 +32,8 @@ #include "mc13192InterruptRegisters.h" #include "mc13192Pins.h" #include "mc13192Const.h" +#include "PhyAttributes.h" +#include "mc13192Filters.h" #include <time.h> configuration Tiny15FourPhyC @@ -43,6 +45,7 @@ interface PhyTransmit; interface PhyEnergyDetect; interface PhyAttributes; + interface PhyFiltering; interface PhyControl; interface PhyReset; } @@ -57,19 +60,22 @@ components mc13192PhyDriverM, mc13192PhyInterruptM, mc13192PhyTimerM, + mc13192PhyFilteringP, // Provided by the MCU implementation. mc13192SpiC; + Init = mc13192PhyDriverM.Init; Init = mc13192PhyTimerM.Init; - Init = mc13192PhyDriverM.Init; PhyReceive = mc13192PhyDriverM.PhyReceive; PhyTransmit = mc13192PhyDriverM.PhyTransmit; PhyAttributes = mc13192PhyDriverM.PhyAttributes; + PhyFiltering = mc13192PhyFilteringP.PhyFiltering; PhyEnergyDetect = mc13192PhyDriverM.PhyEnergyDetect; PhyControl = mc13192PhyDriverM.PhyControl; PhyReset = mc13192PhyDriverM.PhyReset; + PhyReset = mc13192PhyFilteringP.PhyReset; mc13192PhyDriverM.Interrupt -> mc13192PhyInterruptM.Interrupt; mc13192PhyDriverM.Timer -> mc13192PhyTimerM.Timer; Modified: trunk/diku/tiny15four/tos/chips/mc13192/mc13192Const.h =================================================================== --- trunk/diku/tiny15four/tos/chips/mc13192/mc13192Const.h 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/mc13192/mc13192Const.h 2009-03-25 19:09:14 UTC (rev 1065) @@ -152,7 +152,7 @@ #define TX_MODE 0x4203 // Was: 0x4203 #define TX_STRM_MODE 0x5200 - #define RX_STRM_MODE 0x4922 + #define RX_STRM_MODE 0x4922 // Was: 0x4922 #define TX_CCA_MODE1 0x4615 #define TX_CCA_MODE2 0x4616 Modified: trunk/diku/tiny15four/tos/chips/mc13192/mc13192Filters.h =================================================================== --- trunk/diku/tiny15four/tos/chips/mc13192/mc13192Filters.h 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/mc13192/mc13192Filters.h 2009-03-25 19:09:14 UTC (rev 1065) @@ -1,4 +1,5 @@ -/* Copyright (c) 2006, Jan Flora <jan...@di...> +/** + * Copyright (c) 2006, Jan Flora <jan...@di...> * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -24,14 +25,15 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* - @author Jan Flora <jan...@di...> -*/ +/** + * @author Jan Flora <jan...@di...> + */ #ifndef _MC13192_FILTERS_H_ #define _MC13192_FILTERS_H_ - #include "MacPib.h" + #include "PhyAttributes.h" + typedef struct { uint8_t FrameType : 3; @@ -58,7 +60,7 @@ norace frameControlHeader_t *rxFrameControl; norace uint8_t rxDstAddrLength; norace uint8_t *filterValue; - norace uint8_t rxSeqNum; + //norace uint8_t rxSeqNum; norace bool (*filterWord)(uint8_t*); norace char *filterReason; @@ -102,8 +104,8 @@ } // Preaccept beacons when not associated. - //if (!(rxFrameControl->FrameType) && filterPanId[0] == 0xFF && filterPanId[1] == 0xFF) { - if (!(rxFrameControl->FrameType) && macPanId == 0xFFFF) { + if (!(rxFrameControl->FrameType) && filterPanId[0] == 0xFF && filterPanId[1] == 0xFF) { + //if (!(rxFrameControl->FrameType) && filterPanId == 0xFFFF) { filterWord = dummyFilter; return TRUE; } @@ -125,9 +127,8 @@ { // Not a real filter. Just fetch the sequence number // and prepare the right filter. - rxSeqNum = data[0]; - //filterValue = filterPanId; - filterValue = (uint8_t*)&macPanId; + //rxSeqNum = data[0]; + filterValue = filterPanId; if (rxDstAddrLength) { filterWord = dstPanFilter; } else { @@ -145,10 +146,9 @@ // Broadcast pan is also accepted. if (rxDstAddrLength == 2) { //filterValue = filterShortAddr; - filterValue = (uint8_t*)&macShortAddress; + filterValue = filterShortAddr; } else { - //filterValue = filterExtAddr; - filterValue = aExtendedAddress; + filterValue = filterExtAddr; } filterWord = dstAddrFilter; return TRUE; @@ -192,8 +192,16 @@ // Read PANId for short address. uint8_t *myPan = data-1; if ((myPan[0] == filterValue[0] && myPan[1] == filterValue[1])) { - filterWord = dummyFilter; - return TRUE; + if (rxFrameControl->FrameType == 1 || rxFrameControl->FrameType == 3) { + if (filterIsPanCoord) { + // Only accept data or mac command frame if we are pan coordinator. + filterWord = dummyFilter; + return TRUE; + } + } else { + filterWord = dummyFilter; + return TRUE; + } } filterReason = "Invalid source PAN Id!"; return FALSE; Modified: trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyDriverM.nc =================================================================== --- trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyDriverM.nc 2009-03-25 11:46:55 UTC (rev 1064) +++ trunk/diku/tiny15four/tos/chips/mc13192/mc13192PhyDriverM.nc 2009-03-25 19:09:14 UTC (rev 1065) @@ -73,7 +73,6 @@ // Phy attribute variables. norace uint8_t curChannel = 11; - norace bool (*myFilter)(uint8_t*) = NULL; // CCA globals norace bool edOperation = FALSE; @@ -122,6 +121,11 @@ norace uint8_t ackWaitTime = 66; norace uint8_t ackFrame[2] = {0x02, 0x00}; norace bool acking = FALSE; + inline void waitForAck(); + inline void checkAck(); + inline void ackFailed(); + inline void transmitAck(); + inline void transmitAckDone(); // Transmit and receive functions void enableReceiver(bool immediateCommence); @@ -132,7 +136,6 @@ inline void abortReceive(); inline void restartReceive(); inline void changeState(uint16_t state); - //inline void writeRegister(uint8_t addr, uint16_t content); inline void finishStreamOperation(); inline void finishRx(); inline bool readRXPacketLength(); @@ -146,8 +149,10 @@ command error_t Init.init() { // Synchronize radio and MCU time. + call MCUTime.reset(); call Timer.resetEventTime(); - call MCUTime.reset(); + + return SUCCESS; } @@ -207,18 +212,6 @@ return SUCCESS; } - command error_t PhyAttributes.setFilter(bool (*filter)(uint8_t*)) - { - myFilter = filter; - return SUCCESS; - } - - command error_t PhyAttributes.clearFilter() - { - myFilter = NULL; - return SUCCESS; - } - /* command uint8_t PhyAttributes.getChannel() { return curChannel; @@ -275,7 +268,7 @@ async command phy_error_t PhyReceive.rxOn(uint32_t commenceTime, bool immediateCommence) { if (immediateCommence) { - receiverOn = TRUE; + //receiverOn = TRUE; if (opMode == NO_OPERATION) enableReceiver(TRUE); return PHY_SUCCESS; } else { @@ -315,15 +308,21 @@ async command phy_error_t PhyTransmit.tx(txdata_t *data) { + //uint32_t radio,mcu; bool ack = (data->frame[0] & 0x20); + bool opStatus = FALSE; + if (data->immediateCommence) { // Just start operation as fast as possible. if (data->cca) { - if (!sendCca(data,ack)) { + // Disable interrupts while doing time critical stuff.. + atomic opStatus = sendCca(data,ack); + if (!opStatus) { return PHY_CCA_FAIL; } } else { - sendNoCca(data,ack); + // Disable interrupts while doing time critical stuff.. + atomic sendNoCca(data,ack); } return PHY_SUCCESS; } else { @@ -340,6 +339,10 @@ defer1Ack = ack; defer1Data = data; call Timer.startDeferTimer1(data->commenceTime-12); + /*radio = call Timer.getEventTime(); + mcu = call MCUTime.getTime(); + DBG_STRINT("Radio time: ",radio,1); + DBG_STRINT("MCU time: ",mcu,1);*/ return PHY_SUCCESS; } atomic { @@ -376,7 +379,10 @@ call Interrupt.enableStreamMode(); dataTransferMode = STREAM_MODE; } - atomic opMode = RX_OPERATION; + atomic { + opMode = RX_OPERATION; + receiverOn = TRUE; + } nextByte = rxPacket.frame; filterWord = defaultFilter; } @@ -384,6 +390,7 @@ bool sendCca(txdata_t *data, bool ack) { if (isReceiving) return FALSE; + if (!data->immediateCommence) { changeState(ccaMode | EVENT_TIMED); call Timer.startEventTimer(data->commenceTime, PACKET_MODE); @@ -406,6 +413,7 @@ seqNum = data->frame[2]; atomic opMode = TX_OPERATION; txId = data->txId; + return TRUE; } @@ -468,6 +476,7 @@ // TX uses 167 bus cycles to complete = 21 micro seconds inline async event bool Interrupt.fastAction() { + uint8_t i = 20; // TIME CRITICAL SECTION // NO DBG IN HERE if (opMode == RX_OPERATION) { @@ -475,12 +484,13 @@ TOSH_CLR_RADIO_CE_PIN(); call SPI.fastWriteByte(RX_PKT_RAM|0x80); call SPI.fastReadWordSwapped(nextByte); - call SPI.fastReadWordSwapped(nextByte); + //call SPI.fastReadWordSwapped(nextByte); TOSH_SET_RADIO_CE_PIN(); + while(i--); nextByte += 2; // Filter the received word. - if (!filterWord(nextByte-2)) { + if (!phyPromiscuousMode && !filterWord(nextByte-2)) { // Discard packet. restartReceive(); DBG_STR("Discarded by filter!",4); @@ -490,11 +500,9 @@ } } else { // Transmit mode. Supply next word. - //ASSERT_CE; // Enable SPI TOSH_CLR_RADIO_CE_PIN(); call SPI.fastWriteByte(TX_PKT_RAM); call SPI.fastWriteWordSwapped(nextByte); - //DEASSERT_CE; TOSH_SET_RADIO_CE_PIN(); nextByte += 2; } @@ -508,13 +516,15 @@ async event void Interrupt.ackTimerFired() { + bool wasAckedOperation; call Timer.stopAckTimer(); - if (ackedOperation) { + atomic { + wasAckedOperation = ackedOperation; ackedOperation = FALSE; - abortReceive(); - if (receiverOn) enableReceiver(TRUE); - signal PhyTransmit.txDone(PHY_ACK_FAIL, txId); } + if (wasAckedOperation) { + ackFailed(); + } } async event void Interrupt.eventTimerFired() @@ -524,15 +534,20 @@ async event void Interrupt.deferTimer1Fired() { + bool opStatus = FALSE; + // Activate deferred operation. if (defer1OpType == DEFER_TX) { if (defer1Data->cca) { - if (!sendCca(defer1Data,defer1Ack)) { + // Disable interrupts while executing time critical operations + atomic opStatus = sendCca(defer1Data,defer1Ack); + if (!opStatus) { opMode = NO_OPERATION; signal PhyTransmit.txDone(PHY_CCA_FAIL, defer1Data->txId); } } else { - sendNoCca(defer1Data,defer1Ack); + // Disable interrupts while executing time critical operations + atomic sendNoCca(defer1Data,defer1Ack); } } else if (defer1OpType == DEFER_RX) { rxCommenceTime = defer1RxTime; @@ -544,15 +559,20 @@ async event void Interrupt.deferTimer2Fired() { + bool opStatus = FALSE; + // Activate deferred operation. if (defer2OpType == DEFER_TX) { if (defer2Data->cca) { - if (!sendCca(defer2Data,defer2Ack)) { + // Disable interrupts while executing time critical operations + atomic opStatus = sendCca(defer2Data, defer2Ack); + if (!opStatus) { opMode = NO_OPERATION; signal PhyTransmit.txDone(PHY_CCA_FAIL, defer2Data->txId); } } else { - sendNoCca(defer2Data,defer2Ack); + // Disable interrupts while executing time critical operations + atomic sendNoCca(defer2Data,defer2Ack); } DBG_STR("Starting deferred tx from slot 2",4); } else if (defer2OpType == DEFER_RX) { @@ -567,25 +587,9 @@ async event void Interrupt.txDone() { if (ackedOperation) { -/* uint32_t timeout; - changeState(RX_MODE); - timeout = call Timer.getEventTime() + ackWaitTime; - call Timer.startAckTimer(timeout);*/ - uint32_t timeout; - filterWord = ackFilter; - opMode = RX_OPERATION; - - // Enable stream mode. - writeRegister(CONTROL_B, STREAM_MODE_ON); - call Interrupt.enableStreamMode(); - dataTransferMode = STREAM_MODE; - - changeState(RX_STRM_MODE); - // clear interrupt flag to allow rx to finish up. - __nesc_enable_interrupt(); - nextByte = rxPacket.frame; - timeout = call Timer.getEventTime() + ackWaitTime; - call Timer.startAckTimer(timeout); + // Wait for the radio to go into idle mode. + while(TOSH_READ_RADIO_OOI_PIN()); + waitForAck(); } else { // We're done! opMode = NO_OPERATION; @@ -602,8 +606,14 @@ // TIME CRITICAL SECTION // NO DBG IN HERE (This time I mean it!!) if (opMode == RX_OPERATION) { - // Read packet length. + /*if (ackedOperation) { + // Assume that we are receiving an ack. + lastByte = nextByte + 3; + isReceiving = TRUE; + return TRUE; + } else*/ if (readRXPacketLength()) { + // Read packet length. isReceiving = TRUE; return TRUE; } @@ -768,91 +778,48 @@ inline void finishStreamOperation() { + // We need to wait for the radio to go back into idle mode, + // before we can be sure that the stream operation has completed. + while(TOSH_READ_RADIO_OOI_PIN()); + // We're done. if (opMode == RX_OPERATION) { - // We need to wait for the radio to go out of idle - // before we can read the correct CRC result. - while(TOSH_READ_RADIO_OOI_PIN()); if (!TOSH_READ_RADIO_CRC_PIN()) { restartReceive(); return; } - // If we are waiting for an ack. + // If we are awaiting an ACK. if (ackedOperation) { - isReceiving = FALSE; - if (rxPacket.frame[2] == seqNum) { - ackedOperation = FALSE; - call Timer.stopAckTimer(); - DBG_STR("Got ack and finishing up operation!",4); - opMode = NO_OPERATION; - if (receiverOn) enableReceiver(TRUE); - signal PhyTransmit.txDone(PHY_SUCCESS, txId); - return; - } + checkAck(); return; } + // Check if we need to ack the received packet. - if (rxFrameControl->AckRequest) { - // The ack should commence 12 symbol periods after the time of arrival - // of the frame. - uint16_t commenceTime = ((uint16_t)rxPacket.recvTime) + rxDuration + 12; - if (backoffAligned) { - // We backoff align the ack, by assuming that the transmission commenced - // on a backoff boundary. We figure out, how much to add to the commence - // time, so that the commence time of the ack is a multiple of 20 bigger - // than the frame recv time. - commenceTime += 19 - ((rxDuration + 11)%20); - } - // Program event timer. - writeRegister(TC2_PRIME, commenceTime); - writeRegister(TMR_CMP2_A, 0x0000); - changeState(TX_STRM_MODE|EVENT_TIMED); - - // We ack the packet. - writeTXPacketLength(3); - // Write the two first ack bytes to packet ram. - writeTXPacket(ackFrame, 2); - - nextByte = lastByte = &rxSeqNum; - acking = TRUE; - call Interrupt.disableFastAction(); - opMode = TX_OPERATION; - // clear interrupt flag to allow tx to finish up. - ENABLE_IRQ; - __nesc_enable_interrupt(); - } else { - isReceiving = FALSE; - finishRx(); + if (!phyPromiscuousMode && (rxPacket.frame[0] & 0x20)) { + transmitAck(); + return; } + + // The frame requires no further processing. + isReceiving = FALSE; + finishRx(); } else { + // Check if we need to wait for an ACK. if (ackedOperation) { - uint32_t timeout; - filterWord = ackFilter; - while(TOSH_READ_RADIO_OOI_PIN()); - call Interrupt.disableFastAction(); - opMode = RX_OPERATION; - changeState(RX_STRM_MODE); - // clear interrupt flag to allow rx to finish up. - __nesc_enable_interrupt(); - nextByte = rxPacket.frame; - //getReceiveBuffer(); - timeout = call Timer.getEventTime() + ackWaitTime; - call Timer.startAckTimer(timeout); + waitForAck(); return; } + // Check if we are done transmitting an ACK. if (acking) { - // If we were transmitting an ack, just return. - while(TOSH_READ_RADIO... [truncated message content] |
From: <mle...@us...> - 2009-03-25 11:47:04
|
Revision: 1064 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1064&view=rev Author: mleopold Date: 2009-03-25 11:46:55 +0000 (Wed, 25 Mar 2009) Log Message: ----------- Use new McuSleepC for all platforms Added Paths: ----------- trunk/diku/mcs51/tos/chips/mcs51/McuSleepC.nc Removed Paths: ------------- trunk/diku/mcs51/tos/chips/cc2430/McuSleepC.nc trunk/diku/mcs51/tos/chips/cip51/McuSleepC.nc trunk/diku/mcs51/tos/chips/mcs51/McuSleepC.nc Deleted: trunk/diku/mcs51/tos/chips/cc2430/McuSleepC.nc =================================================================== --- trunk/diku/mcs51/tos/chips/cc2430/McuSleepC.nc 2009-03-25 11:38:06 UTC (rev 1063) +++ trunk/diku/mcs51/tos/chips/cc2430/McuSleepC.nc 2009-03-25 11:46:55 UTC (rev 1064) @@ -1,67 +0,0 @@ - -/* - * Copyright (c) 2007 University of Copenhagen - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of University of Copenhagen nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY - * OF COPENHAGEN OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * - * Dummy sleep mode for 8051 - * - * @author Martin Leopold <le...@di...> - */ - -#include "mcs51hardware.h" -#include <CC2430Timer.h> - -module McuSleepC { - provides { - interface McuSleep; - interface McuPowerState; - } -} -implementation { - - async command void McuSleep.sleep() { - // Allow interrupts to squize in... (See TEP112) - __nesc_enable_interrupt(); - - // Enable and disable right after each other does not work for cc2430 - //{ int i; for(i=0 ; i<1 ; i++) { i; } } - - // This gives us enough of a break.. - // (And should be changed to a real low power mode any time now =) - SLEEP = (SLEEP & ~CC2430_SLEEP_MODE_MASK) | CC2430_SLEEP_POWERMODE_0; - - __nesc_disable_interrupt(); - } - - async command void McuPowerState.update() { - } -} Deleted: trunk/diku/mcs51/tos/chips/cip51/McuSleepC.nc =================================================================== --- trunk/diku/mcs51/tos/chips/cip51/McuSleepC.nc 2009-03-25 11:38:06 UTC (rev 1063) +++ trunk/diku/mcs51/tos/chips/cip51/McuSleepC.nc 2009-03-25 11:46:55 UTC (rev 1064) @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2008 Polaric - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of Polaric nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL POLARIC OR ITS CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * - * Idle sleep mode for all 8051 variants. - * - * All 8051 clones should feature the "IDLE" mode as a bare minium, by - * setting PCON.0. This mode should leave all peripherals and clocks - * running and resume operation on any interrupt. The idle mode does - * not in it self provide power savings, lowering clock and disabling - * peripherals should be done separately. The original 8051 also - * featured a "stop" mode and a set of geneal purpose flags in the - * PCON register - however these are not supported by all the 8051 - * variants found in this port (e.g. cc2430). - * - * Some chips feature more advanced automatic power saving - * modes. Taking advantage of such features can be done by providing a - * override McuSleepC. - * - * @author Martin Leopold <le...@di...> - */ - -#include "mcs51hardware.h" - -module McuSleepC { - provides { - interface McuSleep; - interface McuPowerState; - } -} -implementation { - - async command void McuSleep.sleep() { - // Allow interrupts to squize in... (See TEP112) - __nesc_enable_interrupt(); - PCON = _BV(MCS51_PCON_IDLE); - __nesc_disable_interrupt(); - } - - async command void McuPowerState.update() { - } -} Deleted: trunk/diku/mcs51/tos/chips/mcs51/McuSleepC.nc =================================================================== --- trunk/diku/mcs51/tos/chips/mcs51/McuSleepC.nc 2009-03-25 11:38:06 UTC (rev 1063) +++ trunk/diku/mcs51/tos/chips/mcs51/McuSleepC.nc 2009-03-25 11:46:55 UTC (rev 1064) @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2007 University of Copenhagen - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the - * distribution. - * - Neither the name of University of Copenhagen nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY - * OF COPENHAGEN OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * - * Dummy sleep mode for 8051 - * - * @author Martin Leopold <le...@di...> - */ - -#include "mcs51hardware.h" - -module McuSleepC { - provides { - interface McuSleep; - interface McuPowerState; - } -} -implementation { - - async command void McuSleep.sleep() { - // Allow interrupts to squize in... (See TEP112) - __nesc_enable_interrupt(); - __nesc_disable_interrupt(); - } - - async command void McuPowerState.update() { - } -} Copied: trunk/diku/mcs51/tos/chips/mcs51/McuSleepC.nc (from rev 1062, trunk/diku/mcs51/tos/chips/cip51/McuSleepC.nc) =================================================================== --- trunk/diku/mcs51/tos/chips/mcs51/McuSleepC.nc (rev 0) +++ trunk/diku/mcs51/tos/chips/mcs51/McuSleepC.nc 2009-03-25 11:46:55 UTC (rev 1064) @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2008 Polaric + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the + * distribution. + * - Neither the name of Polaric nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL POLARIC OR ITS CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * + * Idle sleep mode for all 8051 variants. + * + * All 8051 clones should feature the "IDLE" mode as a bare minium, by + * setting PCON.0. This mode should leave all peripherals and clocks + * running and resume operation on any interrupt. The idle mode does + * not in it self provide power savings, lowering clock and disabling + * peripherals should be done separately. The original 8051 also + * featured a "stop" mode and a set of geneal purpose flags in the + * PCON register - however these are not supported by all the 8051 + * variants found in this port (e.g. cc2430). + * + * Some chips feature more advanced automatic power saving + * modes. Taking advantage of such features can be done by providing a + * override McuSleepC. + * + * @author Martin Leopold <le...@di...> + */ + +#include "mcs51hardware.h" + +module McuSleepC { + provides { + interface McuSleep; + interface McuPowerState; + } +} +implementation { + + async command void McuSleep.sleep() { + // Allow interrupts to squize in... (See TEP112) + __nesc_enable_interrupt(); + PCON = _BV(MCS51_PCON_IDLE); + __nesc_disable_interrupt(); + } + + async command void McuPowerState.update() { + } +} Property changes on: trunk/diku/mcs51/tos/chips/mcs51/McuSleepC.nc ___________________________________________________________________ Added: svn:executable + * Added: svn:mergeinfo + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mle...@us...> - 2009-03-25 11:38:14
|
Revision: 1063 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1063&view=rev Author: mleopold Date: 2009-03-25 11:38:06 +0000 (Wed, 25 Mar 2009) Log Message: ----------- Use new McuSleepC for all platforms Modified Paths: -------------- trunk/diku/mcs51/doc/ChangeLog Modified: trunk/diku/mcs51/doc/ChangeLog =================================================================== --- trunk/diku/mcs51/doc/ChangeLog 2009-03-25 11:34:31 UTC (rev 1062) +++ trunk/diku/mcs51/doc/ChangeLog 2009-03-25 11:38:06 UTC (rev 1063) @@ -13,7 +13,8 @@ * USBSerialEcho warns that it only works on platforms with USB * c8051F340TB uninitialized variable in PlatformP * Added mcs51_env_check.sh to check env variables - + * New McuSleepC using the 8051 "idle" mode + 0.1 pre4 * .platform updated to include all library directories * PlatformLedsC replaces HalPlatformLedsC This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mle...@us...> - 2009-03-25 11:34:34
|
Revision: 1062 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1062&view=rev Author: mleopold Date: 2009-03-25 11:34:31 +0000 (Wed, 25 Mar 2009) Log Message: ----------- Updated cip-51 to use use IDLE mode in McuSpeepC Modified Paths: -------------- trunk/diku/mcs51/tos/chips/cip51/McuSleepC.nc trunk/diku/mcs51/tos/chips/mcs51/io8051.h Modified: trunk/diku/mcs51/tos/chips/cip51/McuSleepC.nc =================================================================== --- trunk/diku/mcs51/tos/chips/cip51/McuSleepC.nc 2009-03-17 08:32:47 UTC (rev 1061) +++ trunk/diku/mcs51/tos/chips/cip51/McuSleepC.nc 2009-03-25 11:34:31 UTC (rev 1062) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 University of Copenhagen + * Copyright (c) 2008 Polaric * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -11,33 +11,46 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. - * - Neither the name of University of Copenhagen nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. + * - Neither the name of Polaric nor the names of its contributors may + * be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY - * OF COPENHAGEN OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL POLARIC OR ITS CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * - * Dummy sleep mode for 8051 + * Idle sleep mode for all 8051 variants. * + * All 8051 clones should feature the "IDLE" mode as a bare minium, by + * setting PCON.0. This mode should leave all peripherals and clocks + * running and resume operation on any interrupt. The idle mode does + * not in it self provide power savings, lowering clock and disabling + * peripherals should be done separately. The original 8051 also + * featured a "stop" mode and a set of geneal purpose flags in the + * PCON register - however these are not supported by all the 8051 + * variants found in this port (e.g. cc2430). + * + * Some chips feature more advanced automatic power saving + * modes. Taking advantage of such features can be done by providing a + * override McuSleepC. + * * @author Martin Leopold <le...@di...> */ #include "mcs51hardware.h" -#include "iocip51.h" module McuSleepC { provides { @@ -50,13 +63,7 @@ async command void McuSleep.sleep() { // Allow interrupts to squize in... (See TEP112) __nesc_enable_interrupt(); - {uint8_t q=0; - while(q<10) { - q++; - } - //__nesc_enable_interrupt(); - //SBUF='A'; - } + PCON = _BV(MCS51_PCON_IDLE); __nesc_disable_interrupt(); } Modified: trunk/diku/mcs51/tos/chips/mcs51/io8051.h =================================================================== --- trunk/diku/mcs51/tos/chips/mcs51/io8051.h 2009-03-17 08:32:47 UTC (rev 1061) +++ trunk/diku/mcs51/tos/chips/mcs51/io8051.h 2009-03-25 11:34:31 UTC (rev 1062) @@ -69,6 +69,15 @@ #include <byteorder.h> + /* + * Bit locations for PCON + */ + +enum { + MCS51_PCON_STOP = 1, + MCS51_PCON_IDLE = 0 +}; + uint8_t volatile P0 __attribute((sfrAT0x80)); uint8_t volatile SP __attribute((sfrAT0x81)); uint8_t volatile DPL __attribute((sfrAT0x82)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mle...@us...> - 2009-03-17 08:33:01
|
Revision: 1061 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1061&view=rev Author: mleopold Date: 2009-03-17 08:32:47 +0000 (Tue, 17 Mar 2009) Log Message: ----------- Simplify check slightly Modified Paths: -------------- trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh Modified: trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh 2009-03-17 08:17:26 UTC (rev 1060) +++ trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh 2009-03-17 08:32:47 UTC (rev 1061) @@ -17,9 +17,7 @@ do if [ -z "${!var}" ]; then RETURN=1 - if [ ! "$VERBOSE" -eq 0 ]; then - echo "$var not set" - fi + echo "$var not set" else if [ ! "$VERBOSE" -eq 0 ]; then echo "$var=${!var}" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mle...@us...> - 2009-03-17 08:17:29
|
Revision: 1060 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1060&view=rev Author: mleopold Date: 2009-03-17 08:17:26 +0000 (Tue, 17 Mar 2009) Log Message: ----------- Simplify check slightly Modified Paths: -------------- trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh Modified: trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh 2009-03-16 16:58:13 UTC (rev 1059) +++ trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh 2009-03-17 08:17:26 UTC (rev 1060) @@ -28,64 +28,56 @@ done MC=`echo $MCS51_COMPILER | tr "[:upper:]" "[:lower:]"` +CP='' if [ "$MC"=="keil" ]; then - KP='' - if [ -z $ISCYGWIN ]; then if [ -z "$MCS51_WINE_KEIL_PATH" ]; then echo "MCS51_WINE_KEIL_PATH not set (using $MCS51_WINE_KEIL_PATH_DEFAULT)" - KP=$MCS51_WINE_KEIL_PATH_DEFAULT + CP=$MCS51_WINE_KEIL_PATH_DEFAULT else if [ ! "$VERBOSE" -eq 0 ]; then echo "MCS51_WINE_KEIL_PATH=$MCS51_WINE_KEIL_PATH" fi - KP=$MCS51_WINE_KEIL_PATH + CP=$MCS51_WINE_KEIL_PATH fi - KP=$KP/dosdevices/c:/Keil + CP=$CP/dosdevices/c:/Keil else - KP="c:/Keil" + CP="c:/Keil" fi - if [ ! -e "$KP" ]; then - echo "Keil not found ($KP/dosdevices/c:/Keil)." - RETURN=1 - else - if [ ! "$VERBOSE" -eq 0 ]; then - echo "Keil found ($KP/dosdevices/c:/Keil)." - fi - fi fi if [ "$MC" = "iar" ]; then - IP='' if [ -z $ISCYGWIN ]; then if [ ! -z "$MCS51_WINE_IAR_PATH" ]; then if [ ! "$VERBOSE" -eq 0 ]; then echo "MCS51_WINE_IAR_PATH=$MCS51_WINE_IAR_PATH" fi - IP=$MCS51_WINE_IAR_PATH + CP=$MCS51_WINE_IAR_PATH else echo "MCS51_WINE_IAR_PATH not set (using $MCS51_WINE_IAR_PATH_DEFAULT)" - IP=$MCS51_WINE_IAR_PATH_DEFAULT + CP=$MCS51_WINE_IAR_PATH_DEFAULT fi - IP=$IP/dosdevices/c:/$MCS51_IAR_PATH + CP=$CP/dosdevices/c:/$MCS51_IAR_PATH else - IP=c:/$MCS51_IAR_PATH + CP=c:/$MCS51_IAR_PATH fi - if [ ! -e "$IP" ]; then - echo "IAR not found ($IP/dosdevices/c:/$MCS51_IAR_PATH)." - RETURN=1 - else - if [ ! "$VERBOSE" -eq 0 ]; then - echo "IAR found ($KP/dosdevices/c:/$MCS51_IAR_PATH)." - fi - fi fi #if [ "$MC" = "sdcc" ]; then #fi +if [ ! -e "$CP" ]; then + echo "Compiler not found not found ($CP)." + RETURN=1 +else + if [ ! "$VERBOSE" -eq 0 ]; then + echo "Keil found ($CP)." + fi +fi + + if [ ! "$VERBOSE" -eq 0 ]; then if [ ! "$RETURN" -eq "0" ]; then echo "Environment check FAILED" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mle...@us...> - 2009-03-16 16:58:14
|
Revision: 1059 http://tinyos8051wg.svn.sourceforge.net/tinyos8051wg/?rev=1059&view=rev Author: mleopold Date: 2009-03-16 16:58:13 +0000 (Mon, 16 Mar 2009) Log Message: ----------- Env check should now work even in a Cygwin environment Modified Paths: -------------- trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh Modified: trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh =================================================================== --- trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh 2009-03-16 16:48:12 UTC (rev 1058) +++ trunk/diku/mcs51/support/make/mcs51/mcs51_env_check.sh 2009-03-16 16:58:13 UTC (rev 1059) @@ -4,6 +4,8 @@ MCS51_WINE_IAR_PATH_DEFAULT=~/.wine.iar RETURN=0 +ISCYGWIN=`uname | grep -i cygwin ` + VERBOSE=0 if [ ! -z $1 ]; then if [ $1 = "-v" ]; then @@ -25,19 +27,25 @@ fi done -#MC=`echo $MCS51_COMPILER | tr "[:upper:]" "[:lower:]"` -if [ "$MC" = "keil" ]; then +MC=`echo $MCS51_COMPILER | tr "[:upper:]" "[:lower:]"` +if [ "$MC"=="keil" ]; then KP='' - if [ -z "$MCS51_WINE_KEIL_PATH" ]; then - echo "MCS51_WINE_KEIL_PATH not set (using $MCS51_WINE_KEIL_PATH_DEFAULT)" - KP=$MCS51_WINE_KEIL_PATH_DEFAULT + + if [ -z $ISCYGWIN ]; then + if [ -z "$MCS51_WINE_KEIL_PATH" ]; then + echo "MCS51_WINE_KEIL_PATH not set (using $MCS51_WINE_KEIL_PATH_DEFAULT)" + KP=$MCS51_WINE_KEIL_PATH_DEFAULT + else + if [ ! "$VERBOSE" -eq 0 ]; then + echo "MCS51_WINE_KEIL_PATH=$MCS51_WINE_KEIL_PATH" + fi + KP=$MCS51_WINE_KEIL_PATH + fi + KP=$KP/dosdevices/c:/Keil else - if [ ! "$VERBOSE" -eq 0 ]; then - echo "MCS51_WINE_KEIL_PATH=$MCS51_WINE_KEIL_PATH" - fi - KP=$MCS51_WINE_KEIL_PATH + KP="c:/Keil" fi - if [ ! -e "$KP/dosdevices/c:/Keil" ]; then + if [ ! -e "$KP" ]; then echo "Keil not found ($KP/dosdevices/c:/Keil)." RETURN=1 else @@ -45,22 +53,26 @@ echo "Keil found ($KP/dosdevices/c:/Keil)." fi fi - fi if [ "$MC" = "iar" ]; then IP='' - if [ ! -z "$MCS51_WINE_IAR_PATH" ]; then - if [ ! "$VERBOSE" -eq 0 ]; then - echo "MCS51_WINE_IAR_PATH=$MCS51_WINE_IAR_PATH" + if [ -z $ISCYGWIN ]; then + if [ ! -z "$MCS51_WINE_IAR_PATH" ]; then + if [ ! "$VERBOSE" -eq 0 ]; then + echo "MCS51_WINE_IAR_PATH=$MCS51_WINE_IAR_PATH" + fi + IP=$MCS51_WINE_IAR_PATH + else + echo "MCS51_WINE_IAR_PATH not set (using $MCS51_WINE_IAR_PATH_DEFAULT)" + IP=$MCS51_WINE_IAR_PATH_DEFAULT fi - IP=$MCS51_WINE_IAR_PATH + IP=$IP/dosdevices/c:/$MCS51_IAR_PATH else - echo "MCS51_WINE_IAR_PATH not set (using $MCS51_WINE_IAR_PATH_DEFAULT)" - IP=$MCS51_WINE_IAR_PATH_DEFAULT + IP=c:/$MCS51_IAR_PATH fi - if [ ! -e "$IP/dosdevices/c:/$MCS51_IAR_PATH" ]; then - echo "Keil not found ($IP/dosdevices/c:/$MCS51_IAR_PATH)." + if [ ! -e "$IP" ]; then + echo "IAR not found ($IP/dosdevices/c:/$MCS51_IAR_PATH)." RETURN=1 else if [ ! "$VERBOSE" -eq 0 ]; then This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |