]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/msp430/msp430hardware.h
Fix USCI hanging caused by clearing the TXIFG bit.
[tinyos-2.x.git] / tos / chips / msp430 / msp430hardware.h
index dd4a4696b1dc7aaf1387efd5b8cb53dcb02b0649..e0d9cbac33096f04a3e01bf87254d6791db5e223 100644 (file)
@@ -77,7 +77,7 @@ MSP430REG_NORACE3(TYPE_##name,name,name##_)
 // creating potentially broken object code.  Union casts are the appropriate work
 // around.  Unfortunately, they require a function definiton.
 #define DEFINE_UNION_CAST(func_name,to_type,from_type) \
-to_type func_name(from_type x) { union {from_type f; to_type t;} c = {f:x}; return c.t; }
+to_type func_name(from_type x) @safe() { union {from_type f; to_type t;} c = {f:x}; return c.t; }
 
 // redefine ugly defines from msp-gcc
 #ifndef DONT_REDEFINE_SR_FLAGS
@@ -123,6 +123,17 @@ to_type func_name(from_type x) { union {from_type f; to_type t;} c = {f:x}; retu
 #undef signal
 #endif
 
+
+// Re-definitions for safe tinyOS
+// These rely on io.h being included at the top of this file
+// thus pulling the affected header files before the re-definitions
+#ifdef SAFE_TINYOS
+#undef ADC12MEM
+#define ADC12MEM            TCAST(int* ONE, ADC12MEM_) /* ADC12 Conversion Memory (for C) */
+#undef ADC12MCTL
+#define ADC12MCTL           TCAST(char * ONE, ADC12MCTL_)
+#endif
+
 // define platform constants that can be changed for different compilers
 // these are all msp430-gcc specific (add as necessary)
 
@@ -167,20 +178,20 @@ MSP430REG_NORACE2(I2CDCTLnr,I2CDCTL);
 // be detectde by nesc.
 
 #define TOSH_ASSIGN_PIN_HEX(name, port, hex) \
-void TOSH_SET_##name##_PIN() { MSP430REG_NORACE2(r,P##port##OUT); r |= hex; } \
-void TOSH_CLR_##name##_PIN() { MSP430REG_NORACE2(r,P##port##OUT); r &= ~hex; } \
-void TOSH_TOGGLE_##name##_PIN() { MSP430REG_NORACE2(r,P##port##OUT); r ^= hex; } \
-uint8_t TOSH_READ_##name##_PIN() { MSP430REG_NORACE2(r,P##port##IN); return (r & hex); } \
-void TOSH_MAKE_##name##_OUTPUT() { MSP430REG_NORACE2(r,P##port##DIR); r |= hex; } \
-void TOSH_MAKE_##name##_INPUT() { MSP430REG_NORACE2(r,P##port##DIR); r &= ~hex; } \
-void TOSH_SEL_##name##_MODFUNC() { MSP430REG_NORACE2(r,P##port##SEL); r |= hex; } \
-void TOSH_SEL_##name##_IOFUNC() { MSP430REG_NORACE2(r,P##port##SEL); r &= ~hex; }
+void TOSH_SET_##name##_PIN() @safe() { MSP430REG_NORACE2(r,P##port##OUT); r |= hex; } \
+void TOSH_CLR_##name##_PIN() @safe() { MSP430REG_NORACE2(r,P##port##OUT); r &= ~hex; } \
+void TOSH_TOGGLE_##name##_PIN() @safe(){ MSP430REG_NORACE2(r,P##port##OUT); r ^= hex; } \
+uint8_t TOSH_READ_##name##_PIN() @safe() { MSP430REG_NORACE2(r,P##port##IN); return (r & hex); } \
+void TOSH_MAKE_##name##_OUTPUT() @safe() { MSP430REG_NORACE2(r,P##port##DIR); r |= hex; } \
+void TOSH_MAKE_##name##_INPUT() @safe() { MSP430REG_NORACE2(r,P##port##DIR); r &= ~hex; } \
+void TOSH_SEL_##name##_MODFUNC() @safe() { MSP430REG_NORACE2(r,P##port##SEL); r |= hex; } \
+void TOSH_SEL_##name##_IOFUNC() @safe() { MSP430REG_NORACE2(r,P##port##SEL); r &= ~hex; }
 
 #define TOSH_ASSIGN_PIN(name, port, bit) \
 TOSH_ASSIGN_PIN_HEX(name,port,(1<<(bit)))
 
 typedef uint8_t mcu_power_t @combine("mcombine");
-mcu_power_t mcombine(mcu_power_t m1, mcu_power_t m2) {
+mcu_power_t mcombine(mcu_power_t m1, mcu_power_t m2) @safe() {
   return (m1 < m2) ? m1: m2;
 }
 enum {
@@ -192,13 +203,13 @@ enum {
   MSP430_POWER_LPM4   = 5
 };
 
-void __nesc_disable_interrupt(void)
+void __nesc_disable_interrupt(void) @safe()
 {
   dint();
   nop();
 }
 
-void __nesc_enable_interrupt(void)
+void __nesc_enable_interrupt(void) @safe()
 {
   eint();
 }
@@ -212,7 +223,7 @@ void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts);
    is #defined, to avoid duplicate functions definitions wheb binary
    components are used. Such functions do need a prototype in all cases,
    though. */
-__nesc_atomic_t __nesc_atomic_start(void) @spontaneous()
+__nesc_atomic_t __nesc_atomic_start(void) @spontaneous() @safe()
 {
   __nesc_atomic_t result = ((READ_SR & SR_GIE) != 0);
   __nesc_disable_interrupt();
@@ -220,7 +231,7 @@ __nesc_atomic_t __nesc_atomic_start(void) @spontaneous()
   return result;
 }
 
-void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts) @spontaneous()
+void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts) @spontaneous() @safe()
 {
   asm volatile("" : : : "memory"); /* ensure atomic section effect visibility */
   if( reenable_interrupts )