avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AVR-GCC-list Digest, Vol 157, Issue 2


From: Bob von Knobloch
Subject: Re: AVR-GCC-list Digest, Vol 157, Issue 2
Date: Tue, 11 Feb 2020 13:31:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 08/02/2020 18:00, address@hidden wrote:
Send AVR-GCC-list mailing list submissions to
        address@hidden

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
or, via email, send a message with subject or body 'help' to
        address@hidden

You can reach the person managing the list at
        address@hidden

When replying, please edit your Subject line so it is more specific
than "Re: Contents of AVR-GCC-list digest..."


Today's Topics:

    1. Re: Where is the error (stdout) (Col)
    2. Re: Where is the error (stdout) (David Kelly)


----------------------------------------------------------------------

Message: 1
Date: Sat, 8 Feb 2020 12:58:19 +1300
From: Col <address@hidden>
To: address@hidden
Subject: Re: Where is the error (stdout)
Message-ID: <address@hidden>
Content-Type: text/plain; charset=utf-8; format=flowed



void uart_putchar(char c, FILE *stream)
{
  if (c == '\n')
uart_putchar('\r', stream);
  loop_until_bit_is_set(UCSRA, UDRE);
  UDR = c;
  return ;
}

I suspect it's because your returning a void instead of an int,

Here is some code that I used to test stdio on avrlibc ( atmega128 )

which compiles fine with gcc 5.4.0


static int uart_putchar(char c, FILE *stream)
{
      if (c == '\n')
          uart_putchar('\r', stream);
      loop_until_bit_is_set(UCSR0A, UDRE);
      UDR0 = c;
      return 0;
}




Cheers

Colin





------------------------------

Message: 2
Date: Fri, 7 Feb 2020 18:56:41 -0600
From: David Kelly <address@hidden>
To: address@hidden
Subject: Re: Where is the error (stdout)
Message-ID: <address@hidden>
Content-Type: text/plain;       charset=us-ascii


On Feb 7, 2020, at 5:58 PM, Col <address@hidden> wrote:

void uart_putchar(char c, FILE *stream)
{
  if (c == '\n')
uart_putchar('\r', stream);
  loop_until_bit_is_set(UCSRA, UDRE);
  UDR = c;
  return ;
}

I suspect it's because your returning a void instead of an int,

In Unix convention its

        int putc( int, FILE* )
        int putchar( int )

Where upon success one returns the character put or -1 or EOF for failure. If 
replacing standard function one should return the expected value else something 
will break.

--
David Kelly N4HHE, address@hidden
============================================================
Whom computers would destroy, they must first drive mad.




------------------------------

Subject: Digest Footer

_______________________________________________
AVR-GCC-list mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list


------------------------------

End of AVR-GCC-list Digest, Vol 157, Issue 2
********************************************


I use a similar function on a Mega1284:

/**
 *******************************************************************************
 *      Wait until USART free, then send character to the terminal.
 *      Pad LF to CR,LF.
 *******************************************************************************
 */

static void term_putchar(uint8_t c)
{
    if (c == '\n')
        term_putchar('\r');
    loop_until_bit_is_set(UCSR0A, UDRE0);
    UDR0 = c;
}

Compiles and works fine (for me), possible the spurious 'return;' is doing 
something that the compiler doesn't like (need a GCC guru).

Cheers,
Bob






reply via email to

[Prev in Thread] Current Thread [Next in Thread]