source: rtems/bsps/sparc/shared/uart/apbuart_polled.c @ 31720925

5
Last change on this file since 31720925 was 31720925, checked in by Sebastian Huber <sebastian.huber@…>, on 12/22/18 at 06:13:44

grlib: Move header files

Update #3678.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 2010.
3 *  Cobham Gaisler AB.
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#include <grlib/apbuart.h>
11
12void apbuart_outbyte_polled(
13  struct apbuart_regs *regs,
14  unsigned char ch,
15  int do_cr_on_newline,
16  int wait_sent
17)
18{
19send:
20  while ( (regs->status & APBUART_STATUS_TE) == 0 ) {
21    /* Lower bus utilization while waiting for UART */
22    __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
23    __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
24    __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
25    __asm__ volatile ("nop"::); __asm__ volatile ("nop"::);
26  }
27
28  if ((ch == '\n') && do_cr_on_newline) {
29    regs->data = (unsigned int) '\r';
30    do_cr_on_newline = 0;
31    goto send;
32  }
33  regs->data = (unsigned int) ch;
34
35  /* Wait until the character has been sent? */
36  if (wait_sent) {
37    while ((regs->status & APBUART_STATUS_TE) == 0)
38      ;
39  }
40}
41
42int apbuart_inbyte_nonblocking(struct apbuart_regs *regs)
43{
44  /* Clear errors */
45  if (regs->status & APBUART_STATUS_ERR)
46    regs->status = ~APBUART_STATUS_ERR;
47
48  if ((regs->status & APBUART_STATUS_DR) == 0)
49    return -1;
50  else
51    return (int) regs->data;
52}
Note: See TracBrowser for help on using the repository browser.