Skip to content

Commit 58ac7c6

Browse files
committed
Inital commit
0 parents  commit 58ac7c6

File tree

6 files changed

+996
-0
lines changed

6 files changed

+996
-0
lines changed

Makefile

Lines changed: 316 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,316 @@
1+
2+
######### AVR Project Makefile Template #########
3+
###### ######
4+
###### Copyright (C) 2003-2005,Pat Deegan, ######
5+
###### Psychogenic Inc ######
6+
###### All Rights Reserved ######
7+
###### ######
8+
###### You are free to use this code as part ######
9+
###### of your own applications provided ######
10+
###### you keep this copyright notice intact ######
11+
###### and acknowledge its authorship with ######
12+
###### the words: ######
13+
###### ######
14+
###### "Contains software by Pat Deegan of ######
15+
###### Psychogenic Inc (www.psychogenic.com)" ######
16+
###### ######
17+
###### If you use it as part of a web site ######
18+
###### please include a link to our site, ######
19+
###### http://electrons.psychogenic.com or ######
20+
###### http://www.psychogenic.com ######
21+
###### ######
22+
####################################################
23+
24+
25+
##### This Makefile will make compiling Atmel AVR
26+
##### micro controller projects simple with Linux
27+
##### or other Unix workstations and the AVR-GCC
28+
##### tools.
29+
#####
30+
##### It supports C, C++ and Assembly source files.
31+
#####
32+
##### Customize the values as indicated below and :
33+
##### make
34+
##### make disasm
35+
##### make stats
36+
##### make hex
37+
##### make writeflash
38+
##### make gdbinit
39+
##### or make clean
40+
#####
41+
##### See the http://electrons.psychogenic.com/
42+
##### website for detailed instructions
43+
44+
45+
####################################################
46+
##### #####
47+
##### Configuration #####
48+
##### #####
49+
##### Customize the values in this section for #####
50+
##### your project. MCU, PROJECTNAME and #####
51+
##### PRJSRC must be setup for all projects, #####
52+
##### the remaining variables are only #####
53+
##### relevant to those needing additional #####
54+
##### include dirs or libraries and those #####
55+
##### who wish to use the avrdude programmer #####
56+
##### #####
57+
##### See http://electrons.psychogenic.com/ #####
58+
##### for further details. #####
59+
##### #####
60+
####################################################
61+
62+
63+
##### Target Specific Details #####
64+
##### Customize these for your project #####
65+
66+
# Name of target controller
67+
# (e.g. 'at90s8515', see the available avr-gcc mmcu
68+
# options for possible values)
69+
MCU=atmega328p
70+
71+
# id to use with programmer
72+
# default: PROGRAMMER_MCU=$(MCU)
73+
# In case the programer used, e.g avrdude, doesn't
74+
# accept the same MCU name as avr-gcc (for example
75+
# for ATmega8s, avr-gcc expects 'atmega8' and
76+
# avrdude requires 'm8')
77+
PROGRAMMER_MCU=m328p
78+
79+
# Name of our project
80+
# (use a single word, e.g. 'myproject')
81+
PROJECTNAME=ov7670NoRam
82+
83+
# Source files
84+
# List C/C++/Assembly source files:
85+
# (list all files to compile, e.g. 'a.c b.cpp as.S'):
86+
# Use .cc, .cpp or .C suffix for C++ files, use .S
87+
# (NOT .s !!!) for assembly source code files.
88+
PRJSRC=main.c ov7670.c
89+
90+
# additional includes (e.g. -I/path/to/mydir)
91+
INC=
92+
93+
# libraries to link in (e.g. -lmylib)
94+
LIBS=
95+
96+
# Optimization level,
97+
# use s (size opt), 1, 2, 3 or 0 (off)
98+
OPTLEVEL=2
99+
100+
101+
##### AVR Dude 'writeflash' options #####
102+
##### If you are using the avrdude program
103+
##### (http://www.bsdhome.com/avrdude/) to write
104+
##### to the MCU, you can set the following config
105+
##### options and use 'make writeflash' to program
106+
##### the device.
107+
108+
109+
# programmer id--check the avrdude for complete list
110+
# of available opts. These should include stk500,
111+
# avr910, avrisp, bsd, pony and more. Set this to
112+
# one of the valid "-c PROGRAMMER-ID" values
113+
# described in the avrdude info page.
114+
#
115+
AVRDUDE_PROGRAMMERID=arduino
116+
117+
# port--serial or parallel port to which your
118+
# hardware programmer is attached
119+
#
120+
AVRDUDE_PORT=/dev/ttyACM0
121+
122+
123+
####################################################
124+
##### Config Done #####
125+
##### #####
126+
##### You shouldn't need to edit anything #####
127+
##### below to use the makefile but may wish #####
128+
##### to override a few of the flags #####
129+
##### nonetheless #####
130+
##### #####
131+
####################################################
132+
133+
134+
##### Flags ####
135+
136+
# HEXFORMAT -- format for .hex file output
137+
HEXFORMAT=ihex
138+
139+
# compiler
140+
CFLAGS=-L/usr/lib64/binutils/avr/2.23.1/ldscripts/ -I. $(INC) -g -mmcu=$(MCU) -O$(OPTLEVEL) -flto \
141+
-fpack-struct -fshort-enums \
142+
-funsigned-bitfields -funsigned-char \
143+
-Wall -Wstrict-prototypes \
144+
-Wa,-ahlms=$(firstword \
145+
$(filter %.lst, $(<:.c=.lst)))
146+
147+
# c++ specific flags
148+
CPPFLAGS=-fno-exceptions -flto\
149+
-Wa,-ahlms=$(firstword \
150+
$(filter %.lst, $(<:.cpp=.lst))\
151+
$(filter %.lst, $(<:.cc=.lst)) \
152+
$(filter %.lst, $(<:.C=.lst)))
153+
154+
# assembler
155+
ASMFLAGS =-I. $(INC) -mmcu=$(MCU) \
156+
-x assembler-with-cpp \
157+
-Wa,-gstabs,-ahlms=$(firstword \
158+
$(<:.S=.lst) $(<.s=.lst))
159+
160+
161+
# linker
162+
LDFLAGS=-L/usr/lib64/binutils/avr/2.23.1/ldscripts/ -Wl,-gc-sections,-Map,$(TRG).map -mmcu=$(MCU) -flto -O$(OPTLEVEL) $(LIBS)
163+
164+
##### executables ####
165+
CC=avr-gcc
166+
OBJCOPY=avr-objcopy
167+
OBJDUMP=avr-objdump
168+
SIZE=avr-size
169+
AVRDUDE=avrdude
170+
REMOVE=rm -f
171+
172+
##### automatic target names ####
173+
TRG=$(PROJECTNAME).out
174+
DUMPTRG=$(PROJECTNAME).s
175+
176+
HEXROMTRG=$(PROJECTNAME).hex
177+
HEXTRG=$(HEXROMTRG) $(PROJECTNAME).ee.hex
178+
GDBINITFILE=gdbinit-$(PROJECTNAME)
179+
180+
# Define all object files.
181+
182+
# Start by splitting source files by type
183+
# C++
184+
CPPFILES=$(filter %.cpp, $(PRJSRC))
185+
CCFILES=$(filter %.cc, $(PRJSRC))
186+
BIGCFILES=$(filter %.C, $(PRJSRC))
187+
# C
188+
CFILES=$(filter %.c, $(PRJSRC))
189+
# Assembly
190+
ASMFILES=$(filter %.S, $(PRJSRC))
191+
192+
193+
# List all object files we need to create
194+
OBJDEPS=$(CFILES:.c=.o) \
195+
$(CPPFILES:.cpp=.o)\
196+
$(BIGCFILES:.C=.o) \
197+
$(CCFILES:.cc=.o) \
198+
$(ASMFILES:.S=.o)
199+
200+
# Define all lst files.
201+
LST=$(filter %.lst, $(OBJDEPS:.o=.lst))
202+
203+
# All the possible generated assembly
204+
# files (.s files)
205+
GENASMFILES=$(filter %.s, $(OBJDEPS:.o=.s))
206+
207+
208+
.SUFFIXES : .c .cc .cpp .C .o .out .s .S \
209+
.hex .ee.hex .h .hh .hpp
210+
211+
212+
.PHONY: writeflash clean stats gdbinit stats
213+
214+
# Make targets:
215+
# all, disasm, stats, hex, writeflash/install, clean
216+
all: $(TRG)
217+
218+
disasm: $(DUMPTRG) stats
219+
220+
stats: $(TRG)
221+
$(OBJDUMP) -h $(TRG)
222+
$(SIZE) $(TRG)
223+
224+
hex: $(HEXTRG)
225+
226+
227+
writeflash: hex
228+
$(AVRDUDE) -c $(AVRDUDE_PROGRAMMERID) \
229+
-p $(PROGRAMMER_MCU) -P $(AVRDUDE_PORT) -e \
230+
-U flash:w:$(HEXROMTRG)
231+
232+
install: writeflash
233+
234+
$(DUMPTRG): $(TRG)
235+
$(OBJDUMP) -S $< > $@
236+
237+
238+
$(TRG): $(OBJDEPS)
239+
$(CC) $(LDFLAGS) -o $(TRG) $(OBJDEPS)
240+
241+
242+
#### Generating assembly ####
243+
# asm from C
244+
%.s: %.c
245+
$(CC) -S $(CFLAGS) $< -o $@
246+
247+
# asm from (hand coded) asm
248+
%.s: %.S
249+
$(CC) -S $(ASMFLAGS) $< > $@
250+
251+
252+
# asm from C++
253+
.cpp.s .cc.s .C.s :
254+
$(CC) -S $(CFLAGS) $(CPPFLAGS) $< -o $@
255+
256+
257+
258+
#### Generating object files ####
259+
# object from C
260+
.c.o:
261+
$(CC) $(CFLAGS) -c $< -o $@
262+
263+
264+
# object from C++ (.cc, .cpp, .C files)
265+
.cc.o .cpp.o .C.o :
266+
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
267+
268+
# object from asm
269+
.S.o :
270+
$(CC) $(ASMFLAGS) -c $< -o $@
271+
272+
273+
#### Generating hex files ####
274+
# hex files from elf
275+
##### Generating a gdb initialisation file #####
276+
.out.hex:
277+
$(OBJCOPY) -j .text \
278+
-j .data \
279+
-O $(HEXFORMAT) $< $@
280+
281+
.out.ee.hex:
282+
$(OBJCOPY) -j .eeprom \
283+
--change-section-lma .eeprom=0 \
284+
-O $(HEXFORMAT) $< $@
285+
286+
287+
##### Generating a gdb initialisation file #####
288+
##### Use by launching simulavr and avr-gdb: #####
289+
##### avr-gdb -x gdbinit-myproject #####
290+
gdbinit: $(GDBINITFILE)
291+
292+
$(GDBINITFILE): $(TRG)
293+
@echo "file $(TRG)" > $(GDBINITFILE)
294+
295+
@echo "target remote localhost:1212" \
296+
>> $(GDBINITFILE)
297+
298+
@echo "load" >> $(GDBINITFILE)
299+
@echo "break main" >> $(GDBINITFILE)
300+
@echo "continue" >> $(GDBINITFILE)
301+
@echo
302+
@echo "Use 'avr-gdb -x $(GDBINITFILE)'"
303+
304+
305+
#### Cleanup ####
306+
clean:
307+
$(REMOVE) $(TRG) $(TRG).map $(DUMPTRG)
308+
$(REMOVE) $(OBJDEPS)
309+
$(REMOVE) $(LST) $(GDBINITFILE)
310+
$(REMOVE) $(GENASMFILES)
311+
$(REMOVE) $(HEXTRG)
312+
313+
314+
315+
##### EOF #####
316+

README

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
This is a version of code that sends data to the PC.
2+
Unlike previous code this requries no external ram or fifo.
3+
It just sends the data as it recevices it.
4+
The transfer rate is .5 mbps or 64kbytes per second
5+
Connections
6+
Order arduino ov7670
7+
A5->SIOC
8+
A4<->SIOD
9+
11-> (convert 5v to 3.3v) XCLK
10+
A0<-0
11+
A1<-1
12+
A2<-2
13+
A3<-3
14+
4<-4
15+
5<-5
16+
6<-6
17+
7<-7
18+
3<-VSYNC
19+
2<-PCLK

0 commit comments

Comments
 (0)