]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/msp430/msp430hardware.h
mark more modules as safe code
[tinyos-2.x.git] / tos / chips / msp430 / msp430hardware.h
index 9d0cedd87662664b5af6f38f5019666ef1f72d4b..c7a96d0495d5fe4e599964f05c84dfe8b5080556 100644 (file)
@@ -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)
 
@@ -134,6 +145,11 @@ to_type func_name(from_type x) { union {from_type f; to_type t;} c = {f:x}; retu
 #define __msp430_have_adc12
 #endif
 
+// backwards compatibility to older versions of the header files
+#ifdef __MSP430_HAS_I2C__
+#define __msp430_have_usart0_with_i2c
+#endif
+
 // I2CBusy flag is not defined by current MSP430-GCC
 #ifdef __msp430_have_usart0_with_i2c
 #ifndef I2CBUSY
@@ -146,11 +162,11 @@ MSP430REG_NORACE2(I2CDCTLnr,I2CDCTL);
 
 // The signal attribute has opposite meaning in msp430-gcc than in avr-gcc
 #define TOSH_SIGNAL(signame) \
-void sig_##signame() __attribute__((interrupt (signame), wakeup, C))
+  void sig_##signame() __attribute__((interrupt (signame), wakeup)) @C()
 
 // TOSH_INTERRUPT allows nested interrupts
 #define TOSH_INTERRUPT(signame) \
-void isr_##signame() __attribute__((interrupt (signame), signal, wakeup, C))
+  void isr_##signame() __attribute__((interrupt (signame), signal, wakeup)) @C()
 
 
 #define SET_FLAG(port, flag) ((port) |= (flag))
@@ -211,11 +227,13 @@ __nesc_atomic_t __nesc_atomic_start(void) @spontaneous()
 {
   __nesc_atomic_t result = ((READ_SR & SR_GIE) != 0);
   __nesc_disable_interrupt();
+  asm volatile("" : : : "memory"); /* ensure atomic section effect visibility */
   return result;
 }
 
 void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts) @spontaneous()
 {
+  asm volatile("" : : : "memory"); /* ensure atomic section effect visibility */
   if( reenable_interrupts )
     __nesc_enable_interrupt();
 }