Browse Source

Added AudioFirmware

Thomas Buck 12 years ago
parent
commit
8a5fcbf516
4 changed files with 471 additions and 1 deletions
  1. 44
    0
      AudioFirmware/main.c
  2. 419
    0
      AudioFirmware/makefile
  3. BIN
      Hardware/LED Cube.sch
  4. 8
    1
      makefile

+ 44
- 0
AudioFirmware/main.c View File

@@ -0,0 +1,44 @@
1
+/*
2
+ * main.c
3
+ *
4
+ * Copyright 2011 Thomas Buck <xythobuz@me.com>
5
+ * Copyright 2011 Max Nuding <max.nuding@gmail.com>
6
+ * Copyright 2011 Felix Bäder <baeder.felix@gmail.com>
7
+ *
8
+ * This file is part of LED-Cube.
9
+ *
10
+ * LED-Cube is free software: you can redistribute it and/or modify
11
+ * it under the terms of the GNU General Public License as published by
12
+ * the Free Software Foundation, either version 3 of the License, or
13
+ * (at your option) any later version.
14
+ *
15
+ * LED-Cube is distributed in the hope that it will be useful,
16
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
+ * GNU General Public License for more details.
19
+ *
20
+ * You should have received a copy of the GNU General Public License
21
+ * along with LED-Cube.  If not, see <http://www.gnu.org/licenses/>.
22
+ */
23
+#include <stdlib.h>
24
+#include <stdint.h>
25
+#include <avr/io.h>
26
+#include <util/delay.h>
27
+
28
+#ifndef F_CPU
29
+#define F_CPU 16000000L
30
+#endif
31
+
32
+int main(void) {
33
+	uint8_t i;
34
+
35
+	// Blink led :)
36
+	while (1) {
37
+		PORTB |= (1 << PB2);
38
+		_delay_ms(1000);
39
+		PORTB &= ~(1 << PB2);
40
+		_delay_ms(1000);
41
+	}
42
+
43
+	return 0;
44
+}

+ 419
- 0
AudioFirmware/makefile View File

