1
0
mirror of synced 2024-11-28 04:04:23 +01:00
avr_demo/blog/simple_usart/main.c

37 lines
707 B
C
Raw Normal View History

/*
* Demonstration on how to redirect stdio to UART.
*
* http://appelsiini.net/2011/simple-usart-with-avr-libc
*
* To compile and upload run: make clean; make; make program;
* Connect to serial with: screen /dev/tty.usbserial-*
*
* Copyright 2011 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
*/
#include <stdio.h>
#include "main.h"
#include "uart.h"
int main(void) {
uart_init();
stdout = &uart_output;
stdin = &uart_input;
char input;
while(1) {
puts("Hello world!");
input = getchar();
printf("You wrote %c\n", input);
}
return 0;
}