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 | |
parent | 30431427adbf05a3e5cc17f6fb4b1b1cbc105b39 (diff) |
add arch atmega2560 (preliminary support)
-rw-r--r-- | include/arch/atmega2560/arch_types.h | 12 | ||||
-rw-r--r-- | include/arch/atmega2560/driver/counter.h | 41 | ||||
-rw-r--r-- | include/arch/atmega2560/driver/gpio.h | 234 | ||||
-rw-r--r-- | include/arch/atmega2560/driver/stdout.h | 24 | ||||
-rw-r--r-- | include/arch/atmega2560/driver/timer.h | 40 | ||||
-rw-r--r-- | include/arch/atmega2560/driver/uptime.h | 34 | ||||
-rw-r--r-- | src/arch/atmega2560/Makefile.inc | 185 | ||||
-rw-r--r-- | src/arch/atmega2560/arch.cc | 104 | ||||
-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 |
13 files changed, 771 insertions, 0 deletions
diff --git a/include/arch/atmega2560/arch_types.h b/include/arch/atmega2560/arch_types.h new file mode 100644 index 0000000..2e9f070 --- /dev/null +++ b/include/arch/atmega2560/arch_types.h @@ -0,0 +1,12 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#ifndef ARCH_TYPES_H +#define ARCH_TYPES_H + +typedef uint8_t native_uint_t; +typedef int8_t native_int_t; + +#endif diff --git a/include/arch/atmega2560/driver/counter.h b/include/arch/atmega2560/driver/counter.h new file mode 100644 index 0000000..06ff73a --- /dev/null +++ b/include/arch/atmega2560/driver/counter.h @@ -0,0 +1,41 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#ifndef COUNTER_H +#define COUNTER_H + +#include <avr/io.h> +#include <avr/interrupt.h> + +typedef uint16_t counter_value_t; +typedef uint8_t counter_overflow_t; + +class Counter { + private: + Counter(const Counter ©); + + public: + uint16_t value; + volatile uint8_t overflow; + + Counter() : overflow(0) {} + + inline void start() { + overflow = 0; + TCNT3 = 0; + TCCR3A = 0; + TCCR3B = _BV(CS10); // no prescaler + TIMSK3 = _BV(TOIE3); + } + + inline void stop() { + TCCR3B = 0; + value = TCNT3; + } +}; + +extern Counter counter; + +#endif diff --git a/include/arch/atmega2560/driver/gpio.h b/include/arch/atmega2560/driver/gpio.h new file mode 100644 index 0000000..b163ea0 --- /dev/null +++ b/include/arch/atmega2560/driver/gpio.h @@ -0,0 +1,234 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#ifndef GPIO_H +#define GPIO_H + +#include <avr/io.h> + +class GPIO { + private: + GPIO(const GPIO ©); + + public: + GPIO () {} + + enum Pin : unsigned char { + pa0 = 0, + pa1 = 1, + pa2 = 2, + pa3 = 3, + pa4 = 4, + pa5 = 5, + pa6 = 6, + pa7 = 7, + pb0 = 8, + pb1 = 9, + pb2 = 10, + pb3 = 11, + pb4 = 12, + pb5 = 13, + pb6 = 14, + pb7 = 15, + pc0 = 16, + pc1 = 17, + pc2 = 18, + pc3 = 19, + pc4 = 20, + pc5 = 21, + pc6 = 22, + pc7 = 23, + pd0 = 24, + pd1 = 25, + pd2 = 26, + pd3 = 27, + pd4 = 28, + pd5 = 29, + pd6 = 30, + pd7 = 31, + pe0 = 32, + pe1 = 33, + pe2 = 34, + pe3 = 35, + pe4 = 36, + pe5 = 37, + pe6 = 38, + pe7 = 39, + pf0 = 40, + pf1 = 41, + pf2 = 42, + pf3 = 43, + pf4 = 44, + pf5 = 45, + pf6 = 46, + pf7 = 47, + pg0 = 48, + pg1 = 49, + pg2 = 50, + pg3 = 51, + pg4 = 52, + pg5 = 53, + ph0 = 56, + ph1 = 57, + ph2 = 58, + ph3 = 59, + ph4 = 60, + ph5 = 61, + ph6 = 62, + ph7 = 63, + pj0 = 64, + pj1 = 65, + pj2 = 66, + pj3 = 67, + pj4 = 68, + pj5 = 69, + pj6 = 70, + pj7 = 71, + pk0 = 72, + pk1 = 73, + pk2 = 74, + pk3 = 75, + pk4 = 76, + pk5 = 77, + pk6 = 78, + pk7 = 79, + pl0 = 80, + pl1 = 81, + pl2 = 82, + pl3 = 83, + pl4 = 84, + pl5 = 85, + pl6 = 86, + pl7 = 87 + }; + + inline void setup() { + DDRB = _BV(PB7); + } + inline volatile uint8_t * pinToPort(uint8_t pin) { + if (pin <= pa7) { + return &PORTA; + } + if (pin <= pb7) { + return &PORTB; + } + if (pin <= pc7) { + return &PORTC; + } + return &PORTD; + } + inline unsigned char pinToBitmask(uint8_t pin) { + return _BV(pin % 8); + } +#pragma GCC diagnostic ignored "-Wunused-parameter" + inline void led_on(unsigned char id) { + PORTB |= _BV(PB7); + } + inline void led_off(unsigned char id) { + PORTB &= ~_BV(PB7); + } + inline void led_toggle(unsigned char id) { + PINB = _BV(PB7); + } + inline void input(unsigned char const pin) { + if (pin < 8) { + DDRA &= ~_BV(pin); + } else if (pin < 16) { + DDRB &= ~_BV(pin - 8); + } else if (pin < 24) { + DDRC &= ~_BV(pin - 16); + } else if (pin < 32) { + DDRD &= ~_BV(pin - 24); + } + } +#pragma GCC diagnostic pop + inline void input(unsigned char const pin, unsigned char const pull) { + if (pin < 8) { + DDRA &= ~_BV(pin); + PORTA |= _BV(pin); + } else if (pin < 16) { + DDRB &= ~_BV(pin - 8); + PORTB |= _BV(pin - 8); + } else if (pin < 24) { + DDRC &= ~_BV(pin - 16); + PORTC |= _BV(pin - 16); + } else if (pin < 32) { + DDRD &= ~_BV(pin - 24); + PORTD |= _BV(pin - 24); + } + } + inline void output(unsigned char const pin) { + if (pin < 8) { + DDRA |= _BV(pin); + } else if (pin < 16) { + DDRB |= _BV(pin - 8); + } else if (pin < 24) { + DDRC |= _BV(pin - 16); + } else if (pin < 32) { + DDRD |= _BV(pin - 24); + } + } + inline void output(unsigned char const pin, unsigned char const value) { + if (pin < 8) { + PORTA = value ? (PORTA | _BV(pin)) : (PORTA & ~_BV(pin)); + DDRA |= _BV(pin); + } else if (pin < 16) { + PORTB = value ? (PORTB | _BV(pin - 8)) : (PORTB & ~_BV(pin - 8)); + DDRB |= _BV(pin - 8); + } else if (pin < 24) { + PORTC = value ? (PORTC | _BV(pin - 16)) : (PORTC & ~_BV(pin - 16)); + DDRC |= _BV(pin - 16); + } else if (pin < 32) { + PORTD = value ? (PORTD | _BV(pin - 24)) : (PORTD & ~_BV(pin - 24)); + DDRD |= _BV(pin - 24); + } + } + inline unsigned char read(unsigned char const pin) { + if (pin < 8) { + return (PINA & _BV(pin)); + } + if (pin < 16) { + return (PINB & _BV(pin - 8)); + } + if (pin < 24) { + return (PINC & _BV(pin - 16)); + } + if (pin < 32) { + return (PIND & _BV(pin - 24)); + } + return 0; + } + inline void write(unsigned char const pin, unsigned char value) { + if (pin < 8) { + if (value) { + PORTA |= _BV(pin); + } else { + PORTA &= ~_BV(pin); + } + } else if (pin < 16) { + if (value) { + PORTB |= _BV(pin - 8); + } else { + PORTB &= ~_BV(pin - 8); + } + } else if (pin < 24) { + if (value) { + PORTC |= _BV(pin - 16); + } else { + PORTC &= ~_BV(pin - 16); + } + } else if (pin < 32) { + if (value) { + PORTD |= _BV(pin - 24); + } else { + PORTD &= ~_BV(pin - 24); + } + } + } +}; + +extern GPIO gpio; + +#endif diff --git a/include/arch/atmega2560/driver/stdout.h b/include/arch/atmega2560/driver/stdout.h new file mode 100644 index 0000000..09b18c1 --- /dev/null +++ b/include/arch/atmega2560/driver/stdout.h @@ -0,0 +1,24 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#ifndef STANDARDOUTPUT_H +#define STANDARDOUTPUT_H + +#include "object/outputstream.h" + +class StandardOutput : public OutputStream { + private: + StandardOutput(const StandardOutput ©); + + public: + StandardOutput () {} + void setup(); + + virtual void put(char c) override; +}; + +extern StandardOutput kout; + +#endif diff --git a/include/arch/atmega2560/driver/timer.h b/include/arch/atmega2560/driver/timer.h new file mode 100644 index 0000000..73a8125 --- /dev/null +++ b/include/arch/atmega2560/driver/timer.h @@ -0,0 +1,40 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include <avr/io.h> +#include <avr/interrupt.h> + +#define ON_TIMER_INTERRUPT_head ISR(TIMER0_COMPA_vect) { +#define ON_TIMER_INTERRUPT_tail } + +class Timer { + private: + Timer(const Timer ©); + unsigned char prescaler; + + public: + Timer() {} + + inline void setup_khz(uint16_t const frequency) { + OCR0A = frequency ? 255 / frequency : 1; + TCCR0A = _BV(WGM01); + prescaler = _BV(CS01) | _BV(CS00); + } + inline void setup_hz(uint16_t const frequency) { + OCR0A = frequency ? 255 / frequency : 1; + TCCR0A = _BV(WGM01); + prescaler = _BV(CS02) | _BV(CS00); + } + inline void start(unsigned char const interrupt) { + TCNT0 = 0; + TCCR0B = prescaler; + if (interrupt) { + TIMSK0 = _BV(OCIE0A); + } + } + inline void stop() { TCCR0B = 0; TIMSK0 = 0; } +}; + +extern Timer timer; diff --git a/include/arch/atmega2560/driver/uptime.h b/include/arch/atmega2560/driver/uptime.h new file mode 100644 index 0000000..621a55c --- /dev/null +++ b/include/arch/atmega2560/driver/uptime.h @@ -0,0 +1,34 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#ifndef UPTIME_H +#define UPTIME_H + +#include <avr/io.h> + +class Uptime { + private: + Uptime(const Uptime ©); +#ifdef TIMER_S + uint8_t seconds; +#endif + + public: +#ifdef TIMER_S + Uptime () : seconds(0) {} +#else + Uptime () {} +#endif + inline uint8_t get_cycles() { return TCNT0; } + inline uint8_t get_us() { return TCNT2/2; } +#ifdef TIMER_S + inline uint8_t get_s() { return seconds; } + inline void tick_s() { seconds++; } +#endif +}; + +extern Uptime uptime; + +#endif diff --git a/src/arch/atmega2560/Makefile.inc b/src/arch/atmega2560/Makefile.inc new file mode 100644 index 0000000..d78db66 --- /dev/null +++ b/src/arch/atmega2560/Makefile.inc @@ -0,0 +1,185 @@ +# vim:ft=make +# +# Copyright 2021 Daniel Friesel +# +# SPDX-License-Identifier: BSD-2-Clause + +MCU = atmega2560 +SERIAL_PORT ?= /dev/ttyUSB0 +BAUD = 115200 + +ifdef CONFIG_arch_atmega2560_cpufreq + cpu_freq = ${CONFIG_arch_atmega2560_cpufreq} +endif + +cpu_freq ?= 16000000 + +COMMON_FLAGS += -Werror=overflow +COMMON_FLAGS += -mmcu=${MCU} -DMULTIPASS_ARCH_atmega2560 +COMMON_FLAGS += -DF_CPU=${cpu_freq}UL +COMMON_FLAGS += -DMULTIPASS_ARCH_HAS_I2C + +ifeq (${stack_usage}, ) + COMMON_FLAGS += -flto +endif + +CC = avr-gcc +CXX = avr-g++ +NM = avr-nm +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump + +ARCH_SHORTNAME = avr + +ifdef CONFIG_aspectc + CXX = ag++ -r build/repo.acp -v 0 --c_compiler avr-g++ -p . --Xcompiler +endif + +CXX_TARGETS += src/arch/atmega2560/arch.cc +CXX_TARGETS += src/arch/atmega2560/driver/gpio.cc +CXX_TARGETS += src/arch/atmega2560/driver/stdout.cc + +# Command-line driver selection + +ifneq ($(findstring softi2c,${drivers}), ) +else ifneq ($(findstring i2c,${arch_drivers}), ) + CONFIG_arch_atmega2560_driver_i2c = y +endif + +ifneq ($(findstring adc,${arch_drivers}), ) + CONFIG_arch_atmega2560_driver_adc = y +endif + +ifneq ($(findstring spi,${arch_drivers}), ) + CONFIG_arch_atmega2560_driver_spi = y +endif + +ifneq ($(findstring stdin,${arch_drivers}), ) + CONFIG_arch_atmega2560_driver_stdin = y +endif + +ifneq ($(findstring timer,${arch_drivers}), ) + CONFIG_arch_atmega2560_driver_timer = y +endif + +ifneq ($(findstring counter,${arch_drivers}), ) + CONFIG_arch_atmega2560_driver_counter = y +endif + +ifneq ($(findstring neopixel,${arch_drivers}), ) + CONFIG_arch_atmega2560_driver_neopixel = y +endif + +ifeq (${timer_s}, 1) + CONFIG_arch_atmega2560_driver_uptime = y +endif + +# Kconfig driver selection + +ifdef CONFIG_arch_atmega2560_driver_i2c + CXX_TARGETS += src/arch/atmega2560/driver/i2c.cc +endif + +ifdef CONFIG_arch_atmega2560_driver_adc + CXX_TARGETS += src/arch/atmega2560/driver/adc.cc +endif + +ifdef CONFIG_arch_atmega2560_driver_spi + CXX_TARGETS += src/arch/atmega2560/driver/spi.cc +endif + +ifdef CONFIG_arch_atmega2560_driver_stdin + CXX_TARGETS += src/arch/atmega2560/driver/stdin.cc +endif + +ifdef CONFIG_arch_atmega2560_driver_timer + CXX_TARGETS += src/arch/atmega2560/driver/timer.cc +endif + +ifdef CONFIG_arch_atmega2560_driver_counter + CXX_TARGETS += src/arch/atmega2560/driver/counter.cc +endif + +ifdef CONFIG_arch_atmega2560_driver_neopixel + CXX_TARGETS += src/arch/atmega2560/driver/neopixel.cc +endif + +ifdef CONFIG_arch_atmega2560_driver_uptime + COMMON_FLAGS += -DTIMER_S + CXX_TARGETS += src/arch/atmega2560/driver/uptime.cc +endif + +ifeq (${cpu_freq}, 16000000) + uart_baud = 57600 +else ifeq (${cpu_freq}, 8000000) + uart_baud = 38400 +else ifeq (${cpu_freq}, 4000000) + uart_baud = 38400 +else ifeq (${cpu_freq}, 2000000) + uart_baud = 19200 +else ifeq (${cpu_freq}, 1000000) + uart_baud = 9600 +else ifeq (${cpu_freq}, 500000) + uart_baud = 4800 +else ifeq (${cpu_freq}, 250000) + uart_baud = 2400 +else ifeq (${cpu_freq}, 125000) + uart_baud = 1200 +else ifeq (${cpu_freq}, 62500) + uart_baud = 300 +else + uart_baud = 9600 +endif + +COMMON_FLAGS += -DBAUD=${uart_baud}UL + +OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o} + +.cc.o: + ${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc} + +.c.o: + ${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c} + +build/system.elf: ${OBJECTS} + ${QUIET}mkdir -p build + ${QUIET}${CXX} ${COMMON_FLAGS} ${CXXFLAGS} -Wl,--gc-sections -o $@ ${OBJECTS} + ${QUIET}avr-size --format=avr --mcu=${MCU} $@ + ${QUIET}test $$(avr-size --format=avr --mcu=${MCU} build/system.elf | fgrep Program | grep -o '[0-9.]*%' | cut -d . -f 1) -lt 100 + +build/system.hex: build/system.elf + ${QUIET}${OBJCOPY} -O ihex ${@:.hex=.elf} $@ + +program: build/system.hex + ${QUIET}avrdude -p ${MCU} -c wiring -P ${SERIAL_PORT} -b ${BAUD} -D -U flash:w:build/system.hex + +arch_clean: + ${QUIET}rm -f ${OBJECTS} build/system.hex + +cat: + ${QUIET}script/cat.py ${SERIAL_PORT} ${uart_baud} ${cpu_freq} 65536 + +monitor: + ${QUIET}screen ${SERIAL_PORT} ${uart_baud} + +size: build/system.elf + ${QUIET}avr-size --format=avr --mcu=${MCU} build/system.elf | fgrep Program | perl -nE 'if (m{(\d+) bytes \(([0-9.]+%)}) { print("$$1;$$2;") }' + ${QUIET}avr-size --format=avr --mcu=${MCU} build/system.elf | fgrep Data | perl -nE 'if (m{(\d+) bytes \(([0-9.]+%)}) { print("$$1;$$2;") }' + ${QUIET}echo + +arch_help: + @echo "atmega2560 specific flags:" + @echo " SERIAL_PORT = ${SERIAL_PORT}" + @echo " BAUD = ${BAUD} (only used for programming)" + +arch_info: + @echo "CPU Freq: ${cpu_freq} Hz" + @echo "Timer Freq: ${timer_freq} Hz" + @echo "I2C Freq: ${i2c_freq} Hz" + @echo "Counter Overflow: 65536/255" + @echo "Monitor: ${SERIAL_PORT} ${uart_baud}" + +attributes: build/system.elf + ${QUIET}script/size.py avr-size text,data data,bss + +.PHONY: arch_clean arch_help arch_info attributes cat monitor program size diff --git a/src/arch/atmega2560/arch.cc b/src/arch/atmega2560/arch.cc new file mode 100644 index 0000000..9d7e101 --- /dev/null +++ b/src/arch/atmega2560/arch.cc @@ -0,0 +1,104 @@ +/* + * Copyright 2021 Daniel Friesel + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#include "arch.h" +#include <avr/io.h> +#include <avr/interrupt.h> +#include <avr/wdt.h> +#include <util/delay.h> + +void Arch::setup(void) +{ + wdt_disable(); + +#if F_CPU == 16000000UL + /* default */ +#else +#error Unsupported F_CPU +#endif + +#if defined(WITH_LOOP) || defined(TIMER_S) + TCCR1A = 0; + TCCR1B = _BV(WGM12) | _BV(CS12) | _BV(CS10); // /1024 + OCR1A = F_CPU / 1024; + TIMSK1 = _BV(OCIE1A); +#endif + + sei(); +} + +#ifdef WITH_WAKEUP +void wakeup(); +#endif + +#if defined(WITH_LOOP) || defined(TIMER_S) + +#include "driver/uptime.h" + +#endif + +#if defined(WITH_LOOP) +extern void loop(); +volatile char run_loop = 0; +#endif + +void Arch::idle_loop(void) +{ + while (1) { + SMCR = _BV(SE); + asm("sleep"); + SMCR = 0; + asm("wdr"); +#ifdef WITH_LOOP + if (run_loop) { + loop(); + run_loop = 0; + } +#endif +#ifdef WITH_WAKEUP + wakeup(); +#endif + } +} + +void Arch::idle(void) +{ + SMCR = _BV(SE); + asm("sleep"); + SMCR = 0; + asm("wdr"); +} + +void Arch::delay_us(unsigned int const us) +{ + for (unsigned int i = 0; i < us; i++) { + _delay_us(1); + } +} + +void Arch::delay_ms(unsigned int const ms) +{ + for (unsigned int i = 0; i < ms; i++) { + _delay_ms(1); + } +} + +Arch arch; + +#if defined(WITH_LOOP) || defined(TIMER_S) + +#ifndef __acweaving +ISR(TIMER1_COMPA_vect) +{ +#ifdef WITH_LOOP + run_loop = 1; +#endif +#ifdef TIMER_S + uptime.tick_s(); +#endif +} +#endif + +#endif 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; |