Files
There are no circuits or boards in this repository.
Last update 3 years 1 month
by
ddr2
Filessend_code | |
---|---|
.. | |
Makefile | |
diskio.c | |
diskio.h | |
ff.c | |
ff.h | |
ffconf.h | |
main.c | |
mmc_avr.h | |
mmc_avr_spi.c | |
uart.c | |
uart.h |
uart.c#include <avr/io.h> #include <stdio.h> #ifndef BAUD #define BAUD 9600 #endif #include <util/setbaud.h> #include "uart.h" FILE uart_output = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); //FILE uart_input = FDEV_SETUP_STREAM(NULL, uart_getchar, _FDEV_SETUP_READ); void uart_init(void) { UBRR0H = UBRRH_VALUE; UBRR0L = UBRRL_VALUE; UCSR0C = _BV(UCSZ01) | _BV(UCSZ00); /* 8-bit data */ //UCSR0B = _BV(RXEN0) | _BV(TXEN0); /* Enable RX and TX */ UCSR0B = _BV(TXEN0); /* Enable TX */ stdout = &uart_output; //stdin = &uart_input; } int uart_putchar(char c, FILE *stream) { loop_until_bit_is_set(UCSR0A, UDRE0); UDR0 = c; return (0); } /* int uart_getchar(FILE *stream) { loop_until_bit_is_set(UCSR0A, RXC0); return (UDR0); } */