[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/msp430/usart Msp430Uart1C.nc, 1.1.2.9, 1.1.2.10 Msp430Uart1P.nc, 1.1.4.2, 1.1.4.3 Msp430UartP.nc, 1.1.2.9, 1.1.2.10 Uart1C.nc, 1.1.2.5, NONE

Jonathan Hui jwhui at users.sourceforge.net
Tue Oct 10 12:18:44 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv7771/chips/msp430/usart

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	Msp430Uart1C.nc Msp430Uart1P.nc Msp430UartP.nc 
Removed Files:
      Tag: tinyos-2_0_devel-BRANCH
	Uart1C.nc 
Log Message:

Match interfaces proposed in tep117.



Index: Msp430Uart1C.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart/Msp430Uart1C.nc,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -C2 -d -r1.1.2.9 -r1.1.2.10
*** Msp430Uart1C.nc	3 Aug 2006 18:10:41 -0000	1.1.2.9
--- Msp430Uart1C.nc	10 Oct 2006 19:18:42 -0000	1.1.2.10
***************
*** 42,46 ****
  
    provides interface Resource;
!   provides interface SerialByteComm;
    provides interface Msp430UartControl as UartControl;
  
--- 42,47 ----
  
    provides interface Resource;
!   provides interface UartStream;
!   provides interface UartByte;
    provides interface Msp430UartControl as UartControl;
  
***************
*** 56,60 ****
    components Msp430Uart1P as UartP;
    Resource = UartP.Resource[ CLIENT_ID ];
!   SerialByteComm = UartP.SerialByteComm;
    UartControl = UartP.UartControl[ CLIENT_ID ];
    Msp430UartConfigure = UartP.Msp430UartConfigure[ CLIENT_ID ];
--- 57,62 ----
    components Msp430Uart1P as UartP;
    Resource = UartP.Resource[ CLIENT_ID ];
!   UartStream = UartP.UartStream;
!   UartByte = UartP.UartByte;
    UartControl = UartP.UartControl[ CLIENT_ID ];
    Msp430UartConfigure = UartP.Msp430UartConfigure[ CLIENT_ID ];

Index: Msp430Uart1P.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart/Attic/Msp430Uart1P.nc,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -C2 -d -r1.1.4.2 -r1.1.4.3
*** Msp430Uart1P.nc	3 Aug 2006 18:10:41 -0000	1.1.4.2
--- Msp430Uart1P.nc	10 Oct 2006 19:18:42 -0000	1.1.4.3
***************
*** 41,46 ****
    provides interface ResourceConfigure[uint8_t id ];
    provides interface Msp430UartControl as UartControl[ uint8_t id ];
!   provides interface SerialByteComm;
! 
    uses interface Resource as UsartResource[ uint8_t id ];
    uses interface Msp430UartConfigure[ uint8_t id ];
--- 41,47 ----
    provides interface ResourceConfigure[uint8_t id ];
    provides interface Msp430UartControl as UartControl[ uint8_t id ];
!   provides interface UartStream;
!   provides interface UartByte;
!   
    uses interface Resource as UsartResource[ uint8_t id ];
    uses interface Msp430UartConfigure[ uint8_t id ];
***************
*** 56,60 ****
    Msp430UartConfigure = UartP.Msp430UartConfigure;
    UartControl = UartP.UartControl;
!   SerialByteComm = UartP.SerialByteComm;
    UsartResource = UartP.UsartResource;
    UsartInterrupts = UartP.UsartInterrupts;
--- 57,62 ----
    Msp430UartConfigure = UartP.Msp430UartConfigure;
    UartControl = UartP.UartControl;
!   UartStream = UartP.UartStream;
!   UartByte = UartP.UartByte;
    UsartResource = UartP.UsartResource;
    UsartInterrupts = UartP.UsartInterrupts;
***************
*** 62,66 ****
    components HplMsp430Usart1C as UsartC;
    UartP.Usart -> UsartC;
! 
    components LedsC as Leds;
    UartP.Leds -> Leds;
--- 64,71 ----
    components HplMsp430Usart1C as UsartC;
    UartP.Usart -> UsartC;
!   
!   components Counter32khzC as CounterC;
!   UartP.Counter -> CounterC;
!   
    components LedsC as Leds;
    UartP.Leds -> Leds;

Index: Msp430UartP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart/Msp430UartP.nc,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -C2 -d -r1.1.2.9 -r1.1.2.10
*** Msp430UartP.nc	15 Aug 2006 11:59:08 -0000	1.1.2.9
--- Msp430UartP.nc	10 Oct 2006 19:18:42 -0000	1.1.2.10
***************
*** 1,7 ****
! 
  
  /**
   * @author Vlado Handziski <handzisk at tkn.tu-berlin.de>
-  * @author Jonathan Hui <jhui at archedrock.com>
   * @version $Revision$ $Date$
   */
--- 1,36 ----
! /**
!  * Copyright (c) 2005-2006 Arch Rock Corporation
!  * 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 Arch Rock Corporation 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
!  * ARCH ROCK 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
!  */
  
  /**
+  * @author Jonathan Hui <jhui at archrock.com>
   * @author Vlado Handziski <handzisk at tkn.tu-berlin.de>
   * @version $Revision$ $Date$
   */
***************
*** 13,22 ****
    provides interface ResourceConfigure[ uint8_t id ];
    provides interface Msp430UartControl as UartControl[ uint8_t id ];
!   provides interface SerialByteComm;
! 
    uses interface Resource as UsartResource[ uint8_t id ];
    uses interface Msp430UartConfigure[ uint8_t id ];
    uses interface HplMsp430Usart as Usart;
    uses interface HplMsp430UsartInterrupts as UsartInterrupts;
    uses interface Leds;
  
--- 42,53 ----
    provides interface ResourceConfigure[ uint8_t id ];
    provides interface Msp430UartControl as UartControl[ uint8_t id ];
!   provides interface UartStream;
!   provides interface UartByte;
!   
    uses interface Resource as UsartResource[ uint8_t id ];
    uses interface Msp430UartConfigure[ uint8_t id ];
    uses interface HplMsp430Usart as Usart;
    uses interface HplMsp430UsartInterrupts as UsartInterrupts;
+   uses interface Counter<T32khz,uint16_t>;
    uses interface Leds;
  
***************
*** 24,28 ****
  
  implementation {
! 
    async command error_t Resource.immediateRequest[ uint8_t id ]() {
      return call UsartResource.immediateRequest[ id ]();
--- 55,64 ----
  
  implementation {
!   
!   norace uint8_t *m_tx_buf, *m_rx_buf;
!   norace uint16_t m_tx_len, m_rx_len;
!   norace uint16_t m_tx_pos, m_rx_pos;
!   norace uint8_t m_byte_time;
!   
    async command error_t Resource.immediateRequest[ uint8_t id ]() {
      return call UsartResource.immediateRequest[ id ]();
***************
*** 38,41 ****
--- 74,79 ----
  
    async command error_t Resource.release[ uint8_t id ]() {
+     if ( m_rx_buf || m_tx_buf )
+       return EBUSY;
      return call UsartResource.release[ id ]();
    }
***************
*** 54,58 ****
  
    async command void UartControl.setModeRx[ uint8_t id ]() {
!     call Usart.setModeUartRx(call Msp430UartConfigure.getConfig[id]());
      call Usart.clrIntr();
      call Usart.enableRxIntr();
--- 92,98 ----
  
    async command void UartControl.setModeRx[ uint8_t id ]() {
!     msp430_uart_config_t* config = call Msp430UartConfigure.getConfig[id]();
!     m_byte_time = config->ubr / 2;
!     call Usart.setModeUartRx(config);
      call Usart.clrIntr();
      call Usart.enableRxIntr();
***************
*** 66,87 ****
    
    async command void UartControl.setModeDuplex[ uint8_t id ]() {
!     call Usart.setModeUart(call Msp430UartConfigure.getConfig[id]());
      call Usart.clrIntr();
      call Usart.enableIntr();
    }
    
!   async command error_t SerialByteComm.put( uint8_t data ) {
!     call Usart.tx( data );
      return SUCCESS;
    }
! 
!   async event void UsartInterrupts.txDone() {
!     signal SerialByteComm.putDone();
    }
  
    async event void UsartInterrupts.rxDone( uint8_t data ) {
!     signal SerialByteComm.get( data );
    }
  
    default async command error_t UsartResource.isOwner[ uint8_t id ]() { return FAIL; }
    default async command error_t UsartResource.request[ uint8_t id ]() { return FAIL; }
--- 106,200 ----
    
    async command void UartControl.setModeDuplex[ uint8_t id ]() {
!     msp430_uart_config_t* config = call Msp430UartConfigure.getConfig[id]();
!     m_byte_time = config->ubr / 2;
!     call Usart.setModeUart(config);
      call Usart.clrIntr();
      call Usart.enableIntr();
    }
    
!   async command error_t UartStream.enableReceiveInterrupt() {
!     call Usart.enableRxIntr();
      return SUCCESS;
    }
!   
!   async command error_t UartStream.disableReceiveInterrupt() {
!     call Usart.disableRxIntr();
!     return SUCCESS;
    }
  
+   async command error_t UartStream.receive( uint8_t* buf, uint16_t len ) {
+     if ( len == 0 )
+       return FAIL;
+     atomic {
+       if ( m_rx_buf )
+ 	return EBUSY;
+       m_rx_buf = buf;
+       m_rx_len = len;
+       m_rx_pos = 0;
+     }
+     return SUCCESS;
+   }
+   
    async event void UsartInterrupts.rxDone( uint8_t data ) {
!     if ( m_rx_buf ) {
!       m_rx_buf[ m_rx_pos++ ] = data;
!       if ( m_rx_pos >= m_rx_len ) {
! 	uint8_t* buf = m_rx_buf;
! 	m_rx_buf = NULL;
! 	signal UartStream.receiveDone( buf, m_rx_len, SUCCESS );
!       }
!     }
!     else {
!       signal UartStream.receivedByte( data );
!     }
    }
+   
+   async command error_t UartStream.send( uint8_t* buf, uint16_t len ) {
+     if ( len == 0 )
+       return FAIL;
+     else if ( m_tx_buf )
+       return EBUSY;
+     m_tx_buf = buf;
+     m_tx_len = len;
+     m_tx_pos = 0;
+     call Usart.tx( buf[ m_tx_pos++ ] );
+     return SUCCESS;
+   }
+   
+   async event void UsartInterrupts.txDone() {
+     if ( m_tx_pos < m_tx_len ) {
+       call Usart.tx( m_tx_buf[ m_tx_pos++ ] );
+     }
+     else {
+       uint8_t* buf = m_tx_buf;
+       m_tx_buf = NULL;
+       signal UartStream.sendDone( buf, m_tx_len, SUCCESS );
+     }
+   }
+   
+   async command error_t UartByte.send( uint8_t data ) {
+     call Usart.tx( data );
+     while( !call Usart.isTxIntrPending() );
+     return SUCCESS;
+   }
+   
+   async command error_t UartByte.receive( uint8_t* byte, uint8_t timeout ) {
+     
+     uint16_t timeout_micro = m_byte_time * timeout + 1;
+     uint16_t start;
+     
+     start = call Counter.get();
+     while( !call Usart.isRxIntrPending() ) {
+       if ( ( call Counter.get() - start ) >= timeout_micro )
+ 	return FAIL;
+     }
+     *byte = call Usart.rx();
+     
+     return SUCCESS;
  
+   }
+   
+   async event void Counter.overflow() {}
+   
    default async command error_t UsartResource.isOwner[ uint8_t id ]() { return FAIL; }
    default async command error_t UsartResource.request[ uint8_t id ]() { return FAIL; }

--- Uart1C.nc DELETED ---



More information about the Tinyos-2-commits mailing list