Skip to content

primoze/dots-core.old

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dots-core

Generic core definitions for Arduino

Overview

The library is a set of template definitions which can be instantiated on a specific platform.

Timer (16 bit)

// timer is parametrized by the base address of its IO registers
// and the address of its interrupt mask register.
template <ioaddr_t _base, ioaddr_t _timsk>
class timer_16bit {
...

Serial

// usart is parametrized by the base address of its IO registers.
template <ioaddr_t _base>
class usart {
...

An os::io::stream USART writer class is provided:

template <class _usart>
class writer
...

Stream

// stream is parametrized by a writer class, and a writer base class. The writer
// must provide a bool write(byte_t) method, while the writer base class provides
// an int write(byte_t*, size_t) method. The writer_base default template argument
// provides one. Provide a different implementation to change the default behaviour.
template <class _writer, template <typename> class _base = writer_base>
class stream {
public:
...

An os::io::stream default writer_base class is provided:

template <class _writer>
class writer_base : public _writer {
public:
...

Usage

#include <dots-core/usart.h>
#include <dots-core/timer.h>
#include <dots-core/stream.h>

#if defined (__AVR_ATmega328P__)

typedef os::timer::timer_16bit<0x80, 0x6f> timer1_t;
extern timer1_t timer1;

typedef os::usart::usart<0xc0> usart0_t;
typedef os::usart::writer<usart0_t> usart0_writer_t;
typedef os::io::stream<usart0_writer_t> stdout_t;

extern stdout_t stdout;

#endif // __AVR_ATmega328P__

and then instantiate the objects somewhere:

timer1_t timer1;
usart0_t usart0;
stdout_t stdout;

You'll need to implement your own interrupt handlers.

Releases

No releases published

Packages

No packages published

Languages