Asynchronous UART example.
This commit is contained in:
parent
5bf932c6f5
commit
7aa4de63c6
5 changed files with 650 additions and 0 deletions
46
hello_uart_async/main.c
Normal file
46
hello_uart_async/main.c
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Test how to use uart stuff as an outside library. Redirects stdout
|
||||
* to uart.
|
||||
*
|
||||
* Led at Arduino digital 13 (PORTB5). Cause we all love blinken leds!
|
||||
*
|
||||
* To compile and upload run: make clean; make; make program;
|
||||
* Connect to serial with: screen /dev/tty.usbserial-* 9600
|
||||
*
|
||||
* Copyright 2011 Mika Tuupola
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef F_CPU
|
||||
#define F_CPU 16000000UL
|
||||
#endif
|
||||
|
||||
//#include <stdlib.h>
|
||||
#include <avr/io.h>
|
||||
#include <stdio.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "uart.h"
|
||||
|
||||
int main(void) {
|
||||
|
||||
uart_init();
|
||||
stdout = &uart_output;
|
||||
stdin = &uart_input;
|
||||
|
||||
while (1) {
|
||||
/* Blink led by toggling state of PORTB5 (Arduino digital 13). */
|
||||
PORTB ^= _BV(PORTB5);
|
||||
|
||||
puts("Hello async world!");
|
||||
|
||||
_delay_ms(500);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue