Exemple #1
0
void
vDebugSendHook (char data)
{
    vUSBSendByte (data);
    if (xLogfile)
        xQueueSend (xLogfile, &data, 0);
}
Exemple #2
0
static void
usbshell_task (void *pvParameters)
{
  static portCHAR buf[128], c, *p = buf;
  shell_print (PROMPT);

  for (;;)
    {
      if (!vUSBRecvByte (&c, sizeof (c), 100))
	continue;

      if (c == '\n' || c == '\r')
	{
	  *p = '\0';
	  parse_cmd (buf);

	  p = buf;
	  shell_print (PROMPT);
	  continue;
	}
      else if (c < ' ')
	continue;

      if (p == buf + sizeof (buf) - 1)
	{
	  p = buf;
	  *p = '\0';
	}

      /* local echo */
      vUSBSendByte (c);
      *p++ = c;
    }
}
Exemple #3
0
/*
 * overwrite default_putchar with USB CDC ACM
 * output to enable USB support for debug_printf
 */
BOOL default_putchar(uint8_t data)
{
	if (vTasksRunning)
		vUSBSendByte(data);
	/* always send out over serial port as well */
	UARTSendChar(data);

	return TRUE;
}
Exemple #4
0
void vApplicationIdleHook( void )
{
static TickType_t xLastTx = 0;
char cTxByte;

	/* The idle hook simply sends a string of characters to the USB port.
	The characters will be buffered and sent once the port is connected. */
	if( ( xTaskGetTickCount() - xLastTx ) > mainUSB_TX_FREQUENCY )
	{
		xLastTx = xTaskGetTickCount();
		for( cTxByte = mainFIRST_TX_CHAR; cTxByte <= mainLAST_TX_CHAR; cTxByte++ )
		{
			vUSBSendByte( cTxByte );
		}
	}
}
Exemple #5
0
void
vDebugSendHook (char data)
{
	vUSBSendByte (data);
}
Exemple #6
0
/* USB CLI receive task */
void vUSB_cli_receive_task(void *pvParameters) {

	char cRxedChar;
	char cInputString[20];
	char cInputIndex = 0;
	int8_t *pcOutputString;
	portBASE_TYPE xReturned;

	//Initialise pointer to CLI output buffer.
	memset(cInputString, 0, sizeof(cInputString));
	pcOutputString = FreeRTOS_CLIGetOutputBuffer();

	// Cli receive loop
	for (;;) {

		//Receive character from USB receive
		cRxedChar = ucUSBReadByte();
		if ((cRxedChar != 0) && (cRxedChar != 5)) {

			//reflect byte
			vUSBSendByte(cRxedChar);

			//Process only if return is received.
			if (cRxedChar == '\r') {
				
				//Put null character in command input string.
				cInputString[cInputIndex] = '\0';

                //debug_printf("\r\n---%s---%d---\r\n", pcOutputString, strlen(pcOutputString));
				//memcpy(ucRemoteBuffer, cInputString, strlen(cInputString));
				sprintf(ucRemoteBuffer, "%s", cInputString);
				vRemoteSend(ucRemoteBuffer, strlen(ucRemoteBuffer));

			    do {
                    //Process command input string.
                    xReturned = FreeRTOS_CLIProcessCommand( cInputString, pcOutputString, configCOMMAND_INT_MAX_OUTPUT_SIZE );

                    //Display CLI output string
                    sprintf(ucRemoteBuffer, "%s", pcOutputString);
                    remote_printf(ucRemoteBuffer);

                    // Wait for 10ms
					vTaskDelay(10);
					
				// Loop until repeat is done
			    } while (xReturned == cliREPEAT);
				
				memset(cInputString, 0, sizeof(cInputString));
                cInputIndex = 0;
			
			} else {

				if( cRxedChar == '\r' ) {

					// Ignore the character.
				} else if( cRxedChar == '\b' ) {

					// Backspace was pressed.  Erase the last character in the
					//string - if any.
					if( cInputIndex > 0 ) {
						cInputIndex--;
						cInputString[ cInputIndex ] = '\0';
					}

				} else {
					// A character was entered.  Add it to the string
					// entered so far.  When a \n is entered the complete
					// string will be passed to the command interpreter.
					if( cInputIndex < 20 ) {
						cInputString[ cInputIndex ] = cRxedChar;
						cInputIndex++;
					}
				}
			}	
		}

		vTaskDelay(50);
	}
}