Loading Makefile +13 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,11 @@ ifneq ($(findstring am2320,${drivers}), ) COMMON_FLAGS += -DDRIVER_AM2320 endif ifneq ($(findstring ccs811,${drivers}), ) TARGETS += src/driver/ccs811.cc COMMON_FLAGS += -DDRIVER_CCS811 endif ifneq ($(findstring eeprom24lc64,${drivers}), ) TARGETS += src/driver/eeprom24lc64.cc COMMON_FLAGS += -DDRIVER_EEPROM24LC64 Loading Loading @@ -52,6 +57,14 @@ ifneq ($(findstring softi2c,${drivers}), ) COMMON_FLAGS += -DDRIVER_SOFTI2C endif ifneq (${i2c_freq}, ) COMMON_FLAGS += -DF_I2C=${i2c_freq} endif ifneq (${timer_freq}, ) COMMON_FLAGS += -DF_TIMER=${timer_freq} endif ifeq (${softi2c_pullup}, 1) COMMON_FLAGS += -DSOFTI2C_PULLUP endif Loading include/arch/arduino-nano/driver/timer.h +11 −4 Original line number Diff line number Diff line #include <avr/io.h> #include <avr/interrupt.h> #define ON_TIMER_INTERRUPT ISR(TIMER0_COMPA_vect) #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(unsigned char const frequency) { inline void setup_khz(unsigned char const frequency) { OCR0A = frequency ? 255 / frequency : 1; TCCR0A = _BV(WGM01); prescaler = _BV(CS01) | _BV(CS00); } inline void setup_hz(unsigned char 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 = _BV(CS01) | _BV(CS00); TCCR0B = prescaler; if (interrupt) { TIMSK0 = _BV(OCIE0A); } Loading include/arch/msp430fr5969lp/driver/timer.h 0 → 100644 +40 −0 Original line number Diff line number Diff line #include <msp430.h> #define ON_TIMER_INTERRUPT_head __attribute__((interrupt(TIMER0_A1_VECTOR))) __attribute__((wakeup)) void handle_timer0_overflow() { if (TA0IV == 0x0e) { #define ON_TIMER_INTERRUPT_tail } } class Timer { private: Timer(const Timer ©); public: Timer() {} inline void setup_khz(uint16_t const frequency) { TA0CTL = TASSEL__SMCLK | ID__8 | MC__UP; TA0EX0 = 1; TA0CCR0 = 1000 / frequency; TA0CTL |= TACLR; } inline void setup_hz(uint16_t const frequency) { TA0CTL = TASSEL__SMCLK | ID__8 | MC__UP; TA0EX0 = 1; TA0CCR0 = 1000000 / frequency; TA0CTL |= TACLR; } inline void start(unsigned char const interrupt) { if (interrupt) { TA0CTL |= TACLR | TAIE; } else { TA0CTL |= TACLR; } } inline void stop() { TA0CTL = 0; } }; extern Timer timer; src/arch/arduino-nano/Makefile.inc +0 −8 Original line number Diff line number Diff line Loading @@ -37,14 +37,6 @@ ifneq ($(findstring timer,${arch_drivers}), ) TARGETS += src/arch/arduino-nano/driver/timer.cc endif ifneq (${i2c_freq}, ) COMMON_FLAGS += -DF_I2C=${i2c_freq} endif ifneq (${timer_freq}, ) COMMON_FLAGS += -DF_TIMER=${timer_freq} endif OBJECTS = ${TARGETS:.cc=.o} .cc.o: Loading src/arch/blinkenrocket/Makefile.inc +0 −4 Original line number Diff line number Diff line Loading @@ -27,10 +27,6 @@ else ifneq ($(findstring i2c,${arch_drivers}), ) TARGETS += src/arch/blinkenrocket/driver/i2c.cc endif ifneq (${i2c_freq}, ) COMMON_FLAGS += -DF_I2C=${i2c_freq} endif OBJECTS = ${TARGETS:.cc=.o} .cc.o: Loading Loading
Makefile +13 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,11 @@ ifneq ($(findstring am2320,${drivers}), ) COMMON_FLAGS += -DDRIVER_AM2320 endif ifneq ($(findstring ccs811,${drivers}), ) TARGETS += src/driver/ccs811.cc COMMON_FLAGS += -DDRIVER_CCS811 endif ifneq ($(findstring eeprom24lc64,${drivers}), ) TARGETS += src/driver/eeprom24lc64.cc COMMON_FLAGS += -DDRIVER_EEPROM24LC64 Loading Loading @@ -52,6 +57,14 @@ ifneq ($(findstring softi2c,${drivers}), ) COMMON_FLAGS += -DDRIVER_SOFTI2C endif ifneq (${i2c_freq}, ) COMMON_FLAGS += -DF_I2C=${i2c_freq} endif ifneq (${timer_freq}, ) COMMON_FLAGS += -DF_TIMER=${timer_freq} endif ifeq (${softi2c_pullup}, 1) COMMON_FLAGS += -DSOFTI2C_PULLUP endif Loading
include/arch/arduino-nano/driver/timer.h +11 −4 Original line number Diff line number Diff line #include <avr/io.h> #include <avr/interrupt.h> #define ON_TIMER_INTERRUPT ISR(TIMER0_COMPA_vect) #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(unsigned char const frequency) { inline void setup_khz(unsigned char const frequency) { OCR0A = frequency ? 255 / frequency : 1; TCCR0A = _BV(WGM01); prescaler = _BV(CS01) | _BV(CS00); } inline void setup_hz(unsigned char 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 = _BV(CS01) | _BV(CS00); TCCR0B = prescaler; if (interrupt) { TIMSK0 = _BV(OCIE0A); } Loading
include/arch/msp430fr5969lp/driver/timer.h 0 → 100644 +40 −0 Original line number Diff line number Diff line #include <msp430.h> #define ON_TIMER_INTERRUPT_head __attribute__((interrupt(TIMER0_A1_VECTOR))) __attribute__((wakeup)) void handle_timer0_overflow() { if (TA0IV == 0x0e) { #define ON_TIMER_INTERRUPT_tail } } class Timer { private: Timer(const Timer ©); public: Timer() {} inline void setup_khz(uint16_t const frequency) { TA0CTL = TASSEL__SMCLK | ID__8 | MC__UP; TA0EX0 = 1; TA0CCR0 = 1000 / frequency; TA0CTL |= TACLR; } inline void setup_hz(uint16_t const frequency) { TA0CTL = TASSEL__SMCLK | ID__8 | MC__UP; TA0EX0 = 1; TA0CCR0 = 1000000 / frequency; TA0CTL |= TACLR; } inline void start(unsigned char const interrupt) { if (interrupt) { TA0CTL |= TACLR | TAIE; } else { TA0CTL |= TACLR; } } inline void stop() { TA0CTL = 0; } }; extern Timer timer;
src/arch/arduino-nano/Makefile.inc +0 −8 Original line number Diff line number Diff line Loading @@ -37,14 +37,6 @@ ifneq ($(findstring timer,${arch_drivers}), ) TARGETS += src/arch/arduino-nano/driver/timer.cc endif ifneq (${i2c_freq}, ) COMMON_FLAGS += -DF_I2C=${i2c_freq} endif ifneq (${timer_freq}, ) COMMON_FLAGS += -DF_TIMER=${timer_freq} endif OBJECTS = ${TARGETS:.cc=.o} .cc.o: Loading
src/arch/blinkenrocket/Makefile.inc +0 −4 Original line number Diff line number Diff line Loading @@ -27,10 +27,6 @@ else ifneq ($(findstring i2c,${arch_drivers}), ) TARGETS += src/arch/blinkenrocket/driver/i2c.cc endif ifneq (${i2c_freq}, ) COMMON_FLAGS += -DF_I2C=${i2c_freq} endif OBJECTS = ${TARGETS:.cc=.o} .cc.o: Loading