/*====================================================================================================*/
int main( void )
{
  s32 Sita = 0;

  SystemInit();
  GPIO_Config();
  ILI9341_Config();
  ILI9341_Init();
  WaveForm_Init();

  LED_R = 0;

  while(1) {
    LED_G = !LED_G;
    LED_B = !LED_B;

    Sita++;
    if(Sita == 360) Sita = 0;
    WaveForm.Data[0] = sinf(toRad(Sita))*10000;
    WaveForm.Data[1] = sinf(toRad(Sita-120))*10000;
    WaveForm.Data[2] = sinf(toRad(Sita-240))*10000;

    LCD_PutNum(WaveFromNum_X, WaveFromNum_Y+8*11, Type_I, 5, WaveForm.Data[0], RED,   BLACK);
    LCD_PutNum(WaveFromNum_X, WaveFromNum_Y+8*16, Type_I, 5, WaveForm.Data[1], GREEN, BLACK);
    LCD_PutNum(WaveFromNum_X, WaveFromNum_Y+8*21, Type_I, 5, WaveForm.Data[2], BLUE,  BLACK);

    WaveFormPrint(&WaveForm);
	}
}
Esempio n. 2
0
/*=====================================================================================================*/
void Windows_Interface( u8 Menu_Sel )
{
  
  static s16 Sita = 0;

	switch(Menu_Sel) {

/************************** FSM CONF **************************************/
		case Menu_INIT:
			break;
    
/************************** FSM EVENT **************************************/
		case Menu_SDCARD:
			break;
    
/************************** FSM INFO **************************************/
		case Menu_WAVE:
      Sita++;
      if(Sita == 360) Sita = 0;
      WaveForm.Data[0] = sinf(toRad(Sita))*10000;
      WaveForm.Data[1] = sinf(toRad(Sita-120))*10000;
      WaveForm.Data[2] = sinf(toRad(Sita-240))*10000;


      LCD_PutNum(WaveFromNum_X, WaveFromNum_Y+8*9,  Type_I, 5, WaveForm.Data[0], RED, BLACK);

      LCD_PutNum(WaveFromNum_X, WaveFromNum_Y+8*14, Type_I, 5, WaveForm.Data[1], GREEN, BLACK);

      LCD_PutNum(WaveFromNum_X, WaveFromNum_Y+8*19, Type_I, 5, WaveForm.Data[2], BLUE, BLACK);

      WaveFormPrint(&WaveForm);
			break;
/************************** FSM CTRL *************************************/
		case Menu_INFO:
			break;
	}
}
int main( void )
{
  u32 i = 0;
  u8 FileNum = 0;
  u8 ReadBuf[128] = {0};
  u8 WriteData[50] = "ABCDEFG";

  SystemInit();
  GPIO_Config();
  RS232_Config();
  R61581_Config();
  R61581_Init();

  LED_R = 1;
  LED_G = 1;
  LED_B = 1;
  LED_Y = 1;

  LED_R = 0;
  LCD_Clear(BLACK);

  // SD Card Init Info
  #define Axis_X 10
  #define Axis_Y 0
  LCD_PutStr(Axis_X, Axis_Y+16*0, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*1, (u8*)" SDIO SD Fatfs demo",     ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*2, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*3, (u8*)" SD Init ... ", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)" \r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n");
  RS232_SendStr(USART2, (u8*)" SDIO SD FatFs demo\r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n\r\n");
  RS232_SendStr(USART2, (u8*)" SD Init ... ");
  while(SD_Init() != SD_OK) {
    LCD_PutStr(Axis_X+8*13, Axis_Y+16*3, (u8*)"Failed!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"Failed!!\r\n");
    while(1) {
      LED_R = ~LED_R;
      Delay_100ms(2);
    }
  }
  LCD_PutStr(Axis_X+8*13, Axis_Y+16*3, (u8*)"OK!!", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)"OK!!\r\n\r\n");

  LCD_PutStr(Axis_X,      Axis_Y+16*5,  (u8*)"---- SD Init Info -----", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X,      Axis_Y+16*6,  (u8*)" Capacity : ", ASCII1608, WHITE, BLACK);
  LCD_PutNum(Axis_X+8*12, Axis_Y+16*6,  Type_D, 5, SDCardInfo.CardCapacity>>20, WHITE, BLACK);
  LCD_PutStr(Axis_X+8*17, Axis_Y+16*6,  (u8*)" MB", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X,      Axis_Y+16*7,  (u8*)" CardBlockSize : ", ASCII1608, WHITE, BLACK);
  LCD_PutNum(Axis_X+8*17, Axis_Y+16*7,  Type_D, 5, SDCardInfo.CardBlockSize, WHITE, BLACK);
  LCD_PutStr(Axis_X+8*22, Axis_Y+16*7,  (u8*)" ", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X,      Axis_Y+16*8,  (u8*)" CardType : ", ASCII1608, WHITE, BLACK);
  LCD_PutNum(Axis_X+8*12, Axis_Y+16*8,  Type_D, 5, SDCardInfo.CardType, WHITE, BLACK);
  LCD_PutStr(Axis_X+8*17, Axis_Y+16*8,  (u8*)" ", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X,      Axis_Y+16*9,  (u8*)" RCA : ", ASCII1608, WHITE, BLACK);
  LCD_PutNum(Axis_X+8*7,  Axis_Y+16*9,  Type_D, 5, SDCardInfo.RCA, WHITE, BLACK);
  LCD_PutStr(Axis_X+8*12, Axis_Y+16*9,  (u8*)" ", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X,      Axis_Y+16*10, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)"-----SD Init Info-----\r\n");
  RS232_SendStr(USART2, (u8*)" Capacity : ");
  RS232_SendNum(USART2, Type_D, 5, SDCardInfo.CardCapacity>>20);
  RS232_SendStr(USART2, (u8*)" MB\r\n");
  RS232_SendStr(USART2, (u8*)" CardBlockSize : ");
  RS232_SendNum(USART2, Type_D, 5, SDCardInfo.CardBlockSize);
  RS232_SendStr(USART2, (u8*)"\r\n");
  RS232_SendStr(USART2, (u8*)" CardType : ");
  RS232_SendNum(USART2, Type_D, 5, SDCardInfo.CardType);
  RS232_SendStr(USART2, (u8*)"\r\n");
  RS232_SendStr(USART2, (u8*)" RCA : ");
  RS232_SendNum(USART2, Type_D, 5, SDCardInfo.RCA);
  RS232_SendStr(USART2, (u8*)"\r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n");
  RS232_SendStr(USART2, (u8*)"\r\n");

  Delay_100ms(1);
  //////////////////// Wait
  while(KEY_S2 != 1){
    LED_G = ~LED_G;
    Delay_100ms(5);
  }
  LED_G = 0;
  LCD_Clear(BLACK);

  // Read Directory File
  LCD_PutStr(Axis_X, Axis_Y+16*0, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*1, (u8*)" SD_Card Read Directory", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*2, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)"----------------------\r\n");
  RS232_SendStr(USART2, (u8*)" SD_Card Read Directory File\r\n");
  RS232_SendStr(USART2, (u8*)"----------------------\r\n\r\n");

  res = f_mount(&FatFs, "", 1);
  res = f_opendir(&dirs, "0:/");
  res = f_readdir(&dirs, &finfo);
  while(res!= FR_OK) {
    LCD_PutStr(Axis_X, Axis_Y+16*3, (u8*)" Fatfs failed!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)" FatFs failed!!\r\n");
    while(1) {
      LED_R = ~LED_R;
      Delay_100ms(2);
    }
  }
  LCD_PutStr(Axis_X, Axis_Y+16*3, (u8*)" File name : ", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)" File name : \r\n");

  while(finfo.fname[0]) {
    f_readdir(&dirs, &finfo);
    if(!finfo.fname[0])
      break;
    if(FileNum<11) {
      LCD_PutStr(Axis_X,     Axis_Y+16*(3+FileNum), (u8*)" ... ", ASCII1608, WHITE, BLACK);
      LCD_PutStr(Axis_X+8*5, Axis_Y+16*(3+FileNum), (u8*)finfo.fname, ASCII1608, WHITE, BLACK);
    }
    else if((FileNum>=11) && (FileNum<22)) {
      LCD_PutStr(Axis_X+200,     Axis_Y+16*(3+FileNum-11), (u8*)" ... ", ASCII1608, WHITE, BLACK);
      LCD_PutStr(Axis_X+8*5+200, Axis_Y+16*(3+FileNum-11), (u8*)finfo.fname, ASCII1608, WHITE, BLACK);
    }
    else {
      FileNum = 0;
      break;
    }
    FileNum++;
    RS232_SendStr(USART2, (u8*)" ... ");
    RS232_SendStr(USART2, (u8*)finfo.fname);
    RS232_SendStr(USART2, (u8*)"\r\n");
  }

  Delay_100ms(1);
  //////////////////// Wait
  while(KEY_S2 != 1){
    LED_B = ~LED_B;
    Delay_100ms(5);
  }
  LED_B = 0;
  LCD_Clear(BLACK);

  // Write File
  LCD_PutStr(Axis_X, Axis_Y+16*0, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*1, (u8*)" SD_Card Write Data",     ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X, Axis_Y+16*2, (u8*)"-----------------------", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)"-----------------------\r\n");
  RS232_SendStr(USART2, (u8*)" SD_Card Write Data File\r\n");
  RS232_SendStr(USART2, (u8*)"-----------------------\r\n\r\n");

  LCD_PutStr(Axis_X, Axis_Y+16*3, (u8*)" f_open ... ", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)" f_open ... ");
  res = f_open(&file,"SDCard_K.txt", FA_OPEN_ALWAYS | FA_READ | FA_WRITE);
  if(res==FR_OK) {
    LCD_PutStr(Axis_X+8*12, Axis_Y+16*3, (u8*)"OK!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"OK!!\r\n");
  }
  else {
    LCD_PutStr(Axis_X+8*12, Axis_Y+16*3, (u8*)"failed!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"failed!!\r\n");
  }

  LCD_PutStr(Axis_X, Axis_Y+16*4, (u8*)" f_write ... ", ASCII1608, WHITE, BLACK);

  RS232_SendStr(USART2, (u8*)" f_write ... ");
  res = f_write(&file, WriteData, 20, &i); 
  if(res==FR_OK) {
    LCD_PutStr(Axis_X+8*13, Axis_Y+16*4, (u8*)"OK!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"OK!!\r\n");
  }
  else {
    LCD_PutStr(Axis_X+8*13, Axis_Y+16*4, (u8*)"failed!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"failed!!\r\n");
  }

  file.fptr = 0;

  LCD_PutStr(Axis_X, Axis_Y+16*5, (u8*)" f_read ... ", ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, (u8*)" f_read ... ");
  res = f_read(&file, ReadBuf, 100, &i);
  if(res==FR_OK) {
    LCD_PutStr(Axis_X+8*12, Axis_Y+16*5, (u8*)"OK!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"OK!!\r\n");
  }
  else {
    LCD_PutStr(Axis_X+8*12, Axis_Y+16*5, (u8*)"failed!!", ASCII1608, WHITE, BLACK);
    RS232_SendStr(USART2, (u8*)"failed!!\r\n");
  }

  f_close(&file);

  LCD_PutStr(Axis_X, Axis_Y+16*7, (u8*)" Read String : ", ASCII1608, WHITE, BLACK);
  LCD_PutStr(Axis_X+8*1, Axis_Y+16*8, (u8*)ReadBuf, ASCII1608, WHITE, BLACK);
  RS232_SendStr(USART2, ReadBuf);

  while(1) {
    LED_Y = ~LED_Y;
    Delay_100ms(2);
  }
}