From 55f0cf83d1452ba355a33be9eb9d9d10a90ba0f5 Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 10 Nov 2022 19:33:38 +0100 Subject: [PATCH 1/3] changes for attiny1616 --- uart.c | 8 +++----- uart.h | 6 ++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/uart.c b/uart.c index 1578968..7f75cbc 100644 --- a/uart.c +++ b/uart.c @@ -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(__AVR_ATtiny814__) || defined(__AVR_ATtiny1616__) + /* 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 diff --git a/uart.h b/uart.h index d27ee3e..fec4cfb 100644 --- a/uart.h +++ b/uart.h @@ -226,6 +226,12 @@ 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 */ From b460734b804f1eb11291070e3fd44433bff3019f Mon Sep 17 00:00:00 2001 From: Tom Date: Thu, 10 Nov 2022 19:33:49 +0100 Subject: [PATCH 2/3] add #ifdef __cplusplus --- uart.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/uart.h b/uart.h index fec4cfb..c996a6b 100644 --- a/uart.h +++ b/uart.h @@ -236,6 +236,11 @@ were adapted from the Arduino HardwareSerial.h library by Tim Sharpe on ** function prototypes */ +#ifdef __cplusplus +extern "C" { +#endif + + /** @brief Initialize UART and set baudrate @param baudrate Specify baudrate using macro UART_BAUD_SELECT() @@ -439,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 From 068f71858aa4698981bdae3143116c18fe5225eb Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 12 Nov 2022 10:26:48 +0100 Subject: [PATCH 3/3] use AVR1_USART0 #define --- uart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uart.c b/uart.c index 7f75cbc..e6e7638 100644 --- a/uart.c +++ b/uart.c @@ -366,7 +366,7 @@ Date Description #define UART1_CONTROL UCSR1B #define UART1_DATA UDR1 #define UART1_UDRIE UDRIE1 -#elif defined(__AVR_ATtiny814__) || defined(__AVR_ATtiny1616__) +#elif defined(AVR1_USART0) /* AVR-1 with USART */ #define UART0_RECEIVE_INTERRUPT USART0_RXC_vect #define UART0_TRANSMIT_INTERRUPT USART0_DRE_vect