Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of workinQM_10thDec by
Diff: TCTM.cpp
- Revision:
- 6:036d08b62785
- Parent:
- 5:bb592f3185cc
- Child:
- 8:82250e41da81
diff -r bb592f3185cc -r 036d08b62785 TCTM.cpp
--- a/TCTM.cpp Thu Dec 31 17:12:52 2015 +0000
+++ b/TCTM.cpp Fri Jan 22 19:51:50 2016 +0000
@@ -4,6 +4,10 @@
#include "EPS.h"
#include "pin_config.h"
#include "FreescaleIAP.h"
+#include "inttypes.h"
+#include "iostream"
+#include "stdint.h"
+#include "cassert"
extern DigitalOut gpo1; // enable of att sens2 switch
extern DigitalOut gpo2; // enable of att sens switch
@@ -769,12 +773,20 @@
// Convert float to 4 uint8_t
-void FCTN_CONVERT_FLOAT(float input, uint8_t* output)
+void FCTN_CONVERT_FLOAT(float input, uint8_t output[4])
{
- uint32_t temp;
- temp = (uint32_t)input;
- output[0] = (temp>>24)&0xFF;
- output[2] = (temp>>16)&0xFF;
- output[1] = (temp>>8)&0xFF;
- output[3] = temp & 0xFF; // verify the logic
+ assert(sizeof(float) == sizeof(uint32_t));
+ uint32_t* temp = reinterpret_cast<uint32_t*>(&input);
+
+ //float* output1 = reinterpret_cast<float*>(temp);
+
+ printf("\n\r %f ", input);
+ std::cout << "\n\r uint32"<<*temp << std::endl;
+
+ output[0] =(uint8_t )(((*temp)>>24)&0xFF);
+ output[2] =(uint8_t ) (((*temp)>>16)&0xFF);
+ output[1] =(uint8_t ) (((*temp)>>8)&0xFF);
+ output[3] =(uint8_t ) ((*temp) & 0xFF); // verify the logic
+ //printf("\n\r inside %d %d %d %d", output[3],output[2],output[1],output[0]);
+ //std:: cout << "\n\r uint8 inside " << output[3] << '\t' << output[2] << '\t' << output[1] << '\t' << output[0] <<std::endl;
}
\ No newline at end of file
