]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/atm128/pins/HplAtm128GeneralIOSlowPinP.nc
turn on safe compilation for some modules
[tinyos-2.x.git] / tos / chips / atm128 / pins / HplAtm128GeneralIOSlowPinP.nc
index 5043095f1ffb1758e2632f81a5ff24566b159b7b..a6168ff144942bbcc5c6ee0e3bd19f4675ed5854 100644 (file)
 generic module HplAtm128GeneralIOSlowPinP (uint8_t port_addr, 
                                     uint8_t ddr_addr, 
                                     uint8_t pin_addr,
-                                    uint8_t bit)
+                                    uint8_t bit) @safe()
 {
   provides interface GeneralIO as IO;
 }
 implementation
 {
-#define pin (*(volatile uint8_t *)pin_addr)
-#define port (*(volatile uint8_t *)port_addr)
-#define ddr (*(volatile uint8_t *)ddr_addr)
+#define pin (*TCAST(volatile uint8_t * ONE, pin_addr))
+#define port (*TCAST(volatile uint8_t * ONE, port_addr))
+#define ddr (*TCAST(volatile uint8_t * ONE, ddr_addr))
 
   inline async command bool IO.get()        { return READ_BIT (pin, bit); }
   inline async command void IO.set()        { atomic SET_BIT  (port, bit); }
@@ -49,5 +49,7 @@ implementation
   inline async command void IO.toggle()     { atomic FLIP_BIT (port, bit); }
     
   inline async command void IO.makeInput()  { atomic CLR_BIT  (ddr, bit);  }
+  inline async command bool IO.isInput() { return !READ_BIT(ddr, bit); }
   inline async command void IO.makeOutput() { atomic SET_BIT  (ddr, bit);  }
+  inline async command bool IO.isOutput() { return READ_BIT(ddr, bit); }
 }