src/uart_support.c
void cgets(uint32_t port,char *s, int bufsize)
{
  char *p;
  int c;

  memset(s, 0, bufsize);

  p = s;

  for (p = s; p < s + bufsize-1;)
  {
    /* 20090521Nemui */
	do{		
		c = getch_p(port);
	}while(c == false);
	/* 20090521Nemui */
    switch (c)
    {
      case '\r' :
      case '\n' :
        putch_p(port,'\r');
        putch_p(port,'\n');
        *p = '\n';
        return;

      case '\b' :
        if (p > s)
        {
          *p-- = 0;
          putch_p(port,'\b');
          putch_p(port,' ');
          putch_p(port,'\b');
        }
        break;

      default :
        putch_p(port,c);
        *p++ = c;
        break;
    }
  }

  return;
}
/**************************************************************************/
/* Receive a string, with rudimentary line editing */
Receive a string, with rudimentary line editing
Receive a string with rudimentary line editing
void cgets(uint32_t port,char *s, int bufsize)
{
  char *p;
  int c;
  memset(s, 0, bufsize);
  p = s;
  for (p = s; p < s + bufsize-1;)
  {
	do{		
		c = getch_p(port);
	}while(c == false);
    switch (c)
    {
      case '\r' :
      case '\n' :
        putch_p(port,'\r');
        putch_p(port,'\n');
        *p = '\n';
        return;
      case '\b' :
        if (p > s)
        {
          *p-- = 0;
          putch_p(port,'\b');
          putch_p(port,' ');
          putch_p(port,'\b');
        }
        break;
      default :
        putch_p(port,c);
        *p++ = c;
        break;
    }
  }
  return;
}
void cgets ( uint32_t port , char * s , int bufsize ) { char * p ; int c ; memset ( s , 0 , bufsize ) ; p = s ; for ( p = s ; p < s + bufsize - 1 ; ) { do { c = getch_p ( port ) ; } while ( c == false ) ; switch ( c ) { case ' \r ' : case ' \n ' : putch_p ( port , ' \r ' ) ; putch_p ( port , ' \n ' ) ; * p = ' \n ' ; return ; case ' \b ' : if ( p > s ) { * p -- = 0 ; putch_p ( port , ' \b ' ) ; putch_p ( port , ' ' ) ; putch_p ( port , ' \b ' ) ; } break ; default : putch_p ( port , c ) ; * p ++ = c ; break ; } } return ; }
Receive a string, with rudimentary line editing
Receive a string with rudimentary line editing
/* 20090521Nemui */ /* 20090521Nemui */