X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fmsp430%2Fmsp430hardware.h;h=b2a5cfc26762490c0e5c60f645d5af13d7b8e13d;hb=33953a2e344b09fcd13b3bc53a421da4c51336d7;hp=e0d9cbac33096f04a3e01bf87254d6791db5e223;hpb=21733c191df88cb1f62b88a74c39c5d1bccb5d6b;p=tinyos-2.x.git diff --git a/tos/chips/msp430/msp430hardware.h b/tos/chips/msp430/msp430hardware.h index e0d9cbac..b2a5cfc2 100644 --- a/tos/chips/msp430/msp430hardware.h +++ b/tos/chips/msp430/msp430hardware.h @@ -26,8 +26,15 @@ #ifndef _H_msp430hardware_h #define _H_msp430hardware_h +#if defined(__MSPGCC__) +/* mspgcc */ +#include +#include +#else /* __MSPGCC__ */ +/* old mspgcc3, forked mspgcc4 */ #include #include +#endif /* __MSPGCC__ */ #include "msp430regtypes.h" @@ -220,7 +227,7 @@ void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts); #ifndef NESC_BUILD_BINARY /* @spontaneous() functions should not be included when NESC_BUILD_BINARY - is #defined, to avoid duplicate functions definitions wheb binary + is #defined, to avoid duplicate functions definitions when binary components are used. Such functions do need a prototype in all cases, though. */ __nesc_atomic_t __nesc_atomic_start(void) @spontaneous() @safe() @@ -239,5 +246,24 @@ void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts) @spontaneous() @safe } #endif +/* Floating-point network-type support. + These functions must convert to/from a 32-bit big-endian integer that follows + the layout of Java's java.lang.float.floatToRawIntBits method. + Conveniently, for the MSP430 family, this is a straight byte copy... +*/ + +typedef float nx_float __attribute__((nx_base_be(afloat))); + +inline float __nesc_ntoh_afloat(const void *COUNT(sizeof(float)) source) @safe() { + float f; + memcpy(&f, source, sizeof(float)); + return f; +} + +inline float __nesc_hton_afloat(void *COUNT(sizeof(float)) target, float value) @safe() { + memcpy(target, &value, sizeof(float)); + return value; +} + #endif//_H_msp430hardware_h