]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/msp430/usci/HplMsp430UsciRegP.nc
More USCI work.
[tinyos-2.x.git] / tos / chips / msp430 / usci / HplMsp430UsciRegP.nc
index d67123ceb6accf512e4a74b558e9b55630b87e70..cde8ae1acbc44247886d0cbc6e9a0402329c840d 100644 (file)
  * @author R. Steve McKown <rsmckown@gmail.com>
  */
  
-#include "msp430usci.h"
+#include "Msp430Usci.h"
+#include "msp430hardware.h"
 
 generic module HplMsp430UsciRegP(
-    uint8_t Ctl0_addr,
-    uint8_t Ctl1_addr,
-    uint8_t Br0_addr,
-    uint8_t Br1_addr,
-    uint8_t Mctl_addr,         /* A devices only */
-    uint8_t I2Cie_addr,                /* B devices only */
-    uint8_t Stat_addr,
-    uint8_t Rxbuf_addr,
-    uint8_t Txbuf_addr,
-    uint8_t Abctl_addr,                /* A devices only */
-    uint8_t Irtctl_addr,       /* A devices only */
-    uint8_t Irrctl_addr,       /* A devices only */
-    uint8_t I2Coa_addr,                /* B devices only */
-    uint8_t I2Csa_addr,                /* B devices only */
-    uint8_t Ie_addr,
-    uint8_t Ifg_addr,
-    uint8_t UCAxRXIFG, /* We rely on xIE and xIFG at same bit positions */
-    uint8_t UCAxTXIFG,
+    uint16_t Ctl0_addr,
+    uint16_t Ctl1_addr,
+    uint16_t Br0_addr,
+    uint16_t Br1_addr,
+    uint16_t Mctl_addr,                /* A devices only */
+    uint16_t I2Cie_addr,       /* B devices only */
+    uint16_t Stat_addr,
+    uint16_t Rxbuf_addr,
+    uint16_t Txbuf_addr,
+    uint16_t Abctl_addr,       /* A devices only */
+    uint16_t Irtctl_addr,      /* A devices only */
+    uint16_t Irrctl_addr,      /* A devices only */
+    uint16_t I2Coa_addr,       /* B devices only */
+    uint16_t I2Csa_addr,       /* B devices only */
+    uint16_t Ie_addr,
+    uint16_t Ifg_addr,
+    uint16_t UCAxRXIFG,        /* We rely on xIE and xIFG at same bit positions */
+    uint16_t UCAxTXIFG
     ) @safe() {
   provides interface HplMsp430UsciReg as Registers;
 }
@@ -88,53 +89,62 @@ implementation
                (reg = ((reg) & ~(mask)) | ((value) & (mask)))
 
   #define RENDER(name) \
+       command volatile uint8_t* Registers.ptr##name() { \
+               return &UCxx##name; \
+       } \
        command uint8_t Registers.get##name(uint8_t mask) { \
                return READ_FLAG(UCxx##name, mask); \
        } \
        command void Registers.set##name(uint8_t mask) { \
