]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Fix up atomic warnings for robug in MSp430UartP.nc.
authorsmckown <smckown@4bc1554a-c7f2-4f65-a403-e0be01f0239c>
Tue, 9 Sep 2008 18:10:36 +0000 (18:10 +0000)
committerR. Steve McKown <rsmckown@gmail.com>
Tue, 1 Dec 2009 03:00:55 +0000 (20:00 -0700)
tos/chips/msp430/usci/Msp430UartP.nc

index 7b39bbcd8c8a20b318e47cc91d823d64a9bc6436..355820460eb6af580b6b211cb13c160596f1cbcd 100644 (file)
@@ -210,74 +210,84 @@ implementation {
 
   async command error_t UartStream.enableReceiveInterrupt()
   {
-    if (!robuf)
-      call Registers.clrIfgRx();
-    call Registers.setIeRx();
-    rxie = FALSE;
-    return SUCCESS;
+    atomic {
+      if (!robuf)
+       call Registers.clrIfgRx();
+      call Registers.setIeRx();
+      rxie = FALSE;
+      return SUCCESS;
+    }
   }
 
   async command error_t UartStream.disableReceiveInterrupt()
   {
-    if (!robuf) {
-      call Registers.clrIeRx();
-      call Registers.clrIfgRx();
-    } else
-      rxie = TRUE;
-    return SUCCESS;
+    atomic {
+      if (!robuf) {
+       call Registers.clrIeRx();
+       call Registers.clrIfgRx();
+      } else
+       rxie = TRUE;
+      return SUCCESS;
+    }
   }
 
   async command error_t UartByte.receive(uint8_t* byte, uint8_t timeout)
   {
-    uint16_t t;
+    atomic {
+      uint16_t t;
 
-    /* FIXME: race with UartStream.receive() */
-    if (robuf || !byte)
-      return FAIL;
-    /* TODO: implement timeout, byte-time units.  For now, 1-2 sec */
-    t = TBR;
-    while (t < TBR) {
-      if (call Registers.getIfgRx()) {
-       *byte = call Registers.getRxbuf();
-       return SUCCESS;
+      /* FIXME: race with UartStream.receive() */
+      if (robuf || !byte)
+       return FAIL;
+      /* TODO: implement timeout, byte-time units.  For now, 1-2 sec */
+      t = TBR;
+      while (t < TBR) {
+       if (call Registers.getIfgRx()) {
+         *byte = call Registers.getRxbuf();
+         return SUCCESS;
+       }
       }
+      return FAIL;
     }
-    return FAIL;
   }
 
   async command error_t UartStream.receive(uint8_t* buf, uint16_t len)
   {
-    if (robuf || !buf || !len)
-      return FAIL;
-    robuf = rbuf = buf;
-    rolen = rlen = len;
-    if (!call Registers.getIeRx()) {
-      call Registers.clrIfgRx();
-      call Registers.setIeRx();
-      rxie = TRUE;
-    } else
-      rxie = FALSE;
+    atomic {
+      if (robuf || !buf || !len)
+       return FAIL;
+      robuf = rbuf = buf;
+      rolen = rlen = len;
+      if (!call Registers.getIeRx()) {
+       call Registers.clrIfgRx();
+       call Registers.setIeRx();
+       rxie = TRUE;
+      } else
+       rxie = FALSE;
+    }
   }
 
   async event void Interrupts.rx(uint8_t byte)
   {
-    if (robuf) {
-      /* receive() takes precedence if active */
-      while (rlen && call Registers.getIfgRx()) {
-       *rbuf = byte;
-       if (--rlen)
-         rbuf++;
-      }
-      if (rlen == 0 && robuf) {
-       if (rxie) {
-         call Registers.clrIeRx();
-         call Registers.clrIfgRx();
+    atomic {
+      if (robuf) {
+       /* receive() takes precedence if active */
+       while (rlen && call Registers.getIfgRx()) {
+         *rbuf = byte;
+         if (--rlen)
+           rbuf++;
        }
-       robuf = 0;
-       signal UartStream.receiveDone(robuf, rolen, SUCCESS);
-      }
-    } else
-      signal UartStream.receivedByte(byte);
+       if (rlen == 0 && robuf) {
+         if (rxie) {
+           call Registers.clrIeRx();
+           call Registers.clrIfgRx();
+         }
+         robuf = 0;
+         signal UartStream.receiveDone(robuf, rolen, SUCCESS);
+       }
+      } else
+       signal UartStream.receivedByte(byte);
+    }
   }
 
   default async command const msp430_usci_uart_t* Configure.get()