forked from vitperov/VTMotor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
54 lines (46 loc) · 1.26 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
/*
* This file is part of VTMotor (I2C motor driver)
*
* Copyright 2012 Vitaly Perov <[email protected]>
*
* VTMotor is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VTMotor. If not, see <http://www.gnu.org/licenses/>.
*/
#include <avr/io.h>
#include <avr/eeprom.h>
#include "motor.h"
#include "external/SMBSlave.h"
#include "storage.h"
/* TIMER */
inline void conf_TMR0()
{
/* set clock source f_t0 = f_io/8 = 1 MHz */
TCCR0 = _BV(CS01);
TIMSK |= _BV(TOIE0); /* Enable TMR0 interrupt */
}
inline void configure()
{
uint8_t addr = GetAddr();
// Initialize SMBus
SMBusInit(addr);
SMBEnable();
conf_TMR0();
conf_motors();
SREG |= _BV(7); /* Enable interrupts */
}
int main(void)
{
configure();
while (1);
return 0;
}