You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.1 KiB

/** @file usart1.h
@author Michael Hayes
@date 10 December 2004
@brief Routines for interfacing with the usart1 on an Atmega32u2
*/
#ifndef USART1_H
#define USART1_H
#include "system.h"
typedef struct usart1_cfg_struct
{
uint16_t baud_divisor;
uint8_t bits;
} usart1_cfg_t;
#define USART1_BAUD_DIVISOR(BAUD_RATE) ((F_CPU / 16) / (BAUD_RATE))
/* Return non-zero if there is a character ready to be read. */
bool
usart1_read_ready_p (void);
/* Read character from USART1. This blocks if nothing is available to
read. */
int8_t
usart1_getc (void);
/* Return non-zero if a character can be written without blocking. */
bool
usart1_write_ready_p (void);
/* Return non-zero if transmitter finished. */
bool
usart1_write_finished_p (void);
/* Write character to USART1. This returns zero if the character
could not be written. */
int8_t
usart1_putc (char ch);
/* Write string to USART1. */
void
usart1_puts (const char *str);
/* Initialise usart1 and set baud rate. */
uint8_t
usart1_init (const usart1_cfg_t *cfg);
#endif