PWM and ALGO updated.. PWM getting generated

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of TFR_BAE_vr1_1working_finally_PWM_update by Team Fox

Revision:
6:036d08b62785
Parent:
5:bb592f3185cc
--- 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