X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=blobdiff_plain;f=tos%2Fchips%2Fatm1281%2Fatm128hardware.h;h=a5800f16c8ee68144c7463ed9ed1d42c49add8ee;hp=56ef6d102f1963ff86cbf0f5b88e9880613fff45;hb=e9bfab607e051bae6afb47b44892ce37541d1b44;hpb=adf1de6c009d13b7b52e68535c63b28f59c97400 diff --git a/tos/chips/atm1281/atm128hardware.h b/tos/chips/atm1281/atm128hardware.h index 56ef6d10..a5800f16 100644 --- a/tos/chips/atm1281/atm128hardware.h +++ b/tos/chips/atm1281/atm128hardware.h @@ -188,5 +188,23 @@ typedef struct uint8_t xmbk : 1; //!< External Memory Bus-keeper Enable } Atm128_XMCRB_t; +/* 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 AVR 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_atmega128hardware_H