Beispiel #1
0
void main(void)
{
  int cdc_in;
  int uart_in; 
  volatile UINT8 u8Error;
  
  PTBPE_PTBPE5 = 1;                     // DEMOFLEXISJMSD board 
  PTBDD_PTBDD5 = _IN;                     // Initialize Button in 

  hw_init();                            /* MCU Initialization */
  SPI_Init();                           /* SPI Module Init */
  u8Error=SD_Init();                    /* SD Card Init */
  FAT_Read_Master_Block();              /* FAT Driver Init */
  
  cdc_in=uart_in=0xff+1;                /* USB CMX Init */
  usb_cfg_init();
  cdc_init();


  while(PTBD_PTBD5);                    /* Wait until button clic */  
  CDC_Send_String("\r\n\r\n\tSD Card Terminal\r\n");  
  

  while(1)
  {
    cdc_process();                      /* USB CMX CDC process */
    FAT_LS();                           /* Simple function that shows the content*/
    MiniCom();                          /* User Interface call */
  }
}
Beispiel #2
0
/*****************************************************************************
* Name:
*    cdc_putch
* In:
*    c: character to be sent
* Out:
*    0: output is busy, character dropped
*    1: character buffered and will be sent later.
*
* Description:
*    Put one character into tx_buffer.
*
* Assumptions:
*    --
*****************************************************************************/
unsigned char cdc_putch(char c)
{
  uint_8 r=(unsigned char)c;
  /* Store character into current buffer. */
  if (g_send_size < sizeof(g_curr_send_buf))
  {
	g_curr_send_buf[g_send_size++]=(unsigned char)c;
    if (c == '\r')
    {
      cdc_process();
    }	
  }
  else
  {
    cdc_process();
    r++;
  }
  return((uint_8)r);
}
Beispiel #3
0
void CDC_Send_Buffer(unsigned char *Array_to_send,unsigned int u16Size)
{
  unsigned int u16Counter=0;

	while(u16Size--)
	{
		while(*Array_to_send != (char)cdc_putch(*Array_to_send));
		Array_to_send++;
		cdc_process();
	}
}
Beispiel #4
0
void CDC_Send_String(unsigned char *Array_to_send)
{
  while(*Array_to_send!='\0')
	{
	  // if called while no usb is hooked up, usb buffer will get full and cause
	  // this to loop indefinitely
	  while(*Array_to_send != (char)cdc_putch(*Array_to_send));
		Array_to_send++;
		cdc_process();
	}
	delay_ms(25); // KP
}
Beispiel #5
0
/*****************************************************************************
* Name:
*    cdc_putch
* In:
*    c: character to be sent
* Out:
*    0: output is busy, character dropped
*    1: character buffered and will be sent later.
*
* Description:
*    Put one character into tx_buffer.
*
* Assumptions:
*    --
*****************************************************************************/
int cdc_putch(char c)
{
  unsigned int r=(unsigned char)c;
  /* Store character into current buffer. */
  if (tx_ndx < sizeof(tx_buffer1))
  {
    cur_tx_buffer[tx_ndx++]=(hcc_u8)c;
  }
  else
  {
    cdc_process();
    r++;
  }
  return((int)r);
}
Beispiel #6
0
void Comm2PC_Task(void)
{
  CHAR8 c;  
  
  /* configure USB and init CDC driver */
  usb_cfg_init();
  cdc_init();    
  
  /* This loop will receive and process characters from the USB. */
  for(;;)
  {  
    while((*cdc_kbhit)())         
    {
      c=(CHAR8)(*cdc_getch)();
      Comm2PC_FSM(c);
    }
    cdc_process();
    OSSemPend(USB_Sem,0);    
  }  
}
Beispiel #7
0
/*-----------------------------------------------------------------------------------*/
void
slip_arch_writeb(unsigned char c)
{
#if (SLIP_COMM == SLIP_USB)
	while(GetStart_transactions() == FALSE)
	{
		DelayTask(10);
	}
	while(cdc_putch(c) != c)
	{
		//DelayTask(1);
	}
	if (c==SLIP_END)
	{
		cdc_process();
	}
#elif (SLIP_COMM == SLIP_UART)
	uart_putchar(UART_NUMBER, (char)c);
#endif

	buffer_send[buffer_send_i++]=c;
	
}
Beispiel #8
0
/*****************************************************************************
* Name:
*    cdc_kbhit
* In:
*    N/A
*
* Out:
*    N/A
*
* Description:
*    Will return one, if the rx_buffer contains any unread characters.
*
* Assumptions:
*    This function is called periodicaly. (Otherwise usb_receive call will
*    not bee made, and no data will ge received over the USB.)
*****************************************************************************/
int cdc_kbhit(void)
{
  cdc_process();
  /* If the receive buffer is not empty retun 1. */
  return(rx_length > rx_ndx);
}
Beispiel #9
0
/*****************************************************************************
* Name:
*    terminal_proces
* In:
*    N/A
*
* Out:
*    N/A
*
* Description:
*    Main loop of terminal application. gathers input, and executes commands.
*
* Assumptions:
*    --
*****************************************************************************/
void usb_terminal_process(void)
{
    INT8U data;
    char c;

    while(1)
    {
        (void)OSQueuePend(USB, &data, 0);
        c=(char)data;

        if ((c != '\n') && (c != '\r'))
        {
            if (c != 0x7F)
            {
                if (SilentMode == FALSE)
                {
                    while(c!=(char)(*putch)(c)) {};
                }
            } else
            {
                if (usb_cmd_line_ndx)
                {
                    while(c!=(char)(*putch)(c)) {};
                }
            }
        }

        /* Execute command if enter is received, or usb_cmd_line is full. */
        if ((c=='\r') || (usb_cmd_line_ndx == sizeof(usb_cmd_line)-2))
        {
            int usb_start = usb_skipp_space(usb_cmd_line, 0);
            int usb_end = usb_find_word(usb_cmd_line, usb_start);
            int usb_x;

            /* Separate command string from parameters, and close
               parameters string. */
            usb_cmd_line[usb_end]=usb_cmd_line[usb_cmd_line_ndx]='\0';

            /* Identify command. */
            usb_x=usb_find_command(usb_cmd_line+usb_start);

            /* Command not found. */
            if (usb_x == -1)
            {
                print_usb("\r\nUnknown command!\r\n");
            }
            else
            {
                (*usb_cmds[usb_x]->func)(usb_cmd_line+usb_end+1);
            }
            usb_cmd_line_ndx=0;
            usb_print_prompt();
            SetSilentMode(FALSE);
        }
        else
        {   /* Put character to usb_cmd_line. */
            if (c=='\b')
            {
                if (usb_cmd_line_ndx > 0)
                {
                    usb_cmd_line[usb_cmd_line_ndx]='\0';
                    usb_cmd_line_ndx--;
                }
            }
            else if(c=='\n') {
                continue;
            }
            else
            {
                if (c == 0x7F)
                {
                    if (usb_cmd_line_ndx)
                    {
                        usb_cmd_line[usb_cmd_line_ndx]=0;
                        usb_cmd_line_ndx--;
                        usb_cmd_line[usb_cmd_line_ndx]=0;
                    }
                } else
                {
                    usb_cmd_line[usb_cmd_line_ndx++]=c;
                }
            }
        }

        if (SilentMode == FALSE)
        {
            cdc_process();
        }
    }
}