diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2024-01-26 20:38:50 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2024-01-26 20:38:50 +0100 |
commit | 218166456b68ca2266c8e7c77c1085ad4fc16e86 (patch) | |
tree | d83ca341c6706dcbac806c960d8f8baaadfc0421 /src/arch/atmega2560/driver/stdin3.cc | |
parent | fc4a1906ff3fa4ce355c3a058b15ed243d8ce7a8 (diff) |
ATMega2560: Add stdin and stdout on UART1, UART2, UART3
Diffstat (limited to 'src/arch/atmega2560/driver/stdin3.cc')
-rw-r--r-- | src/arch/atmega2560/driver/stdin3.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/arch/atmega2560/driver/stdin3.cc b/src/arch/atmega2560/driver/stdin3.cc new file mode 100644 index 0000000..7b32fe6 --- /dev/null +++ b/src/arch/atmega2560/driver/stdin3.cc @@ -0,0 +1,35 @@ +/* + * Copyright 2020 Birte Kristina Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "driver/stdin3.h" +#include <avr/io.h> +#include <avr/interrupt.h> + +void StandardInput3::setup() +{ + UCSR3B |= _BV(RXCIE3); +} + +bool StandardInput3::hasKey() +{ + if (write_pos != read_pos) { + return true; + } + return false; +} + +char StandardInput3::getKey() +{ + char ret = buffer[read_pos++]; + read_pos %= bufsize; + return ret; +} + +StandardInput3 kin3; + +ISR(USART3_RX_vect) +{ + kin3.addKey(UDR3); +} |