Caddy
A 2005 Roborodentia entry with vision and path planning capability
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Macros
Pages
src
caddy.c
Go to the documentation of this file.
1
/*
2
* This file is part of Caddy.
3
*
4
* Caddy is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* Caddy is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with Caddy. If not, see <http://www.gnu.org/licenses/>.
16
*/
21
#include "
robot_control.h
"
22
#include "
motor_control.h
"
23
#include "
camera.h
"
24
#include "
encoder.h
"
25
#include "
buttons.h
"
26
#include "
tweak_data.h
"
27
#include "utility.h"
28
#include "lcd_16x2.h"
29
30
// avr-libc
31
#include <avr/io.h>
32
37
#define START_DELAY 5
38
42
static
inline
void
initAtmel(
void
)
43
{
44
/*
45
* Initialize Timer
46
*/
47
timerInit();
48
49
#if DEBUGGING
50
/*
51
* Initialize LCD
52
*/
53
lcdInit();
54
lcdWriteStr(
"Init: "
, 0, 0);
55
lcdWriteStr(
" "
, 1, 0);
56
#endif
57
58
/*
59
* Initialize UART for CMUcam communication
60
*/
61
cmuCamInit
();
62
63
/*
64
* Initialize PWM motor control
65
*/
66
outb(DDRD, 0xff);
67
timer1PWMInit(8);
68
neutral();
69
enableMotors();
70
71
/*
72
* Set data direction registers
73
*/
74
outb(DDRA, 0xF0);
// Motor control and up/down buttons
75
cbi(DDRD, 6);
// red button
76
cbi(DDRB, 0);
// nest button
77
cbi(DDRB, 1);
// break beam
78
79
/*
80
* Apply internal pull-up resister to certain digital inputs
81
*/
82
sbi(PORTB, 0);
// internal pull-up for PINB0
83
sbi(PORTA, 3);
// internal pull-up for PINA3
84
sbi(PORTA, 2);
// internal pull-up for PINA2
85
sbi(PORTA, 1);
// internal pull-up for PINA1
86
sbi(PORTA, 0);
// internal pull-up for PINA0
87
88
/*
89
* Initialize quadrature wheel encoders
90
*/
91
cbi(DDRD, 2);
92
cbi(DDRD, 3);
93
encoderInit
();
94
}
95
99
int
main
(
void
)
100
{
101
initAtmel();
102
loadTweakValues();
103
initCamera
();
104
cameraWhiteBalance
();
105
106
#if DEBUGGING
107
runTetherUI();
108
myDelay(
START_DELAY
);
109
runTest();
110
#else
111
waitFor(RED_BUTTON);
112
myDelay(
START_DELAY
);
113
runRoborodentiaCourse
();
114
#endif
115
116
brake(BOTH_MOTORS);
117
#if DEBUGGING
118
lcdWriteStr(
"Done "
, 0, 0);
119
lcdWriteStr(
" "
, 1, 0);
120
#endif
121
122
return
0;
123
}
Generated on Wed Apr 10 2013 22:02:29 for Caddy by
1.8.1.2