On Thu, Mar 12, 2009 at 2:18 PM, Joel Sherrill
<[email protected]> wrote:
> <blush> thanks for the plug.
>
> <hint> we need context switch code to help finish the AVR port. :)

I should look into that because I've got a little project going on
that is in danger of using nested interrupt handlers. From what I've
read, that's a good indication that I should start looking at an RTOS.

> Right but this time I am just doing simple bare metal
> with avr-libc.  I am so used to how newlib does it that
> I have to be retrained. :)

The avr-libc stdio page is a good read. That's where I go every time I
have to be reminded of how to use printf on an avr. But try this on
for size:

#include <stdio.h>

static int uart_putchar(char c, FILE *stream);

static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE);

static int
uart_putchar(char c, FILE *stream)
{

  if (c == '\n')
    uart_putchar('\r', stream);
  loop_until_bit_is_set(UCSRA, UDRE);
  UDR = c;
  return 0;
}

int
main(void)
{
  init_uart();
  stdout = &mystdout;
  printf_P("Hello, world!\n");

  return 0;
}


-- 
GDB has a 'break' feature; why doesn't it have 'fix' too?


_______________________________________________
Simulavr-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/simulavr-devel

Reply via email to