//======================================================
// LED
//======================================================
// File Name : main.c
// Function  : Main Routine
//------------------------------------------------------
// Rev.01 2008.03.24 Takanaga Yamazaki
//------------------------------------------------------
// (C) Copyright 2008 Takanaga Yamazaki
//======================================================
// ---- License Information ----------------------------
// Anyone can FREELY use this code fully or partially
// under conditions shown below.
// 1. You should use this code under the GNU GPL.
// 2. You should remain this header text in your codes
//   including Copyright credit and License Information.
// 3. Your codes should inherit this license information.
//======================================================
// ---- Patent Notice ----------------------------------
// I have not cared whether this system (hw + sw) causes 
// infringement on the patent, copyright, trademark,
// or trade secret rights of others. You have all 
// responsibilities for determining if your designs
// and products infringe on the intellectual property
// rights of others, when you use technical information
// included in this system for your business.
//======================================================
// ---- Disclaimers ------------------------------------
// The function and reliability of this system are not 
// guaranteed. They may cause any damages to loss of
// properties, data, money, profits, life, or business.
// By adopting this sytem even partially, you assume
// all responsibility for its use.
//======================================================

#include "common.h"
#include <stdlib.h>

//========================
// Main Routine
//========================
int main(void)
{
    volatile UI32 count;
    
    Set_System();

#ifdef DEBUG
  debug();
#endif
  
  Init_NVIC();
  Init_TIM4();
  
  count = 0;

  while(1)
  {
    mode = 0;
    
  //ftest1 = 1.23;
  //ftest2 = sin(ftest1) * -3.14;
    
  //GPIO_SetBits(GPIOC, GPIO_Pin_6);

    if (count_out != 0)
    {
      if (memcmp(buffer_out, "*", 1) == 0) mode = 1;
      
       count_out = 0;
    }
    
    if (mode == 1)
    {
      USB_Put_Str((UI08*) "Welcome to Star Finder!");
      USB_Put_Int_UI32((UI32) count);
      USB_Put_CRLF();
      USB_Put_Int_SI32(1234);
      USB_Put_CRLF();
      USB_Put_Int_SI32(-567);
      USB_Put_CRLF();
      USB_Put_FLOT(ftest1, 5);
      USB_Put_CRLF();
      USB_Put_FLOT(ftest2, 5);
      USB_Put_CRLF();

    //To_USB_Send_Data((char*) local_buffer);
    //To_USB_Send_Data("Welcome\n\r");
      
      mode = 0;
      count++;
    //if (count > 9) count = 0;


    }
  }
}

//=============================
// Toggle LED
//=============================
void Toggle_LED(void)
{
    UI16 od_gpioc;
    
    od_gpioc = GPIO_ReadOutputData(GPIOC);
    if (od_gpioc & 0x0040)
    {
        GPIO_ResetBits(GPIOC, GPIO_Pin_6);
    }
    else
    {
        GPIO_SetBits(GPIOC, GPIO_Pin_6);
    }
}



#ifdef  DEBUG
/*******************************************************************************
* Function Name  : assert_failed
* Description    : Reports the name of the source file and the source line number
*                  where the assert_param error has occurred.
* Input          : - file: pointer to the source file name
*                  - line: assert_param error line source number
* Output         : None
* Return         : None
*******************************************************************************/
void assert_failed(u8* file, u32 line)
{
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

  /* Infinite loop */
  while(1)
  {
  }
}
#endif

/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/

//======================================================
// End of Program
//======================================================
