예제 #1
0
/**
 * Writes the given character to stdout.
 * The character is casted to unsigned char.
 *
 * @param character The character for writing
 * @return The character written as unsigned char cast to int
 *
 */
int32_t putchar(int32_t character)
{
  uint8_t output_char = (uint8_t)character;
#ifdef FRAMEBUFFER_H
  if(!std_output)
    uartPutc(output_char);
  else
    consoleWriteChar(output_char);
#else
  uartPutc(output_char);
#endif
  return (int32_t)output_char;
}
예제 #2
0
파일: main.c 프로젝트: keeepcool/Backup
static bool appDataInd(NWK_DataInd_t *ind){
	
	for (uint8_t i = 0; i < ind->size; i++){
		uartPutc((char)ind->data[i]);
	}
	return true;
}
예제 #3
0
/**
 * Read into a buffer from the UART.
 * @param devptr UART device table entry
 * @param buf buffer to read bytes into
 * @param len size of the buffer
 * @return count of bytes read
 */
devcall uartRead(device *devptr, void *buf, uint len)
{
  int i;
  uchar * buffer = buf;
  for(i = 0; i < len; i++){
    buffer[i] = getc(SERIAL1);
  }
      return OK;
#if 0
    irqmask im;
    int count = 0;
    char c;
    struct uart *uartptr;
    uchar *buffer = buf;

    uartptr = &uarttab[devptr->minor];

    im = disable();

    /* If in non-blocking mode, ensure there is */
    /* enough input for the entire read request */
    if ((uartptr->iflags & UART_IFLAG_NOBLOCK)
        && (semcount(uartptr->isema) < len))
    {
        restore(im);
        return SYSERR;
    }

    /* Put each character into the buffer from the input buffer */
    while (count < len)
    {
        /* If in non-blocking mode, ensure there is another byte of input */
        if ((uartptr->iflags & UART_IFLAG_NOBLOCK)
            && (semcount(uartptr->isema) < 1))
        {
            break;
        }

        /* Wait for input and read character from the  */
        /* input buffer; Preserve the circular buffer  */
        wait(uartptr->isema);
        c = uartptr->in[uartptr->istart];
        *buffer++ = c;
        uartptr->icount--;
        uartptr->istart = (uartptr->istart + 1) % UART_IBLEN;
        count++;

        /* If echo is enabled, echo the character */
        if (uartptr->iflags & UART_IFLAG_ECHO)
        {
	   uartPutc(uartptr->dev, c);
        }
    }

    restore(im);
    return count;
#endif // if 0
}
예제 #4
0
/**
 * Writes the given string to stdout.
 *
 * @param output_string The string for writing
 * @return A non-negative number on success
 *
 */
int32_t puts(const char* output_string)
{
  int32_t string_length = 0;

  while(output_string && *output_string)
  {
#ifdef FRAMEBUFFER_H
    if(!std_output)
      uartPutc(*output_string++);
    else
      consoleWriteChar(*output_string++);
#else
    uartPutc(*output_string++);
#endif
    ++string_length;
  }

  return string_length;
}
예제 #5
0
void uartSend(char* data, int len)
{
  if (!isInit)
      return;

  while(len--)
  {
    uartPutc(*data++);
  }
}
예제 #6
0
void uartPuts(char* string)
{
  if (!isInit)
      return;

  while(*string)
  {
    uartPutc(*string++);
  }
}
예제 #7
0
/**
 * @ingroup uartgeneric
 *
 * Reads data from a UART.
 *
 * @param devptr
 *      Pointer to the device table entry for a UART.
 * @param buf
 *      Pointer to a buffer into which to place the read data.
 * @param len
 *      Maximum number of bytes of data to read.
 *
 * @return
 *      On success, returns the number of bytes read, which normally is @p len,
 *      but may be less than @p len if the UART has been set to non-blocking
 *      mode.  Returns SYSERR on other error (currently, only if uartInit() has
 *      not yet been called).
 */
devcall uartRead(device *devptr, void *buf, uint len)
{
    irqmask im;
    struct uart *uartptr;
    uint count;
    uchar c;

    /* Disable interrupts and get a pointer to the UART structure.  */
    im = disable();
    uartptr = &uarttab[devptr->minor];

    /* Make sure uartInit() has run.  */
    if (NULL == uartptr->csr)
    {
        restore(im);
        return SYSERR;
    }

    /* Attempt to read each byte requested.  */
    for (count = 0; count < len; count++)
    {
        /* If the UART is in non-blocking mode, ensure there is a byte available
         * in the input buffer from the lower half (interrupt handler).  If not,
         * return early with a short count.  */
        if ((uartptr->iflags & UART_IFLAG_NOBLOCK) && uartptr->icount == 0)
        {
            break;
        } else if (uartptr->iflags & UART_IFLAG_BLOCK){
            c = uartHwGetc(uartptr->csr);
            ((uchar*)buf)[count] = c;
//            uartPutc(uartptr->dev, c);
            continue;
        }

        /* Wait for there to be at least one byte in the input buffer from the
         * lower half (interrupt handler), then remove it.  */
        wait(uartptr->isema);
        c = uartptr->in[uartptr->istart];
        ((uchar*)buf)[count] = c;
        uartptr->icount--;
        uartptr->istart = (uartptr->istart + 1) % UART_IBLEN;

        /* If the UART is in echo mode, echo the byte back to the UART.  */
        if (uartptr->iflags & UART_IFLAG_ECHO)
        {
            uartPutc(uartptr->dev, c);
        }
    }

    /* Restore interrupts and return the number of bytes read.  */
    restore(im);
    return count;
}
예제 #8
0
파일: main.c 프로젝트: tgfuellner/Basteln
static void uartPuts (char *s) {
    while (*s) {
        uartPutc(*s);
        s++;
    }
}
예제 #9
0
파일: oddebug.c 프로젝트: Moetoeng/PSGroove
static void uartPuts(char *msg)
{
   uchar len = strlen(msg);
   while(len--) 
      uartPutc(*msg++);
}