• Stars
    star
    156
  • Rank 239,589 (Top 5 %)
  • Language
    C
  • License
    Other
  • Created over 12 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An interrupt driven UART Library for 8-bit AVR microcontrollers. Uses built-in UART with circular transmit and receive buffers.

avr-uart

An interrupt driven UART Library for 8-bit AVR microcontrollers.

Maintained by Andy Gock.

https://github.com/andygock/avr-uart

Derived from original library by Peter Fleury.

Interrupt driven UART library using the built-in UART with circular transmit and receive buffers.

An interrupt is generated when the UART has finished transmitting or receiving a byte. The interrupt handling routines use circular buffers for buffering received and transmitted data.

Setting up

Define USARTs enabled and buffer sizes

The UART_RXn_BUFFER_SIZE and UART_TXn_BUFFER_SIZE symbols define the size of the circular buffers in bytes. These values must be a power of 2. You may need to adapt this symbols to your target and your application by adding into your compiler options:

-DUART_RXn_BUFFER_SIZE=nn -DUART_TXn_BUFFER_SIZE=nn

RXn and TXn refer to the UART number, for UART3 with 128 byte buffers, add:

-DUART_RX3_BUFFER_SIZE=128 -DUART_TX3_BUFFER_SIZE=128

UART0 is always enabled by default, to enable the other available UARTs, add the following to your compiler's symbol options for the relevant UART (also known as USART) number.

-DUSART1_ENABLED -DUSART2_ENABLED -DUSART3_ENABLED

To enable large buffer support (over 256 bytes, up to 2^15 bytes) use:

-DUSARTn_LARGE_BUFFER

Where n is the USART number. The maximum buffer size is 32768 bytes.

This library supports AVR devices with up to 4 hardware USARTs.

Define CPU frequency

Define F_CPU in your Makefile or compiler examples. Example, if you're running a 8 MHz clock, then use:

-DF_CPU=8000000UL

Compiler flags

AVR/GNU C compiler requires the -std=gnu99 flag.

Documentation

Doxygen based documentation can be viwed at:

Notes

Buffer overflow behaviour

When the RX circular buffer is full, and it receives further data from the UART, a buffer overflow condition occurs. Any new data is dropped. The RX buffer must be read before any more incoming data from the UART is placed into the RX buffer.

If the TX buffer is full, and new data is sent to it using one of the uartN_put*() functions, this function will loop and wait until the buffer is not full any more. It is important to make sure you have not disabled your UART transmit interrupts (TXEN*) elsewhere in your application (e.g with cli()) before calling the uartN_put*() functions, as the application will lock up. The UART interrupts are automatically enabled when you use the uartN_init() functions. This is probably not the idea behaviour, I'll probably fix this some time.

For now, make sure TXEN* interrupts are enabled when calling uartN_put*() functions. This should not be an issue unless you have code elsewhere purposely turning it off.

More Repositories

1

glcd

Graphic LCD Library for microcontrollers based embedded systems. Compatible with chipsets PCD854, ST7565R, NTD75451 and many AVR, LPC, PIC, STM32 devices.
C
87
star
2

auth-server

A very simple standalone authentication server Express app. Designed to be used with NGINX sub request authentication.
JavaScript
30
star
3

chordy-svg

Node JS module for generating guitar chord diagrams in SVG format. Interval names are shown inside the dotted positions.
JavaScript
23
star
4

Thermocouple

Python script to convert thermocouple voltages to temperatures and vice versa
Python
7
star
5

diff-text

A web app for visually comparing two portions of text, compatible with common spreadsheet formats.
JavaScript
5
star
6

glcd-utils

glcd-utils
C++
4
star
7

password-generator-v2

A passphrase / password generator running in the web browser using the EFF word lists.
JavaScript
2
star
8

DFR_LCD_Keypad

Keyboard library for DFRobot LCD Keypad Arduino Shield DFR0009
C++
2
star
9

hoc-compose

Single neat compose() function used in place of multiple nested higher order component code.
JavaScript
2
star
10

accucel_logger

accucel_logger
Python
2
star
11

mail-gateway

REST API gateway to send email messages with Nodemailer. ExpressJS app.
JavaScript
2
star
12

svelte-dropzone-textarea

Svelte
1
star
13

MAX31855

MAX31855 Library for Arduino
C++
1
star
14

thermocouple-converter

A JavaScript module for thermocouple voltage to temperature conversions.
JavaScript
1
star
15

react-dropzone-textarea

React component of a textarea element. Drop text files onto the element and load file contents as textarea's value.
JavaScript
1
star
16

password-generator

A browser based password / passphrase generator based on EFF's word lists.
JavaScript
1
star
17

jsi-client

Unofficial justseed.it CLI client written in Python. Very early testing stages.
Python
1
star
18

andygock.github.io

HTML
1
star
19

stable-diffusion-style-cheatsheet

A stand alone web site to guide users on different styling prompts for Stable Diffusion relating to fashion styling, hair and make up.
JavaScript
1
star
20

realclock

A minimalistic accurate clock written in ReactJS. Shows the exact real time even if your local time is incorrect. It fetches the correct time from WorldTimeAPI and compensates for network latency.
JavaScript
1
star