From 972126fd2406030dbd3abd1a705bb0ae1af9abb3 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 15 Dec 2017 14:55:27 +0100 Subject: Add AVR (Arduino Nano) support --- include/arduino-nano/driver/gpio.h | 18 ++++++++++++++++++ include/arduino-nano/driver/stdout.h | 19 +++++++++++++++++++ include/arduino-nano/driver/uptime.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 include/arduino-nano/driver/gpio.h create mode 100644 include/arduino-nano/driver/stdout.h create mode 100644 include/arduino-nano/driver/uptime.h (limited to 'include/arduino-nano') diff --git a/include/arduino-nano/driver/gpio.h b/include/arduino-nano/driver/gpio.h new file mode 100644 index 0000000..177e7c5 --- /dev/null +++ b/include/arduino-nano/driver/gpio.h @@ -0,0 +1,18 @@ +#ifndef GPIO_H +#define GPIO_H + +class GPIO { + private: + GPIO(const GPIO ©); + + public: + GPIO () {} + void setup(); + void led_on(unsigned char id); + void led_off(unsigned char id); + void led_toggle(unsigned char id); +}; + +extern GPIO gpio; + +#endif diff --git a/include/arduino-nano/driver/stdout.h b/include/arduino-nano/driver/stdout.h new file mode 100644 index 0000000..d6cb2b0 --- /dev/null +++ b/include/arduino-nano/driver/stdout.h @@ -0,0 +1,19 @@ +#ifndef STANDARDOUTPUT_H +#define STANDANDOUTPUT_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/arduino-nano/driver/uptime.h b/include/arduino-nano/driver/uptime.h new file mode 100644 index 0000000..86a8bb5 --- /dev/null +++ b/include/arduino-nano/driver/uptime.h @@ -0,0 +1,29 @@ +#ifndef UPTIME_H +#define UPTIME_H + +#include + +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 -- cgit v1.2.3