Skip to content
Snippets Groups Projects
Commit 909c7cc3 authored by Markus Scheck's avatar Markus Scheck
Browse files

deleted unused programms

parent b5682c64
Branches
No related tags found
No related merge requests found
Showing
with 5 additions and 59 deletions
......@@ -26,7 +26,7 @@ inline void timer_start(void) {
TCCR1B |= TIMER_MASK;
//enable interrupts
sei();
}
inline uint32_t timer_ticks(void) {
......@@ -40,6 +40,7 @@ inline uint32_t timer_stop(void) {
return timer_ticks();
}
// count overflows
ISR(TIMER1_OVF_vect) {
overflow_count++;
}
// all functions inline to save execution time
// initialize timer for time measurement
inline void timer_init(void);
// start time measurement
inline void timer_start(void);
// stop time measurement, return ticks
inline uint32_t timer_stop(void);
// get timer ticks
inline uint32_t timer_ticks(void);
// This module uses TIMER1 to keep track of time
#include "timer_1.h"
#include <avr/interrupt.h>
uint32_t overflow_count;
#define TIMER_MASK (1<<CS10)
inline void timer_init(void) {
// enable overflow interrupt
TIMSK1 |= (1<<TOIE1);
}
inline void timer_start(void) {
//disable interrupts globally
cli();
//clear out timer counting register
TCNT1 = 0;
//clear overflow count
overflow_count = 0;
// set up clock source
// we have a 16MHz Clock
// and a 16 Bit timer
// Use a prescaler of 256 -> 16/256 = 62.5kHz
TCCR1B |= TIMER_MASK;
//enable interrupts
sei();
}
inline uint32_t timer_ticks(void) {
return TCNT1 ^ (overflow_count << 16);
}
inline uint32_t timer_stop(void) {
// stop timer clock
TCCR1B &= ~(TIMER_MASK);
return timer_ticks();
}
ISR(TIMER1_OVF_vect) {
overflow_count++;
}
......@@ -71,6 +71,8 @@ inline void tp_i2c(uint16_t len) {
transmit_data(0xff);
}
transmit_stop();
delayMicroseconds(11);
delayMicroseconds(5); // wait for transmit of stop condition
// may need to be altered for slow bit speeds
// hardware needs time to latch the request for a stop
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment