/*
   main.c
   Main C source file
   Test for harware profiling

   History:
      11/03/2015 : First version
 */

#define HPROFILE  // Activate Hardware Profiling

#include "Base.h"           // Basic definitions
#include "hprofile.h"       // Hardware Profile Header file

// Function that blinks the Green LED
// Parameters: NONE
// Never returns
void ledBlink(void)
 {
 while(1) // Infinite loop
   {
   // Turn ON Green LED
   (LEDS_PORT->BSRR.H.set)=BIT(GREEN_LED_PAD);

   HPROFILE_1_ON;
   // Wait 200ms
   SLEEP_MS(200);
   HPROFILE_1_OFF;

   // Turn OFF Green LED
   (LEDS_PORT->BSRR.H.clear)=BIT(GREEN_LED_PAD);

   // Wait 200ms
   SLEEP_MS(200);
   }
 }

// Check integer vs float operations
void integer_vs_float(void)
 {
 int32_t i;
 volatile float32_t f32_a,f32_b,fc2_c;
 volatile int32_t   i32_a,i32_b,i32_c;

 f32_a=7.0;
 f32_b=8.6;

 HPROFILE_1_ON;
 for(i=0;i<1000;i++)
   {
   f32_c=f32_a*f32_b;
   }
 HPROFILE_1_OFF;

 i32_a=7;
 i32_b=8;

 HPROFILE_2_ON;
 for(i=0;i<1000;i++)
   {
   i32_c=i32_a*i32_b;
   }
 HPROFILE_2_OFF;
 }

int main(void)
 {
 // Global initializations
 baseInit();

 // Init profile module
 HPROFILE_INIT;

 // Infinite loop
 while (1)
     {
	 integer_vs_float();
     };

 // Main should never return
 // This line is included so that the compiler doesn't complain
 return 0;
 }

