From: R. Steve McKown Date: Thu, 4 Oct 2012 15:27:12 +0000 (-0600) Subject: tmimsp platform family better uart abstraction X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=06526c9bb19fa589e7a14c10d6f24629431cbaa4 tmimsp platform family better uart abstraction --- diff --git a/tos/lib/misc/StdToResourceC.nc b/tos/lib/misc/StdToResourceC.nc new file mode 100644 index 00000000..c6dd9adc --- /dev/null +++ b/tos/lib/misc/StdToResourceC.nc @@ -0,0 +1,58 @@ +/** + * Copyright © 2012, Titanium Mirror, Inc. + * 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 Titanium Mirror, Inc 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. + */ + +/** + * Implement resource acquisition via the StdControl interface. Created to + * implement PlatformSerialC's StdControl interface using USCI Uart's Resource + * interface. + * + * Avoid using with resources that cannot reliably respond with SUCCESS to + * Resource.immediateRequest(). In such cases, it's far smarter to just use the + * Resource interface directly. + * + * @author R. Steve McKown + */ + +generic module StdToResourceC() { + provides interface StdControl; + uses interface Resource; +} +implementation { + command error_t StdControl.start() + { + return call Resource.immediateRequest(); + } + + command error_t StdControl.stop() + { + return call Resource.release(); + } + + event void Resource.granted() {} +} diff --git a/tos/platforms/tmimsp/.family b/tos/platforms/tmimsp/.family index bda9749f..a068ee3f 100644 --- a/tos/platforms/tmimsp/.family +++ b/tos/platforms/tmimsp/.family @@ -9,6 +9,7 @@ push( @includes, qw( %F/common %F/common/chips/bq2403x %F/common/chips/cp210x + %F/common/uart %T/platforms/telosa %T/chips/msp430 %T/chips/msp430/adc12 @@ -23,6 +24,7 @@ push( @includes, qw( %T/lib/serial %T/lib/adc %T/lib/power + %T/lib/misc ) ); @opts = qw( diff --git a/tos/platforms/tmimsp/common/PlatformSerialC.nc b/tos/platforms/tmimsp/common/PlatformSerialC.nc deleted file mode 100644 index a32ffa04..00000000 --- a/tos/platforms/tmimsp/common/PlatformSerialC.nc +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2008-2010, Titanium Mirror, Inc. - * 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 Technische Universität Berlin 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 R. Steve McKown - */ - -configuration PlatformSerialC { - provides interface StdControl; - provides interface UartStream; - provides interface UartByte; -} -implementation { - components PlatformUartC as UartC; - UartStream = UartC; - UartByte = UartC; - - components PlatformSerialP; - StdControl = PlatformSerialP; - PlatformSerialP.Resource -> UartC; -} diff --git a/tos/platforms/tmimsp/common/PlatformUartC.nc b/tos/platforms/tmimsp/common/PlatformUartC.nc deleted file mode 100644 index 10a7cec4..00000000 --- a/tos/platforms/tmimsp/common/PlatformUartC.nc +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2008-2010, Titanium Mirror, Inc. - * 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 Technische Universität Berlin 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 R. Steve McKown - */ - -configuration PlatformUartC { - provides { - interface Resource; - interface UartStream; - interface UartByte; - } -} -implementation { - components new Msp430UartA1C() as UartC; - Resource = UartC; - UartStream = UartC; - UartByte = UartC; - -#if 0 /* If you want to change the Uart's configuration... */ - components SomeConfigurationComponentC as ConfigC; - UartC.AsyncConfigure -> ConfigC; -#endif -} diff --git a/tos/platforms/tmimsp/common/uart/ConsoleUart.h b/tos/platforms/tmimsp/common/uart/ConsoleUart.h new file mode 100644 index 00000000..06fb96a4 --- /dev/null +++ b/tos/platforms/tmimsp/common/uart/ConsoleUart.h @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2008-2010, Titanium Mirror, Inc. + * 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 Technische Universität Berlin 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 R. Steve McKown + */ + +#ifndef CONSOLE_UART_H +#define CONSOLE_UART_H + +#define CONSOLE_UART_RESOURCE "Console.Shared.Uart" + +#endif diff --git a/tos/platforms/tmimsp/common/uart/ConsoleUartC.nc b/tos/platforms/tmimsp/common/uart/ConsoleUartC.nc new file mode 100644 index 00000000..5dbb1452 --- /dev/null +++ b/tos/platforms/tmimsp/common/uart/ConsoleUartC.nc @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2008-2010, Titanium Mirror, Inc. + * 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 Technische Universität Berlin 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 R. Steve McKown + */ + +#include "ConsoleUart.h" + +generic configuration ConsoleUartC() { + provides { + interface Resource; + interface UartStream; + interface UartByte; + } +} +implementation { + enum { CLIENT = unique(CONSOLE_UART_RESOURCE) }; + + components ConsoleUartP; + Resource = ConsoleUartP.Resource[CLIENT]; + UartStream = ConsoleUartP.UartStream; + UartByte = ConsoleUartP.UartByte; +} diff --git a/tos/platforms/tmimsp/common/uart/ConsoleUartConfigC.nc b/tos/platforms/tmimsp/common/uart/ConsoleUartConfigC.nc new file mode 100644 index 00000000..9b362233 --- /dev/null +++ b/tos/platforms/tmimsp/common/uart/ConsoleUartConfigC.nc @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2008-2010, Titanium Mirror, Inc. + * 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 Technische Universität Berlin 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. + */ + +module ConsoleUartConfigC { + provides interface AsyncConfigure; +} +implementation { + const static msp430_usci_uart_t config = { + ctl0: UCMODE_0, /* async, lsb first, 8N1 */ + ctl1: UCSWRST | UCSSEL_3, /* clock uart from SMCLK */ + brx: UBRX_1MHZ_115200, + mctl: UMCTL_1MHZ_115200, + irtctl: 0, + irrctl: 0, + abctl: 0, + uclisten: FALSE, + ren: USCI_REN_NONE + }; + + async command const msp430_usci_uart_t* AsyncConfigure.get() + { + return &config; + } +} diff --git a/tos/platforms/tmimsp/common/uart/ConsoleUartImplP.nc b/tos/platforms/tmimsp/common/uart/ConsoleUartImplP.nc new file mode 100644 index 00000000..9e53e2a6 --- /dev/null +++ b/tos/platforms/tmimsp/common/uart/ConsoleUartImplP.nc @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2008-2010, Titanium Mirror, Inc. + * 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 Technische Universität Berlin 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 R. Steve McKown + */ + +#include "ConsoleUart.h" + +module ConsoleUartImplP { + uses { + interface ResourceDefaultOwner; + interface Resource as SubResource; + } +} +implementation { + async event void ResourceDefaultOwner.granted() + { + call SubResource.release(); + } + + async event void ResourceDefaultOwner.requested() + { + call SubResource.request(); + } + + async event void ResourceDefaultOwner.immediateRequested() + { + if (call SubResource.immediateRequest() == SUCCESS) + call ResourceDefaultOwner.release(); + } + + event void SubResource.granted() + { + call ResourceDefaultOwner.release(); + } +} diff --git a/tos/platforms/tmimsp/common/uart/ConsoleUartP.nc b/tos/platforms/tmimsp/common/uart/ConsoleUartP.nc new file mode 100644 index 00000000..301040df --- /dev/null +++ b/tos/platforms/tmimsp/common/uart/ConsoleUartP.nc @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2008-2010, Titanium Mirror, Inc. + * 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 Technische Universität Berlin 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 R. Steve McKown + */ + +#include "ConsoleUart.h" + +configuration ConsoleUartP { + provides { + interface Resource[uint8_t id]; + interface UartStream; + interface UartByte; + } +} +implementation { + components new SharedArbiterC(CONSOLE_UART_RESOURCE); + Resource = SharedArbiterC; + + components ConsoleUartImplP; + ConsoleUartImplP.ResourceDefaultOwner -> SharedArbiterC; + + components new Msp430UartA1C() as UartC; + UartStream = UartC; + UartByte = UartC; + ConsoleUartImplP.SubResource -> UartC; + + components ConsoleUartConfigC as ConfigC; + UartC.Configure -> ConfigC; +} diff --git a/tos/platforms/tmimsp/common/uart/DebugUartC.nc b/tos/platforms/tmimsp/common/uart/DebugUartC.nc new file mode 100644 index 00000000..2e7c0454 --- /dev/null +++ b/tos/platforms/tmimsp/common/uart/DebugUartC.nc @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2008-2010, Titanium Mirror, Inc. + * 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 Technische Universität Berlin 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 R. Steve McKown + */ + +configuration DebugUartC { + provides { + interface Resource; + interface UartStream; + interface UartByte; + } +} +implementation { + components new ConsoleUartC() as UartC; + Resource = UartC; + UartStream = UartC; + UartByte = UartC; +} diff --git a/tos/platforms/tmimsp/common/uart/PlatformSerialC.nc b/tos/platforms/tmimsp/common/uart/PlatformSerialC.nc new file mode 100644 index 00000000..0a8d43b0 --- /dev/null +++ b/tos/platforms/tmimsp/common/uart/PlatformSerialC.nc @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2008-2010, Titanium Mirror, Inc. + * 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 Technische Universität Berlin 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 R. Steve McKown + */ + +configuration PlatformSerialC { + provides interface StdControl; + provides interface UartStream; + provides interface UartByte; +} +implementation { + components PlatformUartC as UartC; + UartStream = UartC; + UartByte = UartC; + + components new StdToResourceC() as PlatformSerialP; + StdControl = PlatformSerialP; + PlatformSerialP.Resource -> UartC; +} diff --git a/tos/platforms/tmimsp/common/uart/PlatformUartC.nc b/tos/platforms/tmimsp/common/uart/PlatformUartC.nc new file mode 100644 index 00000000..0388fe05 --- /dev/null +++ b/tos/platforms/tmimsp/common/uart/PlatformUartC.nc @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2008-2010, Titanium Mirror, Inc. + * 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 Technische Universität Berlin 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 R. Steve McKown + */ + +configuration PlatformUartC { + provides { + interface Resource; + interface UartStream; + interface UartByte; + } +} +implementation { + components new ConsoleUartC() as UartC; + Resource = UartC; + UartStream = UartC; + UartByte = UartC; +}