Ejemplo n.º 1
0
void console_init()
{
	command_len = 0;
	
	// Print the first command prompt
// 	print_prompt();
	
	// Start reading commands
	usb_rx_start();
}
Ejemplo n.º 2
0
S32 usb_read(U32 dis_addr,U32 tag, U32 *len, U8*buf)
{
    switch(tag)
    {
    case USB_START_XMIT_KEY:
        usb_rx_start();
        break;

    case USB_STOP_XMIT_KEY:
        usb_rx_stop();
        break;

    case USB_USER_DATA:
        return(usb_read_hw( len, buf ));

    case USB_USER_DATA_CSTR:
        return(usb_read_hw_cstr( len, buf ));

    case USB_ENUM_STATUS:
        if (usb_enum_status != NULL)
        {
            if (usb_enum_status(dis_addr) == TRUE)
            {
                *buf = TRUE;
            }
            else
            {
                *buf = FALSE;
            }
        }
        return CSST_SUCCESS;

    default:
        break;
    }
    return CSST_ERROR;
}
Ejemplo n.º 3
0
int console_run()
{
	int ret = 1;
	
	if (usb_rx_len)
	{
		for (int i = 0; i < usb_rx_len; ++i)
		{
			char ch = usb_rx_buffer[i];
			if (ch == 3)
			{
				printf("Stop\n");
				debug_update = 0;
				ret = 0;
				
				// Clear the command buffer
				command_len = 0;
			} else if (ch == '\r')
			{
				putchar('\n');
				if (command_len >= MAX_COMMAND_SIZE)
				{
					// Command too long
					printf("Command too long\n");
				} else {
					// We still have room for the terminator
					command_buffer[command_len] = 0;
					
					// Execute the command
					console_execute_buffer();
				}
				
				// Clear the command buffer
				command_len = 0;
			} else if (ch == 8 || ch == 0x7f)
			{
				// Backspace
				if (command_len)
				{
					putchar(8);
					putchar(32);
					putchar(8);
					flush_stdout();
					--command_len;
				}
				continue;
			} else {
				if (ch >= 0x20 && ch <= 0x7e && command_len < MAX_COMMAND_SIZE)
				{
					// Add to command buffer
					command_buffer[command_len++] = ch;
					putchar(ch);
					flush_stdout();
				}
				continue;
			}
			print_prompt();
		}
		
		// Clear the buffer and keep reading
		usb_rx_start();
	}
	
	return ret;
}