Go to file
Jake Goodwin f4aef61b0e Decided to not use defines everywhere, instead making user accessable functions for runtime use. 2023-01-16 20:10:53 -08:00
.gitignore updated to ignore binary stuff. 2023-01-13 22:57:03 -08:00
LICENSE Initial commit 2023-01-14 06:51:49 +00:00
Makefile updated makefile for correct 328p fuses 2023-01-16 19:42:53 -08:00
README.md updated example in readme for new interface 2023-01-15 14:37:57 -08:00
avr_usart.c Decided to not use defines everywhere, instead making user accessable functions for runtime use. 2023-01-16 20:10:53 -08:00
avr_usart.h Decided to not use defines everywhere, instead making user accessable functions for runtime use. 2023-01-16 20:10:53 -08:00

README.md

AVR_ATMEGA_USART


Description:

This is a asynchronous serial program for the ATMEGA seiries of mcu. The sotfware is tested and working.

Over time, I'm planning to add support for multiple AVR MCUs, however that may end up requiring more memory, so extensive of use of define macros will likely end up being the end result.

Features:

  • Multiple Baud Rates: 300, 600, 1200, 2400, 9600 ...
  • Asynchronous Receive and Transmit.
  • Optional Parity checking.
  • 7-8 data bits.
  • Hardware abstraction API
  • No Interrupt service routines required.
  • BSD-3 Licensing, aka you can use this for whatevery you want pretty much.

Instructions

Example 1

#include "avr_usart.h"

/*
 *Description: Echos a single char back to the term.
 */
void echo_char(char* cmd) {
    init_usart();
    
    unsigned char data[1] = "0";
    uint8_t data_len = 1;

    //clear the buffer
    serial0_flush_rxbuf();

    //receive the char.
    serial0_read(data, data_len);

    //Now echo it.
    serial0_write(data, data_len);
}

int main() {
    while(1) {
        echo_char();
    }
}

ISSUES:

It's required to set the fuses in the chip for 8Mhz, otherwise a baud rate of 9600 will result in errors at a 7% rate.

Another is that I need to design a standard naming scheme.