I have a compass module with an SPI that sends the heading information as IEEE floating point.
The float number is contained in a longer data stream, the four bytes for its representation are organized MSB first. The exaxt position of the four bytes inside the data stream is know.
I´ve got the following variable definitions:
uint8_t incoming_data; uint8_t tmpstr; float heading;
The four bytes of the float are in the incoming_data array at positions 3 to 6.
Since avr-gcc also uses the 32 bit IEEE-representation for floats, after receiving the whole 24 byte data stream, I do:
memcpy(tmpstr,incoming_data+3,4); heading = (float) *tmpstr;
I´m unsure if this cast will work out OK. Could you please comment on this?