Simple implementation of an command-interface. More...
#include <avr\io.h>
#include <avr\interrupt.h>
Go to the source code of this file.
Defines | |
#define | _AVR_USART_H |
#define | _XTAL F_CPU+'UL' |
#define | _AVR_USART_UBRR_CALC(_BAUD) (((_XTAL)/((_BAUD)*16UL))-1) |
#define | _AVR_USART_ENABLE_TRANSMIT() UCSRB |= ( 1 << TXEN ) |
#define | _AVR_USART_DISABLE_TRANSMIT() UCSRB &= ~( 1 << TXEN ) |
#define | _AVR_USART_ENABLE_RECEIVE() UCSRB |= ( 1 << RXEN ) |
#define | _AVR_USART_DISABLE_RECEIVE() UCSRB &= ~( 1 << RXEN ) |
#define | _AVR_USART_ENABLE_RECV_IRQ() UCSRB |= ( 1 << RXCIE ) |
#define | _AVR_USART_DISABLE_RECV_IRQ() UCSRB &= ~( 1 << RXCIE ) |
#define | _AVR_USART_ENABLE_TRANS_IRQ() UCSRB |= ( 1 << TXCIE ) |
#define | _AVR_USART_DISABLE_TRANS_IRQ() UCSRB &= ~( 1 << TXCIE ) |
#define | _AVR_USART_MODE_SYNCHRONOUS() UCSRC |= ( 1<<UMSEL) |
#define | _AVR_USART_MODE_ASYNCHRONOUS() UCSRC &= ~( 1<<UMSEL) |
#define | _AVR_USART_SET_PARITY_NONE() UCSRC &= ~((1<<UPM0)|(1<<UPM1)) |
#define | _AVR_USART_SET_PARITY_EVEN() _AVR_USART_SET_PARITY_NONE(); UCSRC |= ( 1<<UMSEL) |
#define | _AVR_USART_SET_PARITY_ODD() _AVR_USART_SET_PARITY_NONE(); UCSRC &= ~( 1<<UMSEL) |
#define | _AVR_USART_SET_DATABITS_TO_5() UCSRB &= ~(1<<UCSZ2); UCSRC &= ~(1<<UCSZ1)|(1<<UCSZ0) |
#define | _AVR_USART_SET_DATABITS_TO_6() _AVR_USART_SET_DATABITS_TO_5(); UCSRB|= (0<<UCSZ2); UCSRC |= (0<<UCSZ1)|(1<<UCSZ0) |
#define | _AVR_USART_SET_DATABITS_TO_7() _AVR_USART_SET_DATABITS_TO_5(); UCSRB|= (0<<UCSZ2); UCSRC |= (1<<UCSZ1)|(0<<UCSZ0) |
#define | _AVR_USART_SET_DATABITS_TO_8() _AVR_USART_SET_DATABITS_TO_5(); UCSRB|= (0<<UCSZ2); UCSRC |= (1<<UCSZ1)|(1<<UCSZ0) |
#define | _AVR_USART_SET_DATABITS_TO_9() _AVR_USART_SET_DATABITS_TO_5(); UCSRB|= (1<<UCSZ2); UCSRC |= (1<<UCSZ1)|(1<<UCSZ0) |
#define | _AVR_USART_SET_STOPPBITS_1() UCSRC &= ~(1<<USBS) |
#define | _AVR_USART_SET_STOPPBITS_2() UCSRC |= (1<<USBS) |
#define | _AVR_USART_SAMPLE_AT_POS_EDGE() UCSRC &= ~(1<<UCPOL) |
#define | _AVR_USART_SAMPLE_AT_NEG_EDGE() UCSRC |= (1<<UCPOL) |
Functions | |
void | avr_usart_init_9600_8_1_N_Asyn (void) |
void | avr_usart_putc (uint8_t data) |
sends a single byte | |
void | avr_usart_puts (char *s) |
transmits each character of a string terminated with null | |
uint8_t | avr_usart_getc_wait (void) |
wait till one char has been received | |
uint8_t | avr_usart_getc (void) |
checks whether something has been received | |
uint8_t | avr_usart_getc_isr (void) |
interrupt service routine to be used to receive characters in ISR |
Simple implementation of an command-interface.
Target/Compiler: AVR_MEGA / GCC(WinAVR)
Routines for the internal hardware UART.
\
#define _AVR_USART_ENABLE_RECEIVE | ( | ) | UCSRB |= ( 1 << RXEN ) |
Makro to enable reveive via USART-interface
#define _AVR_USART_ENABLE_RECV_IRQ | ( | ) | UCSRB |= ( 1 << RXCIE ) |
Makro to enable receive interrupt of USART-interface
#define _AVR_USART_ENABLE_TRANS_IRQ | ( | ) | UCSRB |= ( 1 << TXCIE ) |
Makro to enable transmit interrupt of USART-interface
#define _AVR_USART_ENABLE_TRANSMIT | ( | ) | UCSRB |= ( 1 << TXEN ) |
Makro to enable transmission via USART-interface
#define _AVR_USART_H |
precompiler help
#define _AVR_USART_MODE_SYNCHRONOUS | ( | ) | UCSRC |= ( 1<<UMSEL) |
Makro to set mode of USART-interface When Synchronous mode is used (UMSEL = 1), the XCK pin will be used as either clock input (Slave) or clock output (Master). The dependency between the clock edges and data sampling or data change is the same. The basic principle is that data input (on RxD) is sampled at the opposite XCK clock edge of the edge the data output (TxD) is changed.
#define _AVR_USART_SAMPLE_AT_POS_EDGE | ( | ) | UCSRC &= ~(1<<UCPOL) |
Makro to define at which edge of the XCK-signal the datasignal shall be sampled in synchronous mode.
#define _AVR_USART_SET_DATABITS_TO_5 | ( | ) | UCSRB &= ~(1<<UCSZ2); UCSRC &= ~(1<<UCSZ1)|(1<<UCSZ0) |
Makro to setup amount of databits for USART UCSZ2(in UCSRB), UCSZ1, UCSZ0 Datenbits 0 0 0 5 0 0 1 6 0 1 0 7 0 1 1 8 1 1 1 9
#define _AVR_USART_SET_PARITY_NONE | ( | ) | UCSRC &= ~((1<<UPM0)|(1<<UPM1)) |
Makro to set parity of USART-interface
#define _AVR_USART_SET_STOPPBITS_1 | ( | ) | UCSRC &= ~(1<<USBS) |
Makro to set number of stopp-bits used at the USART-interface
#define _AVR_USART_UBRR_CALC | ( | _BAUD | ) | (((_XTAL)/((_BAUD)*16UL))-1) |
Makro calculating required content of the USART Baud Rate Register (UBRR) in "SINGLE SPEED MODE"
uint8_t avr_usart_getc | ( | void | ) |
checks whether something has been received
void |
none
uint8_t avr_usart_getc_isr | ( | void | ) | [inline] |
interrupt service routine to be used to receive characters in ISR
void |
none
uint8_t avr_usart_getc_wait | ( | void | ) |
wait till one char has been received
void |
none
void avr_usart_putc | ( | uint8_t | data | ) |
sends a single byte
uint8_t | data - byte to be send |
none
void avr_usart_puts | ( | char * | s | ) |
transmits each character of a string terminated with null
char | *s - string to be send |
none