Skip to content

Library for working with the UART on the ATmega328/P.

License

Notifications You must be signed in to change notification settings

VasilKalchev/ATmega328_UART

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ATmega328 UART

Download Documentation License

Library for the UART on the ATmega328/P.

Table of Contents

Features

  • Polling implementation
  • Interrupts implementation
  • Formatted IO streams implementation

Prerequisites

  • ATmega328/P
  • AVR-GCC

Getting started


Building and uploading using one of the provided Makefiles 📃

Prerequisites: AVR-GCC and Make

Building ATmega328_UART to a static library

  • Open .../ATmega328_UART/Makefile and edit the variables: $HOST_PLATFORM, $F_CPU and $UART_BAUD.
  • Execute > make inside .../ATmega328_UART/ to recompile the library according to the specified frequency and baud rate.

The library must be recompiled every time $F_CPU and/or $UART_BAUD variables are changed!

Building and uploading an example

  • Open the Makefile that is in the root directory of the chosen example (e.g. /ATmega328_UART/examples/IO_streams/Makefile) and edit the variables: $HOST_PLATFORM, $F_CPU, $PROGRAMMER and $PORT.
  • Execute > make inside the same directory to build the example.
  • And finally execute > make program to upload it to the AVR target.

Building and uploading a new project using one of the example's Makefile

This is the same as 'Building and uploading an example' except that the Makefile should be configured for the new project (e.g. the target name, the new location of the library, etc).


Building and uploading manually 🔧

The library can be compiled and linked to a project using a different build system (e.g. a user's Makefile, an IDE, etc). The location of the header file is .../ATmega328_UART/include/ATmega328_UART.h and the location of the source file is ../ATmega328_UART/src/ATmega328_UART.c.

F_CPU and BAUD macros must be defined.

The library must be recompiled every time F_CPU and/or BAUD macros are changed!

When using formatted IO streams, the libraries printf and/or scanf should be linked1. AVR-GCC linker flags:

  • -Wl,-u,vfprintf -lprintf_min
  • -Wl,-u,vfprintf -lprintf_flt -lm
  • -Wl,-u,vfscanf -lscanf_min
  • -Wl,-u,vfscanf -lscanf_flt -lm

License

The MIT License (MIT)

Copyright (c) 2019 Vasil Kalchev

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


1. avr-libc: <stdio.h> documentation

About

Library for working with the UART on the ATmega328/P.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages