Esempio n. 1
0
static void CDC_Run(void) {
  int i;

  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
//      LED1_Neg(); LED2_Off();
      WAIT1_Waitms(10);
    }
//    LED1_Off(); LED2_Neg();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(   i<sizeof(in_buffer)-1
            && CDC1_GetChar(&in_buffer[i])==ERR_OK
           )
      {
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      (void)CDC1_SendString((unsigned char*)"\r\n");
    } else {
      WAIT1_Waitms(10);
    }
  }
}
Esempio n. 2
0
static void CDC_Run(void) {
  int i;

  SendStr((unsigned char*)"Hello World to Kinetis SCI3!\r\n");
  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      LED1_Neg(); LED2_Off();
     // WAIT1_Waitms(1); /* just give back some CPU time. */
      SendStr((unsigned char*)"waiting to enumerate...\r\n");
    }
    LED1_Off(); LED2_Neg();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(   i<sizeof(in_buffer)-1
            && CDC1_GetChar(&in_buffer[i])==ERR_OK
           )
      {
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      (void)CDC1_SendString((unsigned char*)"\r\n");
      SendStr((unsigned char*)"echo to SCI3: ");
      SendStr(in_buffer);
      SendStr((unsigned char*)"\r\n");
    } else {
     // WAIT1_Waitms(5);
    }
  }
}
Esempio n. 3
0
static void CDC_Run(void) {
  int i;
  
  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      LED1_Neg(); LED2_Off();
     // WAIT1_Waitms(1); /* just give back some CPU time. S08JM60 does not allow much spare time here! */
    }
    LED1_Off(); LED2_Neg();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(   i<sizeof(in_buffer)-1 
            && CDC1_GetChar(&in_buffer[i])==ERR_OK
           ) 
      {
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      (void)CDC1_SendString((unsigned char*)"\r\n");
    } else {
      //WAIT1_Waitms(5);
    }
  }
}
Esempio n. 4
0
void APP_Run(void) {
  int i;
  uint32_t val = 0;
  unsigned char buf[16];

  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      LED1_Neg(); LED2_Off();
      WAIT1_Waitms(10);
    }
    LED2_Off(); LED1_Neg();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(   i<sizeof(in_buffer)-1
            && CDC1_GetChar(&in_buffer[i])==ERR_OK
           )
      {
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"val: ");
      UTIL1_strcatNum32u(buf, sizeof(buf), val);
      UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n");
      (void)CDC1_SendString(buf);
      val++;
    } else {
      WAIT1_Waitms(10);
    }
  }
}
Esempio n. 5
0
static void CDC_Run(void) {
  int i;
 
  for(;;) {
	reactToButton();  
	
	int j = 0;
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      //LEDR_Neg(); LEDG_Off();
      reactToButton();
      
      if(j % 50 == 0) {
    	  LED_Neg();
      }
      j++;
      
      WAIT1_Waitms(10);
    }
    //LEDR_Off(); LEDG_Neg();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(i<sizeof(in_buffer)-1 && CDC1_GetChar(&in_buffer[i])==ERR_OK) {
    	switchLEDs(in_buffer[i]);  
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      (void)CDC1_SendString((unsigned char*)"\r\n");
    } else {
      WAIT1_Waitms(10);
    }
  }
}
Esempio n. 6
0
void Handle_USB_Read()
{
	static char myChar = 0;
	uint8_t Recieved_Data = 0;
	  if (USB1_GetCharsInRxBuf()!=0)
	    {
	      while(CDC1_GetChar(&Recieved_Data)==ERR_OK)
	      {


	    	USB1_SendChar(Recieved_Data);
	    	CMD_String_Buffer[CMD_Index] = Recieved_Data;

	    	do
	    	{

	    		if(CMD_Index>(CMD_STRING_SIZE-1)) // If buffer overflowed
	    		{
	    			Buffer_Overflow = true;
	    			break;
	    		}

				if(Recieved_Data=='\r') // if received enter key
				{
					Command_Recieved = true;
					break;
				}
	    		CMD_Index++;

	    	}while(0);

	    	if(Buffer_Overflow)
	    	{
	    		CMD_Index=0;
	    		CDC1_SendString((char *)CMD_Invalid_Str);
	    		memset(CMD_String_Buffer,0,CMD_STRING_SIZE);
	    	}

	    	if(Command_Recieved)
	    	{
	    		Command_Recieved = false;
	    		CDC1_SendString("\n");
	    		Handle_Command(CMD_String_Buffer);
	    		memset(CMD_String_Buffer,0,CMD_STRING_SIZE); // Erase command
	    		CMD_Index=0;
	    	}
	      }
	    }
}
static void CDC_Run(void) {
  int i, cnt = 0;
  uint32_t val = 0;
  unsigned char buf[16];

  (void)CDC1_SendString((unsigned char*)"Hello world from the KL25Z with USB CDC\r\n");
  for(;;) {
    while(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF) {
      /* device not enumerated */
      LED1_Neg(); LED2_Off();
      WAIT1_Waitms(10);
      cnt++;
      if (cnt==100) {
        LED3_Neg();
        cnt = 0;
      }
    }
    LED1_Off(); LED2_Neg(); LED3_Off();
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(   i<sizeof(in_buffer)-1
            && CDC1_GetChar(&in_buffer[i])==ERR_OK
           )
      {
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"echo: ");
      (void)CDC1_SendString(in_buffer);
      UTIL1_strcpy(buf, sizeof(buf), (unsigned char*)"val: ");
      UTIL1_strcatNum32u(buf, sizeof(buf), val);
      UTIL1_strcat(buf, sizeof(buf), (unsigned char*)"\r\n");
      (void)CDC1_SendString(buf);
      val++;
    } else {
      WAIT1_Waitms(10);
      cnt++;
      if ((cnt%1024)==0) { /* from time to time, write some text */
        (void)CDC1_SendString((unsigned char*)"Type some text and it will echo.\r\n");
      }
    }
  }
}
Esempio n. 8
0
static void CDC_Run(void) {
  int i;
  Init();
  SendString((unsigned char*) "uart: Hello World\r\n", &deviceData);
  for(;;) {
	reactToButton();  
	reactToUART();
    cdc_connected = !(CDC1_App_Task(cdc_buffer, sizeof(cdc_buffer))==ERR_BUSOFF);
    if (CDC1_GetCharsInRxBuf()!=0) {
      i = 0;
      while(i<sizeof(in_buffer)-1 && CDC1_GetChar(&in_buffer[i])==ERR_OK) {
    	switchLEDs(in_buffer[i]);  
        i++;
      }
      in_buffer[i] = '\0';
      (void)CDC1_SendString((unsigned char*)"cdc: ");
      (void)CDC1_SendString(in_buffer);
      (void)CDC1_SendString((unsigned char*)"\r\n");
    } else {
      WAIT1_Waitms(10);
    }
  }
}
static void CDC_StdIOReadChar(uint8_t *c) {
  if (CDC1_GetChar((uint8_t *)c) != ERR_OK) {
    /* failed to receive character: return a zero character */
    *c = '\0';
  }
}
Esempio n. 10
0
uint8 USB_GetByte(){
	CDC1_GetChar(&c);
	return c;
}