@@ -0,0 +1,419 @@
1
+# Makefile
2
+#
3
+# On command line:
4
+#
5
+# make all = Make software.
6
+#
7
+# make clean = Clean out built project files.
8
+#
9
+# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
10
+#
11
+# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
12
+#                4.07 or greater).
13
+#
14
+# make program = Download the hex file to the device, using avrdude.  Please
15
+#                customize the avrdude settings below first!
16
+#
17
+# make filename.s = Just compile filename.c into the assembler code only
18
+#
19
+# To rebuild project do "make clean" then "make all".
20
+#
21
+
22
+
23
+# MCU name
24
+MCU = atmega8
25
+
26
+# Main Oscillator Frequency
27
+# This is only used to define F_OSC in all assembler and c-sources.
28
+F_CPU = 16000000
29
+
30
+# Output format. (can be srec, ihex, binary)
31
+FORMAT = ihex
32
+
33
+# Target file name (without extension).
34
+TARGET = main
35
+
36
+
37
+# List C source files here. (C dependencies are automatically generated.)
38
+SRC = $(TARGET).c
39
+#SRC += uart.c # Additional Source-File
40
+
41
+# List Assembler source files here.
42
+# Make them always end in a capital .S.  Files ending in a lowercase .s
43
+# will not be considered source files but generated files (assembler
44
+# output from the compiler), and will be deleted upon "make clean"!
45
+# Even though the DOS/Win* filesystem matches both .s and .S the same,
46
+# it will preserve the spelling of the filenames, and gcc itself does
47
+# care about how the name is spelled on its command-line.
48
+ASRC = 
49
+
50
+
51
+
52
+# Optimization level, can be [0, 1, 2, 3, s]. 
53
+# 0 = turn off optimization. s = optimize for size.
54
+# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
55
+OPT = s
56
+
57
+# Debugging format.
58
+# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
59
+# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
60
+#DEBUG = stabs
61
+DEBUG = dwarf-2
62
+
63
+# List any extra directories to look for include files here.
64
+#     Each directory must be seperated by a space.
65
+EXTRAINCDIRS = 
66
+
67
+
68
+# Compiler flag to set the C Standard level.
69
+# c89   - "ANSI" C
70
+# gnu89 - c89 plus GCC extensions
71
+# c99   - ISO C99 standard (not yet fully implemented)
72
+# gnu99 - c99 plus GCC extensions
73
+CSTANDARD = -std=gnu99
74
+
75
+# Place -D or -U options here
76
+CDEFS =
77
+
78
+# Place -I options here
79
+CINCS =
80
+
81
+
82
+# Compiler flags.
83
+#  -g*:          generate debugging information
84
+#  -O*:          optimization level
85
+#  -f...:        tuning, see GCC manual and avr-libc documentation
86
+#  -Wall...:     warning level
87
+#  -Wa,...:      tell GCC to pass this to the assembler.
88
+#    -adhlns...: create assembler listing
89
+CFLAGS = -g$(DEBUG)
90
+CFLAGS += $(CDEFS) $(CINCS)
91
+CFLAGS += -O$(OPT)
92
+CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
93
+CFLAGS += -Wall -Wstrict-prototypes
94
+CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
95
+CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
96
+CFLAGS += $(CSTANDARD)
97
+CFLAGS += -DF_CPU=$(F_CPU)
98
+
99
+
100
+
101
+# Assembler flags.
102
+#  -Wa,...:   tell GCC to pass this to the assembler.
103
+#  -ahlms:    create listing
104
+#  -gstabs:   have the assembler create line number information; note that
105
+#             for use in COFF files, additional information about filenames
106
+#             and function names needs to be present in the assembler source
107
+#             files -- see avr-libc docs [FIXME: not yet described there]
108
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs 
109
+ASFLAGS += -DF_CPU=$(F_CPU)
110
+
111
+
112
+#Additional libraries.
113
+
114
+# Minimalistic printf version
115
+PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
116
+
117
+# Floating point printf version (requires MATH_LIB = -lm below)
118
+PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
119
+
120
+PRINTF_LIB = 
121
+
122
+# Minimalistic scanf version
123
+SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
124
+
125
+# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
126
+SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
127
+
128
+SCANF_LIB = 
129
+
130
+MATH_LIB = -lm
131
+
132
+# External memory options
133
+
134
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
135
+# used for variables (.data/.bss) and heap (malloc()).
136
+#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
137
+
138
+# 64 KB of external RAM, starting after internal RAM (ATmega128!),
139
+# only used for heap (malloc()).
140
+#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
141
+
142
+EXTMEMOPTS =
143
+
144
+# Linker flags.
145
+#  -Wl,...:     tell GCC to pass this to linker.
146
+#    -Map:      create map file
147
+#    --cref:    add cross reference to  map file
148
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
149
+LDFLAGS += $(EXTMEMOPTS)
150
+LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
151
+
152
+
153
+
154
+
155
+# Programming support using avrdude. Settings and variables.
156
+
157
+# Programming hardware: alf avr910 avrisp bascom bsd 
158
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
159
+#
160
+# Type: avrdude -c ?
161
+# to get a full listing.
162
+#
163
+AVRDUDE_PROGRAMMER = stk500
164
+
165
+# com1 = serial port. Use lpt1 to connect to parallel port.
166
+AVRDUDE_PORT = com1    # programmer connected to serial device
167
+
168
+AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
169
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
170
+
171
+
172
+# Uncomment the following if you want avrdude's erase cycle counter.
173
+# Note that this counter needs to be initialized first using -Yn,
174
+# see avrdude manual.
175
+#AVRDUDE_ERASE_COUNTER = -y
176
+
177
+# Uncomment the following if you do /not/ wish a verification to be
178
+# performed after programming the device.
179
+#AVRDUDE_NO_VERIFY = -V
180
+
181
+# Increase verbosity level.  Please use this when submitting bug
182
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> 
183
+# to submit bug reports.
184
+#AVRDUDE_VERBOSE = -v -v
185
+
186
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
187
+AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
188
+AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
189
+AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
190
+
191
+
192
+
193
+# ---------------------------------------------------------------------------
194
+
195
+# Define directories, if needed.
196
+DIRAVR = /usr/local/CrossPack-AVR
197
+DIRAVRBIN = $(DIRAVR)/bin
198
+DIRAVRUTILS = $(DIRAVR)/bin
199
+DIRINC = .
200
+DIRLIB = $(DIRAVR)/lib
201
+
202
+
203
+# Define programs and commands.
204
+SHELL = bash
205
+CC = avr-gcc
206
+OBJCOPY = avr-objcopy
207
+OBJDUMP = avr-objdump
208
+SIZE = avr-size
209
+NM = avr-nm
210
+AVRDUDE = avrdude
211
+REMOVE = rm -f
212
+COPY = cp
213
+
214
+
215
+
216
+
217
+# Define Messages
218
+# English
219
+MSG_ERRORS_NONE = Errors: none
220
+MSG_BEGIN = -------- begin --------
221
+MSG_END = --------  end  --------
222
+MSG_SIZE_BEFORE = Size before: 
223
+MSG_SIZE_AFTER = Size after:
224
+MSG_COFF = Converting to AVR COFF:
225
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
226
+MSG_FLASH = Creating load file for Flash:
227
+MSG_EEPROM = Creating load file for EEPROM:
228
+MSG_EXTENDED_LISTING = Creating Extended Listing:
229
+MSG_SYMBOL_TABLE = Creating Symbol Table:
230
+MSG_LINKING = Linking:
231
+MSG_COMPILING = Compiling:
232
+MSG_ASSEMBLING = Assembling:
233
+MSG_CLEANING = Cleaning project:
234
+
235
+
236
+
237
+
238
+# Define all object files.
239
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) 
240
+
241
+# Define all listing files.
242
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
243
+
244
+
245
+# Compiler flags to generate dependency files.
246
+### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
247
+GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
248
+
249
+# Combine all necessary flags and optional flags.
250
+# Add target processor to flags.
251
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)
252
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
253
+
254
+
255
+
256
+
257
+
258
+# Default target.
259
+all: begin gccversion sizebefore build sizeafter finished end
260
+
261
+build: elf hex eep lss sym
262
+
263
+elf: $(TARGET).elf
264
+hex: $(TARGET).hex
265
+eep: $(TARGET).eep
266
+lss: $(TARGET).lss 
267
+sym: $(TARGET).sym
268
+
269
+
270
+
271
+# Eye candy.
272
+# AVR Studio 3.x does not check make's exit code but relies on
273
+# the following magic strings to be generated by the compile job.
274
+begin:
275
+	@echo
276
+	@echo $(MSG_BEGIN)
277
+
278
+finished:
279
+	@echo $(MSG_ERRORS_NONE)
280
+
281
+end:
282
+	@echo $(MSG_END)
283
+	@echo
284
+
285
+
286
+# Display size of file.
287
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
288
+ELFSIZE = $(SIZE) -A $(TARGET).elf
289
+sizebefore:
290
+	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
291
+
292
+sizeafter:
293
+	@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
294
+
295
+
296
+
297
+# Display compiler version information.
298
+gccversion : 
299
+	@$(CC) --version
300
+
301
+
302
+
303
+# Program the device.  
304
+program: $(TARGET).hex $(TARGET).eep
305
+	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
306
+
307
+
308
+
309
+
310
+# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
311
+COFFCONVERT=$(OBJCOPY) --debugging \
312
+--change-section-address .data-0x800000 \
313
+--change-section-address .bss-0x800000 \
314
+--change-section-address .noinit-0x800000 \
315
+--change-section-address .eeprom-0x810000 
316
+
317
+
318
+coff: $(TARGET).elf
319
+	@echo
320
+	@echo $(MSG_COFF) $(TARGET).cof
321
+	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
322
+
323
+
324
+extcoff: $(TARGET).elf
325
+	@echo
326
+	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof
327
+	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
328
+
329
+
330
+
331
+# Create final output files (.hex, .eep) from ELF output file.
332
+%.hex: %.elf
333
+	@echo
334
+	@echo $(MSG_FLASH) $@
335
+	$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
336
+
337
+%.eep: %.elf
338
+	@echo
339
+	@echo $(MSG_EEPROM) $@
340
+	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
341
+	--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
342
+
343
+# Create extended listing file from ELF output file.
344
+%.lss: %.elf
345
+	@echo
346
+	@echo $(MSG_EXTENDED_LISTING) $@
347
+	$(OBJDUMP) -h -S $< > $@
348
+
349
+# Create a symbol table from ELF output file.
350
+%.sym: %.elf
351
+	@echo
352
+	@echo $(MSG_SYMBOL_TABLE) $@
353
+	$(NM) -n $< > $@
354
+
355
+
356
+
357
+# Link: create ELF output file from object files.
358
+.SECONDARY : $(TARGET).elf
359
+.PRECIOUS : $(OBJ)
360
+%.elf: $(OBJ)
361
+	@echo
362
+	@echo $(MSG_LINKING) $@
363
+	$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
364
+
365
+
366
+# Compile: create object files from C source files.
367
+%.o : %.c
368
+	@echo
369
+	@echo $(MSG_COMPILING) $<
370
+	$(CC) -c $(ALL_CFLAGS) $< -o $@ 
371
+
372
+
373
+# Compile: create assembler files from C source files.
374
+%.s : %.c
375
+	$(CC) -S $(ALL_CFLAGS) $< -o $@
376
+
377
+
378
+# Assemble: create object files from assembler source files.
379
+%.o : %.S
380
+	@echo
381
+	@echo $(MSG_ASSEMBLING) $<
382
+	$(CC) -c $(ALL_ASFLAGS) $< -o $@
383
+
384
+
385
+
386
+# Target: clean project.
387
+clean: begin clean_list finished end
388
+
389
+clean_list :
390
+	@echo
391
+	@echo $(MSG_CLEANING)
392
+	$(REMOVE) $(TARGET).hex
393
+	$(REMOVE) $(TARGET).eep
394
+	$(REMOVE) $(TARGET).obj
395
+	$(REMOVE) $(TARGET).cof
396
+	$(REMOVE) $(TARGET).elf
397
+	$(REMOVE) $(TARGET).map
398
+	$(REMOVE) $(TARGET).obj
399
+	$(REMOVE) $(TARGET).a90
400
+	$(REMOVE) $(TARGET).sym
401
+	$(REMOVE) $(TARGET).lnk
402
+	$(REMOVE) $(TARGET).lss
403
+	$(REMOVE) $(OBJ)
404
+	$(REMOVE) $(LST)
405
+	$(REMOVE) $(SRC:.c=.s)
406
+	$(REMOVE) $(SRC:.c=.d)
407
+	$(REMOVE) .dep/*
408
+
409
+
410
+
411
+# Include the dependency files.
412
+-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
413
+
414
+
415
+# Listing of phony targets.
416
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
417
+build elf hex eep lss sym coff extcoff \
418
+clean clean_list program
419
+

BIN
Hardware/LED Cube.sch View File


+ 8
- 1
makefile View File

@@ -1,4 +1,4 @@
1
-all: Control Firmware
1
+all: Control Firmware Audio
2 2
 
3 3
 Control:
4 4
 	make -C CubeControl
@@ -10,6 +10,11 @@ else
10 10
 endif
11 11
 	make -C CubeControl clean
12 12
 
13
+Audio:
14
+	make -C AudioFirmware
15
+	mv AudioFirmware/main.hex AudioFirmware.hex
16
+	make -C AudioFirmware clean
17
+
13 18
 Firmware:
14 19
 	make -C CubeFirmware
15 20
 	mv CubeFirmware/main.hex CubeFirmware.hex
@@ -19,9 +24,11 @@ clean:
19 24
 ifdef SystemRoot
20 25
 	del CubeControl.jar
21 26
 	del CubeFirmware.hex
27
+	del AudioFirmware.hex
22 28
 	del Serial.dll
23 29
 else
24 30
 	rm -f CubeControl.jar
25 31
 	rm -f CubeFirmware.hex
32
+	rm -f AudioFirmware.hex
26 33
 	rm -f libSerial.jnilib
27 34
 endif

Loading…
Cancel
Save