4 This test case enables uart RX interupts, does a "printf" and then receive characters
5 via the interupt handler until it reaches a \r.
7 This tests the uart reception fifo system. It relies on the uart "irq" input and output
8 to be wired together (see simavr.c)
13 #include <avr/interrupt.h>
14 #include <avr/eeprom.h>
15 #include <avr/sleep.h>
18 * This demonstrate how to use the avr_mcu_section.h file
19 * The macro adds a section to the ELF file with useful
20 * information for the simulator
22 #include "avr_mcu_section.h"
23 AVR_MCU(F_CPU, "atmega88");
24 // tell simavr to listen to commands written in this (unused) register
25 AVR_MCU_SIMAVR_COMMAND(&GPIOR0);
27 static int uart_putchar(char c, FILE *stream) {
29 uart_putchar('\r', stream);
30 loop_until_bit_is_set(UCSR0A, UDRE0);
35 static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,
38 volatile uint8_t bindex = 0;
40 volatile uint8_t done = 0;
53 // this tell simavr to put the UART in loopback mode
54 GPIOR0 = SIMAVR_CMD_UART_LOOPBACK;
59 UCSR0B |= (1 << RXCIE0) | (1 << RXEN0) | (1 << TXEN0);
62 printf("Hey there, this should be received back\n");
68 printf("Received: %s", buffer);
70 // this quits the simulator, since interupts are off
71 // this is a "feature" that allows running tests cases and exit