-               return SET_FLAG(UCxx##name, mask); \
+               SET_FLAG(UCxx##name, mask); \
        } \
        command void Registers.clr##name(uint8_t mask) { \
-               return CLR_FLAG(UCxx##name, mask); \
+               CLR_FLAG(UCxx##name, mask); \
        } \
        command void Registers.assign##name(uint8_t mask, uint8_t value) { \
-               return ASSIGNBITS(UCxx##name, mask, value); \
+               ASSIGNBITS(UCxx##name, mask, value); \
        }
 
   #define RENDER_A(name) \
+       command volatile uint8_t* Registers.ptr##name() { \
+               return &UCAx##name; \
+       } \
        command uint8_t Registers.get##name(uint8_t mask) { \
                if (IS_USCI_Ax) \
                        return READ_FLAG(UCAx##name, mask); \
        } \
        command void Registers.set##name(uint8_t mask) { \
                if (IS_USCI_Ax) \
-                       return SET_FLAG(UCAx##name, mask); \
+                       SET_FLAG(UCAx##name, mask); \
        } \
        command void Registers.clr##name(uint8_t mask) { \
                if (IS_USCI_Ax) \
-                       return CLR_FLAG(UCAx##name, mask); \
+                       CLR_FLAG(UCAx##name, mask); \
        } \
        command void Registers.assign##name(uint8_t mask, uint8_t value) { \
                if (IS_USCI_Ax) \
-                       return ASSIGNBITS(UCAx##name, mask, value); \
+                       ASSIGNBITS(UCAx##name, mask, value); \
        }
 
   #define RENDER_B(name) \
+       command volatile uint8_t* Registers.ptr##name() { \
+               return &UCBx##name; \
+       } \
        command uint8_t Registers.get##name(uint8_t mask) { \
                if (IS_USCI_Bx) \
                        return READ_FLAG(UCBx##name, mask); \
        } \
        command void Registers.set##name(uint8_t mask) { \
                if (IS_USCI_Bx) \
-                       return SET_FLAG(UCBx##name, mask); \
+                       SET_FLAG(UCBx##name, mask); \
        } \
        command void Registers.clr##name(uint8_t mask) { \
                if (IS_USCI_Bx) \
-                       return CLR_FLAG(UCBx##name, mask); \
+                       CLR_FLAG(UCBx##name, mask); \
        } \
        command void Registers.assign##name(uint8_t mask, uint8_t value) { \
                if (IS_USCI_Bx) \
-                       return ASSIGNBITS(UCBx##name, mask, value); \
+                       ASSIGNBITS(UCBx##name, mask, value); \
        }
 
 #if 0
@@ -157,25 +167,25 @@ implementation
   MSP430REG_NORACE(UCxIfg);
 #endif
 
-  command msp430usci_mode_t Registers.getMode()
+  command msp430_usci_mode_t Registers.getMode()
   {
     if (READ_FLAG(UCxxCtl0, UCSYNC)) {
-      if (READ_FLAG(UCxxCtl0 == UCMODE_3))
-       return UCSYNC_I2C;
+      if (READ_FLAG(UCxxCtl0, UCMODE_3) == UCMODE_3)
+       return USCI_I2C;
       else
-       return UCSYNC_SPI;
+       return USCI_SPI;
     } else {
-      return UCSYNC_UART;
+      return USCI_UART;
     }
   }
 
   command bool Registers.setMode(msp430_usci_mode_t mode)
   {
-    if (mode == UCSYNC_UART && IS_USCI_Bx)
+    if (mode == USCI_UART && IS_USCI_Bx)
       return FALSE;
-    if (mode == UCI2C && IS_USCI_Ax)
+    if (mode == USCI_I2C && IS_USCI_Ax)
       return FALSE;
-    SET_FLAG(UCxxCtl0, UCSYNC)
+    SET_FLAG(UCxxCtl0, UCSYNC);
   }
 
   RENDER(Ctl0);
@@ -187,30 +197,30 @@ implementation
   RENDER(Stat);
 
   /* RENDER(Rxbuf); */
-  command uint8_t* Registers.ptrRxbuf()
+  command volatile uint8_t* Registers.ptrRxbuf()
   {
-    return UCxxRXBuf;
+    return &UCxxRxbuf;
   }
 
   command uint8_t Registers.getRxbuf()
   {
-    return UCxxRXBuf;
+    return UCxxRxbuf;
   }
 
   /* RENDER(Txbuf); */
-  command uint8_t* Registers.ptrTxbuf()
+  command volatile uint8_t* Registers.ptrTxbuf()
   {
-    return UCxxTXBuf;
+    return &UCxxTxbuf;
   }
 
   command uint8_t Registers.getTxbuf()
   {
-    return UCxxTXBuf;
+    return UCxxTxbuf;
   }
 
   command void Registers.setTxbuf(uint8_t byte)
   {
-    UCxxTXBuf = byte;
+    UCxxTxbuf = byte;
   }
 
   RENDER_A(Abctl);
@@ -220,65 +230,64 @@ implementation
   RENDER_B(I2Csa);
 
   /* RENDER(Ie); */
-  command bool getIeRx()
+  command bool Registers.getIeRx()
   {
     return READ_FLAG(UCxxIe, UCAxRXIFG);
   }
 
-  command void setIeRx()
+  command void Registers.setIeRx()
   {
-    return SET_FLAG(UCxxIe, UCAxRXIFG);
+    SET_FLAG(UCxxIe, UCAxRXIFG);
   }
 
-  command void clrIeRx()
+  command void Registers.clrIeRx()
   {
-    return CLR_FLAG(UCxxIe, UCAxRXIFG);
+    CLR_FLAG(UCxxIe, UCAxRXIFG);
   }
 
-  command bool getIeTx()
+  command bool Registers.getIeTx()
   {
     return READ_FLAG(UCxxIe, UCAxTXIFG);
   }
 
-  command void setIeTx()
+  command void Registers.setIeTx()
   {
-    return SET_FLAG(UCxxIe, UCAxTXIFG);
+    SET_FLAG(UCxxIe, UCAxTXIFG);
   }
 
-  command void clrIeTx()
+  command void Registers.clrIeTx()
   {
-    return CLR_FLAG(UCxxIe, UCAxTXIFG);
+    CLR_FLAG(UCxxIe, UCAxTXIFG);
   }
 
   /* RENDER(Ifg); */
-  command bool getIeRx()
+  command bool Registers.getIfgRx()
   {
     return READ_FLAG(UCxxIfg, UCAxRXIFG);
   }
 
-  command void setIfgRx()
+  command void Registers.setIfgRx()
   {
-    return SET_FLAG(UCxxIfg, UCAxRXIFG);
+    SET_FLAG(UCxxIfg, UCAxRXIFG);
   }
 
-  command void clrIfgRx()
+  command void Registers.clrIfgRx()
   {
-    return CLR_FLAG(UCxxIfg, UCAxRXIFG);
+    CLR_FLAG(UCxxIfg, UCAxRXIFG);
   }
 
-  command bool getIfgTx()
+  command bool Registers.getIfgTx()
   {
     return READ_FLAG(UCxxIfg, UCAxTXIFG);
   }
 
-  command void setIfgTx()
+  command void Registers.setIfgTx()
   {
-    return SET_FLAG(UCxxIfg, UCAxTXIFG);
+    SET_FLAG(UCxxIfg, UCAxTXIFG);
   }
 
-  command void clrIfgTx()
+  command void Registers.clrIfgTx()
   {
-    return CLR_FLAG(UCxxIfg, UCAxTXIFG);
+    CLR_FLAG(UCxxIfg, UCAxTXIFG);
   }
-
 }