]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/msp430/usart/Msp430UartP.nc
Swapping HEAD and DEVEL branches
[tinyos-2.x.git] / tos / chips / msp430 / usart / Msp430UartP.nc
index c08d3fc00960babf62133af1a9897b4e0db26b5f..290fb60605a81a9435306999298bbe0f8b959d2a 100644 (file)
@@ -41,7 +41,7 @@ generic module Msp430UartP() {
 
   provides interface Resource[ uint8_t id ];
   provides interface ResourceConfigure[ uint8_t id ];
-  provides interface Msp430UartControl as UartControl[ uint8_t id ];
+  //provides interface Msp430UartControl as UartControl[ uint8_t id ];
   provides interface UartStream;
   provides interface UartByte;
   
@@ -80,39 +80,22 @@ implementation {
   }
 
   async command void ResourceConfigure.configure[ uint8_t id ]() {
-    call UartControl.setModeDuplex[id]();
+    msp430_uart_union_config_t* config = call Msp430UartConfigure.getConfig[id]();
+    m_byte_time = config->uartConfig.ubr / 2;
+    call Usart.setModeUart(config);
+    call Usart.enableIntr();
   }
 
   async command void ResourceConfigure.unconfigure[ uint8_t id ]() {
+    call Usart.resetUsart(TRUE);
     call Usart.disableIntr();
     call Usart.disableUart();
+    call Usart.resetUsart(FALSE);
   }
 
   event void UsartResource.granted[ uint8_t id ]() {
     signal Resource.granted[ id ]();
   }
-
-  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();
-  }
-  
-  async command void UartControl.setModeTx[ uint8_t id ]() {
-    call Usart.setModeUartTx(call Msp430UartConfigure.getConfig[id]());
-    call Usart.clrIntr();
-    call Usart.enableTxIntr();
-  }
-  
-  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();
@@ -177,6 +160,7 @@ implementation {
   async command error_t UartByte.send( uint8_t data ) {
     call Usart.tx( data );
     while( !call Usart.isTxIntrPending() );
+    call Usart.clrTxIntr();
     return SUCCESS;
   }
   
@@ -188,7 +172,7 @@ implementation {
     start = call Counter.get();
     while( !call Usart.isRxIntrPending() ) {
       if ( ( call Counter.get() - start ) >= timeout_micro )
-       return FAIL;
+                               return FAIL;
     }
     *byte = call Usart.rx();
     
@@ -202,7 +186,7 @@ implementation {
   default async command error_t UsartResource.request[ uint8_t id ]() { return FAIL; }
   default async command error_t UsartResource.immediateRequest[ uint8_t id ]() { return FAIL; }
   default async command error_t UsartResource.release[ uint8_t id ]() { return FAIL; }
-  default async command msp430_uart_config_t* Msp430UartConfigure.getConfig[uint8_t id]() {
+  default async command msp430_uart_union_config_t* Msp430UartConfigure.getConfig[uint8_t id]() {
     return &msp430_uart_default_config;
   }