Skip to content

changes for attiny16 (avr-1 family) #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,11 @@ Date Description
#define UART1_CONTROL UCSR1B
#define UART1_DATA UDR1
#define UART1_UDRIE UDRIE1
#elif defined(__AVR_ATtiny814__)
/* AVR-1 with USART */
#define AVR1_USART0
#elif defined(AVR1_USART0)
/* AVR-1 with USART */
#define UART0_RECEIVE_INTERRUPT USART0_RXC_vect
#define UART0_TRANSMIT_INTERRUPT USART0_DRE_vect
#define USART0_BAUD_RATE(_br_) (uint16_t)((float)(F_CPU * 64 / (16 * (float)(_br_)) + 0.5))
// #error "AVR ATtiny814 currently not supported by this libaray !"
#define USART0_BAUD_RATE(_br_) (uint16_t)((float)(F_CPU * 64 / (16 * (float)(_br_)) + 0.5))
#else
#error "no UART definition for MCU available"
#endif
Expand Down
16 changes: 16 additions & 0 deletions uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,21 @@ were adapted from the Arduino HardwareSerial.h library by Tim Sharpe on
/** @brief Macro to flush bytes waiting in receive buffer of USART0 @see uart0_flush */
#define uart_flush() uart0_flush()


#if defined(__AVR_ATtiny814__) || defined(__AVR_ATtiny1616__)
# define AVR1_USART0
#endif


/*
** function prototypes
*/

#ifdef __cplusplus
extern "C" {
#endif


/**
@brief Initialize UART and set baudrate
@param baudrate Specify baudrate using macro UART_BAUD_SELECT()
Expand Down Expand Up @@ -433,6 +444,11 @@ extern uint16_t uart3_available(void);
/** @brief Flush bytes waiting in receive buffer of USART3 */
extern void uart3_flush(void);

#ifdef __cplusplus
}
#endif


/**@}*/

#endif // UART_H
Expand Down