-
Notifications
You must be signed in to change notification settings - Fork 7
/
test.c
77 lines (67 loc) · 1.68 KB
/
test.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Copyright © 2010-2015, Matthias Urlichs <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License (included; see the file LICENSE)
* for more details.
*/
/* This code implements a smple test code which uses a delay loop to toggle
* a pin and emit a serial character.
*/
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/interrupt.h>
#include <string.h>
#include "onewire.h"
#include "features.h"
#include "debug.h"
#ifndef TIMSK
#define TIMSK TIMSK0
#endif
#ifndef TIFR
#define TIFR TIFR0
#endif
#ifndef EICRA
#define EICRA MCUCR
#endif
#define EN_TIMER() do {TIFR|=(1<<TOV0); TIMSK|=(1<<TOIE0);}while(0) //enable timer interrupt
#define DIS_TIMER() do {TIMSK &= ~(1<<TOIE0);} while(0) // disable timer interrupt
static unsigned long long x = 0;
void init_state(void) {
wdt_reset();
DBG(0x01);
DBG_ON();
DBG_OFF();
DBG_ON();
//TCCR0A = 0;
//TCCR0B = 0x03; // Prescaler 1/64
DBG_OFF();
DBG_ON();
//EN_TIMER();
//TCNT0=0xF0;
DBG_OFF();
DBG(0x03);
}
void mainloop(void) {
DBG(0x02);
DBG_ON();
DBG_OFF();
wdt_reset();
if(++x<100000ULL) {
DBG(0x06);
return;
}
DBG(0x0A);
x = 0;
DBG_C('/');
//TCNT0=0xE0;
//EN_TIMER();
DBG(0x0B);
}