So, I'm working on a project where I am loading configurations from nonvolatile memory (NVM). Because of this, I'm including a CRC along with the rest of the data to ensure that the data was not corrupted somehow and restore the data if necessary. However, I am running into a block with processing the data. While I know how to write or load the block of data from the NVM, the issue I run into is how to process the data once I've loaded it. For those that don't know a Float is a 4 byte number, and I'm organizing the data I save into 32 long single byte arrays with the data encoded into it and pulling the data out and dumping the data into this array.
When I write it, I convert the float into an 4 Byte array, then copy the array into memory:
uint8_t data_buff; float temp_f = 0.0; uint8_t * temp_f_array; temp_f = MAGIC_FLOAT_NUMBER; //4 Bytes temp_f_array = (uint8_t*) &temp_f; memcpy(&data_buff, &temp_f_array, 4); [\code] (I believe this code works, testing is somewhat hard without) Now the problem I'm having is figuring out what I need to do to point the float temp_f at the same place as temp_f_array so I can consider it a float value. I've tried: [code] &temp_f = (float *) temp_f_array;
But this is not legal code: (lvalue required as left operand of assignment, IE I cannot use '&' on the left side)
How can I perform this operation?