[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/msp430/usart HplMsp430I2C0P.nc, 1.1.2.1, 1.1.2.2 HplMsp430Usart0C.nc, 1.1.2.11, 1.1.2.12 HplMsp430Usart0P.nc, 1.1.2.11, 1.1.2.12 Msp430SpiNoDmaP.nc, 1.1.2.6, 1.1.2.7 Msp430UartP.nc, 1.1.2.10, 1.1.2.11 Msp430UsartShare0P.nc, 1.1.2.8, 1.1.2.9

Jonathan Hui jwhui at users.sourceforge.net
Fri Oct 13 10:26:07 PDT 2006


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

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	HplMsp430I2C0P.nc HplMsp430Usart0C.nc HplMsp430Usart0P.nc 
	Msp430SpiNoDmaP.nc Msp430UartP.nc Msp430UsartShare0P.nc 
Log Message:

Bug fix attempt for bug reported by Max Cortiana.

Change way USART is reset. Make use of unconfigure event so that the
UART, SPI, and I2C ocmponents reset the USART
appropriately. Specifically, I2C has different requirements for how to
reset the USART.

Because individual components disable themselves, the async power
manager is no longer needed.



Index: HplMsp430I2C0P.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart/Attic/HplMsp430I2C0P.nc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** HplMsp430I2C0P.nc	30 Aug 2006 17:15:55 -0000	1.1.2.1
--- HplMsp430I2C0P.nc	13 Oct 2006 17:26:03 -0000	1.1.2.2
***************
*** 58,66 ****
    
    async command void HplI2C.clearModeI2C() {
!     atomic U0CTL &= ~(I2C | I2CEN | SYNC);
    }
    
    async command void HplI2C.setModeI2C( msp430_i2c_config_t* config ) {
      
      atomic {
        
--- 58,76 ----
    
    async command void HplI2C.clearModeI2C() {
!     atomic {
!       U0CTL &= ~(I2C | SYNC | I2CEN);
!       call HplUsart.resetUsart(TRUE);
!     }
    }
    
    async command void HplI2C.setModeI2C( msp430_i2c_config_t* config ) {
      
+     call HplUsart.disableUart();
+     call HplUsart.disableSpi();
+     call SIMO.makeInput();
+     call SIMO.selectModuleFunc();
+     call UCLK.makeInput();
+     call UCLK.selectModuleFunc();
+     
      atomic {
        
***************
*** 70,84 ****
        U0CTL &= ~I2CEN;
        
-       call HplUsart.disableUart();
-       call HplUsart.disableSpi();
-       call SIMO.makeInput();
-       call SIMO.selectModuleFunc();
-       call UCLK.makeInput();
-       call UCLK.selectModuleFunc();
-       
        U0CTL |= ( ( config->rxdmaen << 7 ) |
                   ( config->txdmaen << 6 ) |
                   ( config->xa << 4 ) |
                   ( config->listen << 3 ) );
        I2CTCTL = ( ( config->i2cword << 7 ) |
  		  ( config->i2crm << 6 ) |
--- 80,88 ----
        U0CTL &= ~I2CEN;
        
        U0CTL |= ( ( config->rxdmaen << 7 ) |
                   ( config->txdmaen << 6 ) |
                   ( config->xa << 4 ) |
                   ( config->listen << 3 ) );
+       I2CTCTL = TXEPT;
        I2CTCTL = ( ( config->i2cword << 7 ) |
  		  ( config->i2crm << 6 ) |

Index: HplMsp430Usart0C.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart/HplMsp430Usart0C.nc,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -C2 -d -r1.1.2.11 -r1.1.2.12
*** HplMsp430Usart0C.nc	31 Aug 2006 14:59:54 -0000	1.1.2.11
--- HplMsp430Usart0C.nc	13 Oct 2006 17:26:03 -0000	1.1.2.12
***************
*** 66,70 ****
  configuration HplMsp430Usart0C {
    
-   provides interface AsyncStdControl;
    provides interface HplMsp430Usart;
    provides interface HplMsp430UsartInterrupts;
--- 66,69 ----
***************
*** 76,80 ****
    
    components HplMsp430Usart0P as HplUsartP;
-   AsyncStdControl = HplUsartP;
    HplMsp430Usart = HplUsartP;
    HplMsp430UsartInterrupts = HplUsartP;
--- 75,78 ----

Index: HplMsp430Usart0P.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart/HplMsp430Usart0P.nc,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -C2 -d -r1.1.2.11 -r1.1.2.12
*** HplMsp430Usart0P.nc	31 Aug 2006 14:59:54 -0000	1.1.2.11
--- HplMsp430Usart0P.nc	13 Oct 2006 17:26:04 -0000	1.1.2.12
***************
*** 72,76 ****
  
  module HplMsp430Usart0P {
-   provides interface AsyncStdControl;
    provides interface HplMsp430Usart as Usart;
    provides interface HplMsp430UsartInterrupts as Interrupts;
--- 72,75 ----
***************
*** 106,121 ****
    }
    
-   async command error_t AsyncStdControl.start() {
-     return SUCCESS;
-   }
- 
-   async command error_t AsyncStdControl.stop() {
-     call Usart.disableSpi();
-     call HplI2C.clearModeI2C();
-     call Usart.disableUart();
-     return SUCCESS;
-   }
- 
- 
    async command void Usart.setUctl(msp430_uctl_t control) {
      U0CTL=uctl2int(control);
--- 105,108 ----
***************
*** 162,169 ****
  
    async command void Usart.resetUsart(bool reset) {
!     if (reset)
!       SET_FLAG(U0CTL, SWRST);
!     else
        CLR_FLAG(U0CTL, SWRST);
    }
  
--- 149,158 ----
  
    async command void Usart.resetUsart(bool reset) {
!     if (reset) {
!       U0CTL = SWRST;
!     }
!     else {
        CLR_FLAG(U0CTL, SWRST);
+     }
    }
  
***************
*** 216,221 ****
  
    async command void Usart.disableUart() {
-     ME1 &= ~(UTXE0 | URXE0);   // USART0 UART module enable
      atomic {
        call UTXD.selectIOFunc();
        call URXD.selectIOFunc();
--- 205,211 ----
  
    async command void Usart.disableUart() {
      atomic {
+       ME1 &= ~(UTXE0 | URXE0);   // USART0 UART module enable
+       call Usart.resetUsart(TRUE);
        call UTXD.selectIOFunc();
        call URXD.selectIOFunc();
***************
*** 256,261 ****
  
    async command void Usart.disableSpi() {
-     ME1 &= ~USPIE0;   // USART0 SPI module disable
      atomic {
        call SIMO.selectIOFunc();
        call SOMI.selectIOFunc();
--- 246,252 ----
  
    async command void Usart.disableSpi() {
      atomic {
+       ME1 &= ~USPIE0;   // USART0 SPI module disable
+       call Usart.resetUsart(TRUE);
        call SIMO.selectIOFunc();
        call SOMI.selectIOFunc();
***************
*** 277,281 ****
      utctl.ssel = config->ssel;
      utctl.stc = config->stc;
! 
      call Usart.setUctl(uctl);
      call Usart.setUtctl(utctl);
--- 268,272 ----
      utctl.ssel = config->ssel;
      utctl.stc = config->stc;
!     
      call Usart.setUctl(uctl);
      call Usart.setUtctl(utctl);
***************
*** 286,293 ****
  
    async command void Usart.setModeSpi(msp430_spi_config_t* config) {
-     call Usart.disableUart();
-     call HplI2C.clearModeI2C();
      atomic {
-       call Usart.resetUsart(TRUE);
        configSpi(config);
        call Usart.enableSpi();
--- 277,281 ----
***************
*** 329,336 ****
    async command void Usart.setModeUartTx(msp430_uart_config_t* config) {
  
-     call Usart.disableSpi();
-     call HplI2C.clearModeI2C();
-     call Usart.disableUart();
- 
      atomic {
        call UTXD.selectModuleFunc();
--- 317,320 ----
***************
*** 349,356 ****
    async command void Usart.setModeUartRx(msp430_uart_config_t* config) {
  
-     call Usart.disableSpi();
-     call HplI2C.clearModeI2C();
-     call Usart.disableUart();
-     
      atomic {
        call UTXD.selectIOFunc();
--- 333,336 ----
***************
*** 369,376 ****
    async command void Usart.setModeUart(msp430_uart_config_t* config) {
  
-     call Usart.disableSpi();
-     call HplI2C.clearModeI2C();
-     call Usart.disableUart();
- 
      atomic {
        call UTXD.selectModuleFunc();
--- 349,352 ----
***************
*** 466,470 ****
    default async event void I2CInterrupts.fired() {}
    default async command bool HplI2C.isI2C() { return FALSE; }
-   default async command void HplI2C.clearModeI2C() {}
    
  }
--- 442,445 ----

Index: Msp430SpiNoDmaP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart/Msp430SpiNoDmaP.nc,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -d -r1.1.2.6 -r1.1.2.7
*** Msp430SpiNoDmaP.nc	28 Sep 2006 19:26:21 -0000	1.1.2.6
--- Msp430SpiNoDmaP.nc	13 Oct 2006 17:26:04 -0000	1.1.2.7
***************
*** 87,90 ****
--- 87,91 ----
  
    async command void ResourceConfigure.unconfigure[ uint8_t id ]() {
+     call Usart.disableSpi();
    }
  
***************
*** 97,101 ****
--- 98,104 ----
      call Usart.disableRxIntr();
      call Usart.tx( tx );
+     TOSH_CLR_GREEN_LED_PIN();
      while( !call Usart.isRxIntrPending() );
+     TOSH_SET_GREEN_LED_PIN();
      byte = call Usart.rx();
      call Usart.enableRxIntr();

Index: Msp430UartP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart/Msp430UartP.nc,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -C2 -d -r1.1.2.10 -r1.1.2.11
*** Msp430UartP.nc	10 Oct 2006 19:18:42 -0000	1.1.2.10
--- Msp430UartP.nc	13 Oct 2006 17:26:04 -0000	1.1.2.11
***************
*** 85,88 ****
--- 85,89 ----
    async command void ResourceConfigure.unconfigure[ uint8_t id ]() {
      call Usart.disableIntr();
+     call Usart.disableUart();
    }
  

Index: Msp430UsartShare0P.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/msp430/usart/Msp430UsartShare0P.nc,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** Msp430UsartShare0P.nc	30 Aug 2006 17:15:55 -0000	1.1.2.8
--- Msp430UsartShare0P.nc	13 Oct 2006 17:26:04 -0000	1.1.2.9
***************
*** 50,56 ****
    Interrupts = UsartShareP;
    I2CInterrupts = UsartShareP;
!   UsartShareP.RawInterrupts -> UsartC;
!   UsartShareP.RawI2CInterrupts -> UsartC;
! 
    components new FcfsArbiterC( MSP430_HPLUSART0_RESOURCE ) as ArbiterC;
    Resource = ArbiterC;
--- 50,54 ----
    Interrupts = UsartShareP;
    I2CInterrupts = UsartShareP;
!   
    components new FcfsArbiterC( MSP430_HPLUSART0_RESOURCE ) as ArbiterC;
    Resource = ArbiterC;
***************
*** 59,66 ****
    UsartShareP.ArbiterInfo -> ArbiterC;
  
!   components new AsyncStdControlPowerManagerC() as PowerManagerC;
!   PowerManagerC.ResourceController -> ArbiterC;
  
-   components HplMsp430Usart0C as UsartC;
-   PowerManagerC.AsyncStdControl -> UsartC;
  }
--- 57,63 ----
    UsartShareP.ArbiterInfo -> ArbiterC;
  
!   components HplMsp430Usart0C as HplUsartC;
!   UsartShareP.RawInterrupts -> HplUsartC;
!   UsartShareP.RawI2CInterrupts -> HplUsartC;
  
  }



More information about the Tinyos-2-commits mailing list