-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmain.c
82 lines (62 loc) · 1.11 KB
/
main.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
78
79
80
81
82
/*
* Author: [email protected]
*/
#include "common.h"
#include "mdb.h"
void init_uart(void);
void init_io(void);
void killdog(void);
uint8_t mcusr_mirror __attribute__((section (".noinit")));
void get_mcusr(void) __attribute__((naked)) __attribute__((section(".init3")));
int main()
{
unsigned int i=0;
killdog();
init_io();
uart_init();
mdb_uart_init();
mdb_init();
mdb_billv_init();
sei();
for(;;)
{
// mdb_timer_set(500);
// while (!mdb_timer_is_shot());
cmdrecv_uart_tick();
mdb_polling();
_delay_ms(250);
}
cli();
wdt_enable(WDTO_500MS); /* should not run here */
for(;;);
}
void init_io()
{
/*
* PORTA
* all pins used as ADC input channel
*/
DDRA = 0x00;
PORTA = 0x00;
/*
* PORTB
*/
DDRB = 0xff;
PORTB = 0xff;
/*
* PORTC
*/
DDRC = 0x00;
PORTC = 0xff;
/*
* PORTD
*/
DDRD = 0xfa;
PORTD = 0xff;
}
void killdog(void)
{
mcusr_mirror = MCUSR;
MCUSR = 0;
wdt_disable();
}