diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-02-07 21:12:04 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-02-07 21:12:04 +0100 |
commit | 998419816c815175cd4c4f226e619c578d42e0aa (patch) | |
tree | 3efa872828bb973406a15469ac9ddfd245f29cfa /src/arch/atmega2560/driver | |
parent | 30431427adbf05a3e5cc17f6fb4b1b1cbc105b39 (diff) |
add arch atmega2560 (preliminary support)
Diffstat (limited to 'src/arch/atmega2560/driver')
-rw-r--r-- | src/arch/atmega2560/driver/counter.cc | 15 | ||||
-rw-r--r-- | src/arch/atmega2560/driver/gpio.cc | 26 | ||||
-rw-r--r-- | src/arch/atmega2560/driver/stdout.cc | 40 | ||||
-rw-r--r-- | src/arch/atmega2560/driver/timer.cc | 8 | ||||
-rw-r--r-- | src/arch/atmega2560/driver/uptime.cc | 8 |
5 files changed, 97 insertions, 0 deletions
diff --git a/src/arch/atmega2560/driver/counter.cc b/src/arch/atmega2560/driver/counter.cc new file mode 100644 index 0000000..d6cde46 --- /dev/null +++ b/src/arch/atmega2560/driver/counter.cc @@ -0,0 +1,15 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "driver/counter.h" + +Counter counter; + +ISR(TIMER3_OVF_vect) +{ + if (counter.overflow < 255) { + counter.overflow++; + } +} diff --git a/src/arch/atmega2560/driver/gpio.cc b/src/arch/atmega2560/driver/gpio.cc new file mode 100644 index 0000000..60e374e --- /dev/null +++ b/src/arch/atmega2560/driver/gpio.cc @@ -0,0 +1,26 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "driver/gpio.h" +#include <avr/io.h> +#include <avr/interrupt.h> + +GPIO gpio; + +#ifndef __acweaving +ISR(PCINT0_vect) +{ +} + +ISR(PCINT1_vect) +{ +} + +/* +ISR(PCINT2_vect) +{ +} +*/ +#endif diff --git a/src/arch/atmega2560/driver/stdout.cc b/src/arch/atmega2560/driver/stdout.cc new file mode 100644 index 0000000..58a3e7e --- /dev/null +++ b/src/arch/atmega2560/driver/stdout.cc @@ -0,0 +1,40 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "driver/stdout.h" +#include <avr/io.h> +#include <avr/interrupt.h> + +#ifndef BAUD +#define BAUD 115200UL +#endif + +#include <util/setbaud.h> + +void StandardOutput::setup() +{ + UBRR0H = UBRRH_VALUE; + UBRR0L = UBRRL_VALUE; + +#if USE_2X + UCSR0A |= _BV(U2X0); +#else + UCSR0A &= ~_BV(U2X0); +#endif + + UCSR0B |= _BV(RXEN0) | _BV(TXEN0); + UCSR0C = _BV(UCSZ01) | _BV(UCSZ00); +} + +void StandardOutput::put(char c) +{ + while (!(UCSR0A & _BV(UDRE0))); + UDR0 = c; + if (c == '\n') { + put('\r'); + } +} + +StandardOutput kout; diff --git a/src/arch/atmega2560/driver/timer.cc b/src/arch/atmega2560/driver/timer.cc new file mode 100644 index 0000000..b6d4145 --- /dev/null +++ b/src/arch/atmega2560/driver/timer.cc @@ -0,0 +1,8 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "driver/timer.h" + +Timer timer; diff --git a/src/arch/atmega2560/driver/uptime.cc b/src/arch/atmega2560/driver/uptime.cc new file mode 100644 index 0000000..7e37a7b --- /dev/null +++ b/src/arch/atmega2560/driver/uptime.cc @@ -0,0 +1,8 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "driver/uptime.h" + +Uptime uptime; |