parent
be4e83bad5
commit
d1383b45bc
@ -0,0 +1,20 @@
|
||||
Lab1 programs
|
||||
lab1-ex1 Flash LED by writing to port registers
|
||||
lab1-ex2 Flash LED, using helper functions to write to port registers directly
|
||||
lab1-ex3 Flash LED, using helper functions in module led1.c to write to port registers directly
|
||||
lab1-ex4 Flash LED, using helper functions in module led1.c to write to port registers using pio abstraction
|
||||
lab1-ex5 Flash LED, using led device driver
|
||||
|
||||
Lab2 programs
|
||||
lab2-ex1 Implement paced loop by writing to timer/counter1 registers directly
|
||||
lab2-ex2 Implement paced loop, using helper functions in mypacer.c by writing to timer/counter1 registers directly
|
||||
lab2-ex3 Implement paced loop using pacer.c
|
||||
lab2-ex4 Flash LED in LED matrix
|
||||
lab2-ex5 Output pattern by multiplexing LED matrix
|
||||
|
||||
Lab3 programs
|
||||
lab3-ex1 Reimplement stopwatch program using paced loop.
|
||||
lab3-ex2 Hello world!
|
||||
lab3-ex3 Using the navswitch
|
||||
lab3-ex4 Using the navswitch and IR communications.
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab1-ex1
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab1-ex1.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab1-ex1.o: lab1-ex1.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab1-ex1.out: lab1-ex1.o system.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab1-ex1.out
|
||||
$(OBJCOPY) -O ihex lab1-ex1.out lab1-ex1.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab1-ex1.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex1 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,20 @@
|
||||
#include <avr/io.h>
|
||||
#include "system.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init ();
|
||||
|
||||
/* Initialise port to drive LED 1. */
|
||||
|
||||
/* TODO. */
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
/* Turn LED 1 on. */
|
||||
|
||||
/* TODO. */
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab1-ex2
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab1-ex2.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab1-ex2.o: lab1-ex2.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab1-ex2.out: lab1-ex2.o system.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab1-ex2.out
|
||||
$(OBJCOPY) -O ihex lab1-ex2.out lab1-ex2.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab1-ex2.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex2 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,64 @@
|
||||
#include <avr/io.h>
|
||||
#include "system.h"
|
||||
|
||||
|
||||
static void led_init (void)
|
||||
{
|
||||
/* Initialise port to drive LED 1. */
|
||||
|
||||
/* TODO. */
|
||||
}
|
||||
|
||||
|
||||
static void led_on (void)
|
||||
{
|
||||
/* Set port to turn LED 1 on. */
|
||||
|
||||
/* TODO. */
|
||||
}
|
||||
|
||||
|
||||
static void led_off (void)
|
||||
{
|
||||
/* Set port to turn LED 1 off. */
|
||||
|
||||
/* TODO. */
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void button_init (void)
|
||||
{
|
||||
/* Initialise port to read button 1. */
|
||||
|
||||
/* TODO. */
|
||||
}
|
||||
|
||||
|
||||
static int button_pressed_p (void)
|
||||
{
|
||||
/* Return non-zero if button pressed_p. */
|
||||
|
||||
/* TODO. */
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init ();
|
||||
|
||||
led_init ();
|
||||
button_init ();
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (button_pressed_p ())
|
||||
{
|
||||
led_on ();
|
||||
}
|
||||
else
|
||||
{
|
||||
led_off ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab1-ex3
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I. -I../../drivers/avr
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab1-ex3.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab1-ex3.o: lab1-ex3.c ../../drivers/avr/system.h button.h led.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
button.o: button.c button.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
led.o: led.c led.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab1-ex3.out: lab1-ex3.o system.o button.o led.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab1-ex3.out
|
||||
$(OBJCOPY) -O ihex lab1-ex3.out lab1-ex3.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab1-ex3.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for lab1-lab1-ex3
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wstrict-prototypes -Wlab1-extra -g -I. -I../../drivers/test
|
||||
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab1-lab1-ex3
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab1-lab1-ex3-test.o: lab1-lab1-ex3.c ../../drivers/test/system.h io.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio-test.o: ../../drivers/test/pio.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system-test.o: ../../drivers/test/system.c ../../drivers/test/avrtest.h ../../drivers/test/mgetkey.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
io-test.o: io.c io.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
|
||||
# Link: create lab1-executable file from object files.
|
||||
lab1-lab1-ex3: lab1-lab1-ex3-test.o mgetkey-test.o pio-test.o system-test.o io-test.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) lab1-lab1-ex3 lab1-lab1-ex3-test.o mgetkey-test.o pio-test.o system-test.o io-test.o
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
#include <avr/io.h>
|
||||
#include "button.h"
|
||||
|
||||
|
||||
/** Return non-zero if button pressed. */
|
||||
int button_pressed_p (void)
|
||||
{
|
||||
/* TODO. */
|
||||
}
|
||||
|
||||
|
||||
/** Initialise button1. */
|
||||
void button_init (void)
|
||||
{
|
||||
/* TODO. */
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
#ifndef BUTTON_H
|
||||
#define BUTTON_H
|
||||
|
||||
|
||||
/** Return non-zero if button pressed. */
|
||||
int button_pressed_p (void);
|
||||
|
||||
|
||||
/** Initialise button1. */
|
||||
void button_init (void);
|
||||
#endif
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex3 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,24 @@
|
||||
#include "button.h"
|
||||
#include "led.h"
|
||||
#include "system.h"
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init ();
|
||||
|
||||
led_init ();
|
||||
button_init ();
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (button_pressed_p ())
|
||||
{
|
||||
led_on ();
|
||||
}
|
||||
else
|
||||
{
|
||||
led_off ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
#include <avr/io.h>
|
||||
#include "led.h"
|
||||
|
||||
|
||||
/** Turn LED1 on. */
|
||||
void led_on (void)
|
||||
{
|
||||
/* TODO! */
|
||||
}
|
||||
|
||||
|
||||
/** Turn LED1 off. */
|
||||
void led_off (void)
|
||||
{
|
||||
/* TODO! */
|
||||
}
|
||||
|
||||
|
||||
/** Initialise LED1. */
|
||||
void led_init (void)
|
||||
{
|
||||
/* TODO! */
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
/** Turn LED1 on. */
|
||||
void led_on (void);
|
||||
|
||||
|
||||
/** Turn LED1 off. */
|
||||
void led_off (void);
|
||||
|
||||
|
||||
/** Initialise LED1. */
|
||||
void led_init (void);
|
||||
#endif
|
||||
@ -0,0 +1,54 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab1-ex4
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I. -I../../drivers/avr
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab1-ex4.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab1-ex4.o: lab1-ex4.c ../../drivers/avr/system.h button.h led.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
button.o: button.c ../../drivers/avr/pio.h ../../drivers/avr/system.h button.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
led.o: led.c ../../drivers/avr/pio.h ../../drivers/avr/system.h led.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab1-ex4.out: lab1-ex4.o pio.o system.o button.o led.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab1-ex4.out
|
||||
$(OBJCOPY) -O ihex lab1-ex4.out lab1-ex4.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab1-ex4.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for lab1-ex4
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wstrict-prototypes -Wlab1-extra -g -I. -I../../drivers/test
|
||||
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab1-ex4
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab1-ex4-test.o: lab1-ex4.c ../../drivers/test/system.h button.h led.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio-test.o: ../../drivers/test/pio.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system-test.o: ../../drivers/test/system.c ../../drivers/test/avrtest.h ../../drivers/test/mgetkey.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
button-test.o: button.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h button.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
led-test.o: led.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h led.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
|
||||
# Link: create lab1-executable file from object files.
|
||||
lab1-ex4: lab1-ex4-test.o mgetkey-test.o pio-test.o system-test.o button-test.o led-test.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) lab1-ex4 lab1-ex4-test.o mgetkey-test.o pio-test.o system-test.o button-test.o led-test.o
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
#include "pio.h"
|
||||
#include "button.h"
|
||||
|
||||
/** Return non-zero if button pressed. */
|
||||
int button_pressed_p (void)
|
||||
{
|
||||
/* TODO. */
|
||||
}
|
||||
|
||||
|
||||
/** Initialise button1. */
|
||||
void button_init (void)
|
||||
{
|
||||
/* TODO. */
|
||||
}
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
#ifndef BUTTON_H
|
||||
#define BUTTON_H
|
||||
|
||||
|
||||
/** Return non-zero if button pressed. */
|
||||
int button_pressed_p (void);
|
||||
|
||||
|
||||
/** Initialise button1. */
|
||||
void button_init (void);
|
||||
#endif
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex4 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,24 @@
|
||||
#include "button.h"
|
||||
#include "led.h"
|
||||
#include "system.h"
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init ();
|
||||
|
||||
led_init ();
|
||||
button_init ();
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (button_pressed_p ())
|
||||
{
|
||||
led_on ();
|
||||
}
|
||||
else
|
||||
{
|
||||
led_off ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
#include "pio.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
/** Turn LED1 on. */
|
||||
void led_on (void)
|
||||
{
|
||||
/* TODO! */
|
||||
}
|
||||
|
||||
|
||||
/** Turn LED1 off. */
|
||||
void led_off (void)
|
||||
{
|
||||
/* TODO! */
|
||||
}
|
||||
|
||||
|
||||
/** Initialise LED1. */
|
||||
void led_init (void)
|
||||
{
|
||||
/* TODO! */
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
/** Turn LED1 on. */
|
||||
void led_on (void);
|
||||
|
||||
|
||||
/** Turn LED1 off. */
|
||||
void led_off (void);
|
||||
|
||||
|
||||
/** Initialise LED1. */
|
||||
void led_init (void);
|
||||
#endif
|
||||
@ -0,0 +1,48 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab1-ex5
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab1-ex5.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab1-ex5.o: lab1-ex5.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab1-ex5.out: lab1-ex5.o pio.o system.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab1-ex5.out
|
||||
$(OBJCOPY) -O ihex lab1-ex5.out lab1-ex5.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab1-ex5.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,43 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for lab1-ex5
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wstrict-prototypes -Wlab1-extra -g -I../../drivers/test
|
||||
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab1-ex5
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab1-ex5-test.o: lab1-ex5.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio-test.o: ../../drivers/test/pio.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system-test.o: ../../drivers/test/system.c ../../drivers/test/avrtest.h ../../drivers/test/mgetkey.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
|
||||
# Link: create lab1-executable file from object files.
|
||||
lab1-ex5: lab1-ex5-test.o mgetkey-test.o pio-test.o system-test.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) lab1-ex5 lab1-ex5-test.o mgetkey-test.o pio-test.o system-test.o
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex5 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,16 @@
|
||||
#include "pio.h"
|
||||
#include "system.h"
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init ();
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
/* TODO. Use PIO module to turn on LEDs in
|
||||
LED matrix. */
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab2-ex1
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr -I../../drivers
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab2-ex1.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab2-ex1.o: lab2-ex1.c ../../drivers/avr/system.h ../../drivers/led.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
led.o: ../../drivers/led.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/led.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab2-ex1.out: lab2-ex1.o pio.o system.o led.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab2-ex1.out
|
||||
$(OBJCOPY) -O ihex lab2-ex1.out lab2-ex1.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab2-ex1.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex1 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,28 @@
|
||||
#include <avr/io.h>
|
||||
#include "system.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init ();
|
||||
led_init ();
|
||||
|
||||
/* TODO: Initialise timer/counter1. */
|
||||
|
||||
while (1)
|
||||
{
|
||||
|
||||
/* Turn LED on. */
|
||||
led_set (LED1, 1);
|
||||
|
||||
/* TODO: wait for 500 milliseconds. */
|
||||
|
||||
/* Turn LED off. */
|
||||
led_set (LED1, 0);
|
||||
|
||||
/* TODO: wait for 500 milliseconds. */
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab2-ex2
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I. -I../../drivers/avr -I../../drivers
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab2-ex2.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab2-ex2.o: lab2-ex2.c ../../drivers/avr/system.h ../../drivers/led.h timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
led.o: ../../drivers/led.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/led.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer.o: timer.c ../../drivers/avr/system.h timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab2-ex2.out: lab2-ex2.o pio.o system.o led.o timer.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab2-ex2.out
|
||||
$(OBJCOPY) -O ihex lab2-ex2.out lab2-ex2.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab2-ex2.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex2 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,28 @@
|
||||
#include "system.h"
|
||||
#include "led.h"
|
||||
|
||||
#include "timer.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init ();
|
||||
led_init ();
|
||||
|
||||
/* Initialise timer. */
|
||||
timer_init ();
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Turn LED on. */
|
||||
led_set (LED1, 1);
|
||||
|
||||
/* Wait 500ms. */
|
||||
timer_delay_ms (500);
|
||||
|
||||
/* Turn LED off. */
|
||||
led_set (LED1, 0);
|
||||
|
||||
/* Wait 500ms. */
|
||||
timer_delay_ms (500);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
#include <avr/io.h>
|
||||
#include "timer.h"
|
||||
|
||||
/* Initialise timer. */
|
||||
void timer_init (void)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
|
||||
/* Wait for the specified length of time. */
|
||||
void timer_delay_ms (uint16_t milliseconds)
|
||||
{
|
||||
/* TODO: Calculate the timer/counter value needed
|
||||
for the given number of milliseconds. */
|
||||
|
||||
/* TODO: Wait for the timer/couter to reach the
|
||||
value calculated above. */
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
#ifndef TIMER_H
|
||||
#define TIMER_H
|
||||
|
||||
#include "system.h"
|
||||
|
||||
/* Initialise timer. */
|
||||
void timer_init (void);
|
||||
|
||||
|
||||
/* Wait for the specified length of time. */
|
||||
void timer_delay_ms (uint16_t milliseconds);
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,54 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab2-ex3
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I. -I../../drivers/avr -I../../drivers
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab2-ex3.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab2-ex3.o: lab2-ex3.c ../../drivers/avr/system.h ../../drivers/led.h pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
led.o: ../../drivers/led.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/led.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer.o: pacer.c ../../drivers/avr/system.h pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab2-ex3.out: lab2-ex3.o pio.o system.o led.o pacer.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab2-ex3.out
|
||||
$(OBJCOPY) -O ihex lab2-ex3.out lab2-ex3.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab2-ex3.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex3 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,25 @@
|
||||
#include "system.h"
|
||||
#include "led.h"
|
||||
#include "pacer.h"
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
uint8_t state = 0;
|
||||
|
||||
system_init ();
|
||||
led_init ();
|
||||
|
||||
/* Set up pacer with a frequency of 2 Hz. */
|
||||
pacer_init (2);
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Pace the loop. */
|
||||
pacer_wait ();
|
||||
|
||||
/* Toggle LED. */
|
||||
led_set (LED1, state);
|
||||
state = !state;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
#include <avr/io.h>
|
||||
#include "pacer.h"
|
||||
|
||||
static uint16_t pacer_period;
|
||||
|
||||
/* Initialise the pacer module. */
|
||||
void pacer_init (uint16_t pacer_frequency)
|
||||
{
|
||||
/* TODO: initialise timer/counter peripheral the
|
||||
same way as in lab2/lab2-ex2/timer.c but also calculate
|
||||
the timer/counter value from the pacer frequency */
|
||||
}
|
||||
|
||||
|
||||
/* Pace a while loop. */
|
||||
void pacer_wait (void)
|
||||
{
|
||||
|
||||
/* TODO: Implement the same way as the timer_delay () function
|
||||
lab2-except reset TCNT1 after the while loop. */
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
#ifndef PACER_H
|
||||
#define PACER_H
|
||||
|
||||
#include "system.h"
|
||||
|
||||
/* Initialise the pacer module. */
|
||||
void pacer_init (uint16_t pacer_frequency);
|
||||
|
||||
|
||||
/* Pace a while loop. */
|
||||
void pacer_wait (void);
|
||||
|
||||
#endif //PACER_H
|
||||
@ -0,0 +1,51 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab2-ex4
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I. -I../../drivers/avr
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab2-ex4.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab2-ex4.o: lab2-ex4.c ../../drivers/avr/pio.h ../../drivers/avr/system.h pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer.o: pacer.c ../../drivers/avr/system.h pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab2-ex4.out: lab2-ex4.o pio.o system.o pacer.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab2-ex4.out
|
||||
$(OBJCOPY) -O ihex lab2-ex4.out lab2-ex4.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab2-ex4.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex4 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,26 @@
|
||||
#include "system.h"
|
||||
#include "pio.h"
|
||||
|
||||
/* Include the pacer module from the previous lab.
|
||||
You must have completed this before starting this lab2-exercise. */
|
||||
#include "pacer.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init ();
|
||||
|
||||
/* TODO: Initialise the pins of the LED matrix. */
|
||||
|
||||
|
||||
/* Set up pacer with a frequency of 50 Hz. */
|
||||
pacer_init (50);
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* Pace the loop. */
|
||||
pacer_wait ();
|
||||
|
||||
/* TODO: Drive the LED matrix using the pio functions,
|
||||
displaying only three corner LEDs. */
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
#include <avr/io.h>
|
||||
#include "pacer.h"
|
||||
|
||||
static uint16_t pacer_period;
|
||||
|
||||
/* Initialise the pacer module. */
|
||||
void pacer_init (uint16_t pacer_frequency)
|
||||
{
|
||||
/* TODO: initialise timer/counter peripheral the
|
||||
same way as in lab2/lab2-ex2/timer.c but also calculate
|
||||
the timer/counter value from the pacer frequency */
|
||||
}
|
||||
|
||||
|
||||
/* Pace a while loop. */
|
||||
void pacer_wait (void)
|
||||
{
|
||||
|
||||
/* TODO: Implement the same way as the timer_delay () function
|
||||
lab2-except reset TCNT1 after the while loop. */
|
||||
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
#ifndef PACER_H
|
||||
#define PACER_H
|
||||
|
||||
#include "system.h"
|
||||
|
||||
/* Initialise the pacer module. */
|
||||
void pacer_init (uint16_t pacer_frequency);
|
||||
|
||||
|
||||
/* Pace a while loop. */
|
||||
void pacer_wait (void);
|
||||
|
||||
#endif //PACER_H
|
||||
@ -0,0 +1,54 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab2-ex5
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr -I../../utils
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab2-ex5.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab2-ex5.o: lab2-ex5.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer.o: ../../drivers/avr/timer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer.o: ../../utils/pacer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab2-ex5.out: lab2-ex5.o pio.o system.o timer.o pacer.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab2-ex5.out
|
||||
$(OBJCOPY) -O ihex lab2-ex5.out lab2-ex5.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab2-ex5.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for lab2-ex5
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wstrict-prototypes -Wlab2-extra -g -I../../drivers/test -I../../utils
|
||||
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab2-ex5
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab2-ex5-test.o: lab2-ex5.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio-test.o: ../../drivers/test/pio.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system-test.o: ../../drivers/test/system.c ../../drivers/test/avrtest.h ../../drivers/test/mgetkey.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer-test.o: ../../drivers/test/timer.c ../../drivers/test/system.h ../../drivers/test/timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer-test.o: ../../utils/pacer.c ../../drivers/test/system.h ../../drivers/test/timer.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
|
||||
# Link: create lab2-executable file from object files.
|
||||
lab2-ex5: lab2-ex5-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o pacer-test.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) lab2-ex5 lab2-ex5-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o pacer-test.o
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex5 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,61 @@
|
||||
#include "system.h"
|
||||
#include "pio.h"
|
||||
#include "pacer.h"
|
||||
|
||||
|
||||
/** Define PIO pins driving LED matrix rows. */
|
||||
static const pio_t rows[] =
|
||||
{
|
||||
LEDMAT_ROW1_PIO, LEDMAT_ROW2_PIO, LEDMAT_ROW3_PIO,
|
||||
LEDMAT_ROW4_PIO, LEDMAT_ROW5_PIO, LEDMAT_ROW6_PIO,
|
||||
LEDMAT_ROW7_PIO
|
||||
};
|
||||
|
||||
|
||||
/** Define PIO pins driving LED matrix columns. */
|
||||
static const pio_t cols[] =
|
||||
{
|
||||
LEDMAT_COL1_PIO, LEDMAT_COL2_PIO, LEDMAT_COL3_PIO,
|
||||
LEDMAT_COL4_PIO, LEDMAT_COL5_PIO
|
||||
};
|
||||
|
||||
|
||||
static const uint8_t bitmap[] =
|
||||
{
|
||||
0x30, 0x46, 0x40, 0x46, 0x30
|
||||
};
|
||||
|
||||
|
||||
|
||||
static void display_column (uint8_t row_pattern, uint8_t current_column)
|
||||
{
|
||||
|
||||
/* TODO */
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
uint8_t current_column = 0;
|
||||
|
||||
system_init ();
|
||||
pacer_init (500);
|
||||
|
||||
/* TODO: Initialise LED matrix pins. */
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
pacer_wait ();
|
||||
|
||||
display_column (bitmap[current_column], current_column);
|
||||
|
||||
current_column++;
|
||||
|
||||
if (current_column > (LEDMAT_COLS_NUM - 1))
|
||||
{
|
||||
current_column = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab3-ex1
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers -I../../fonts -I../../drivers/avr -I../../utils
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab3-ex1.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab3-ex1.o: lab3-ex1.c ../../drivers/avr/system.h ../../drivers/button.h ../../drivers/display.h ../../fonts/font3x5_1_r.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer.o: ../../drivers/avr/timer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
button.o: ../../drivers/button.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/button.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
display.o: ../../drivers/display.c ../../drivers/avr/system.h ../../drivers/display.h ../../drivers/ledmat.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
ledmat.o: ../../drivers/ledmat.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/ledmat.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
font.o: ../../utils/font.c ../../drivers/avr/system.h ../../utils/font.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer.o: ../../utils/pacer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
tinygl.o: ../../utils/tinygl.c ../../drivers/avr/system.h ../../drivers/display.h ../../utils/font.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab3-ex1.out: lab3-ex1.o pio.o system.o timer.o button.o display.o ledmat.o font.o pacer.o tinygl.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab3-ex1.out
|
||||
$(OBJCOPY) -O ihex lab3-ex1.out lab3-ex1.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab3-ex1.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for lab3-ex1
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wstrict-prototypes -Wlab3-extra -g -I../../drivers/test -I../../drivers -I../../fonts -I../../utils
|
||||
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab3-ex1
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab3-ex1-test.o: lab3-ex1.c ../../drivers/button.h ../../drivers/display.h ../../drivers/test/system.h ../../fonts/font3x5_1_r.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
button-test.o: ../../drivers/button.c ../../drivers/button.h ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
display-test.o: ../../drivers/display.c ../../drivers/display.h ../../drivers/ledmat.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
ledmat-test.o: ../../drivers/ledmat.c ../../drivers/ledmat.h ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio-test.o: ../../drivers/test/pio.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system-test.o: ../../drivers/test/system.c ../../drivers/test/avrtest.h ../../drivers/test/mgetkey.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer-test.o: ../../drivers/test/timer.c ../../drivers/test/system.h ../../drivers/test/timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
font-test.o: ../../utils/font.c ../../drivers/test/system.h ../../utils/font.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer-test.o: ../../utils/pacer.c ../../drivers/test/system.h ../../drivers/test/timer.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
tinygl-test.o: ../../utils/tinygl.c ../../drivers/display.h ../../drivers/test/system.h ../../utils/font.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
|
||||
# Link: create lab3-executable file from object files.
|
||||
lab3-ex1: lab3-ex1-test.o button-test.o display-test.o ledmat-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o font-test.o pacer-test.o tinygl-test.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) lab3-ex1 lab3-ex1-test.o button-test.o display-test.o ledmat-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o font-test.o pacer-test.o tinygl-test.o
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex1 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,24 @@
|
||||
#include "system.h"
|
||||
#include "button.h"
|
||||
#include "pacer.h"
|
||||
#include "tinygl.h"
|
||||
#include "../fonts/font3x5_1.h"
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init();
|
||||
|
||||
/* TODO: Initialise the button driver, tinygl, and the pacer. */
|
||||
|
||||
|
||||
while(1)
|
||||
{
|
||||
pacer_wait();
|
||||
|
||||
/* TODO: Implement the functionality of the tasks in the
|
||||
stopwatch1 program. */
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab3-ex2
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers -I../../fonts -I../../drivers/avr -I../../utils
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab3-ex2.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab3-ex2.o: lab3-ex2.c ../../drivers/avr/system.h ../../drivers/display.h ../../fonts/font5x7_1.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer.o: ../../drivers/avr/timer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
display.o: ../../drivers/display.c ../../drivers/avr/system.h ../../drivers/display.h ../../drivers/ledmat.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
ledmat.o: ../../drivers/ledmat.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/ledmat.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
font.o: ../../utils/font.c ../../drivers/avr/system.h ../../utils/font.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer.o: ../../utils/pacer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
tinygl.o: ../../utils/tinygl.c ../../drivers/avr/system.h ../../drivers/display.h ../../utils/font.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab3-ex2.out: lab3-ex2.o pio.o system.o timer.o display.o ledmat.o font.o pacer.o tinygl.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab3-ex2.out
|
||||
$(OBJCOPY) -O ihex lab3-ex2.out lab3-ex2.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab3-ex2.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for lab3-ex2
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wstrict-prototypes -Wlab3-extra -g -I../../drivers/test -I../../drivers -I../../fonts -I../../utils
|
||||
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab3-ex2
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab3-ex2-test.o: lab3-ex2.c ../../drivers/display.h ../../drivers/test/system.h ../../fonts/font5x7_1.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
display-test.o: ../../drivers/display.c ../../drivers/display.h ../../drivers/ledmat.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
ledmat-test.o: ../../drivers/ledmat.c ../../drivers/ledmat.h ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio-test.o: ../../drivers/test/pio.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system-test.o: ../../drivers/test/system.c ../../drivers/test/avrtest.h ../../drivers/test/mgetkey.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer-test.o: ../../drivers/test/timer.c ../../drivers/test/system.h ../../drivers/test/timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
font-test.o: ../../utils/font.c ../../drivers/test/system.h ../../utils/font.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer-test.o: ../../utils/pacer.c ../../drivers/test/system.h ../../drivers/test/timer.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
tinygl-test.o: ../../utils/tinygl.c ../../drivers/display.h ../../drivers/test/system.h ../../utils/font.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
|
||||
# Link: create lab3-executable file from object files.
|
||||
lab3-ex2: lab3-ex2-test.o display-test.o ledmat-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o font-test.o pacer-test.o tinygl-test.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) lab3-ex2 lab3-ex2-test.o display-test.o ledmat-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o font-test.o pacer-test.o tinygl-test.o
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex2 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,29 @@
|
||||
#include "system.h"
|
||||
#include "pacer.h"
|
||||
#include "tinygl.h"
|
||||
#include "../fonts/font5x7_1.h"
|
||||
|
||||
|
||||
#define PACER_RATE 500
|
||||
#define MESSAGE_RATE 10
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init();
|
||||
|
||||
/* TODO: Initialise tinygl. */
|
||||
|
||||
/* TODO: Set the message using tinygl_tlab3-ext(). */
|
||||
|
||||
|
||||
pacer_init (PACER_RATE);
|
||||
|
||||
while(1)
|
||||
{
|
||||
pacer_wait();
|
||||
|
||||
/* TODO: Call the tinygl update function. */
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab3-ex3
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers -I../../fonts -I../../drivers/avr -I../../utils
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab3-ex3.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab3-ex3.o: lab3-ex3.c ../../drivers/avr/system.h ../../drivers/display.h ../../drivers/navswitch.h ../../fonts/font5x7_1.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer.o: ../../drivers/avr/timer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
display.o: ../../drivers/display.c ../../drivers/avr/system.h ../../drivers/display.h ../../drivers/ledmat.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
ledmat.o: ../../drivers/ledmat.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/ledmat.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
navswitch.o: ../../drivers/navswitch.c ../../drivers/avr/delay.h ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/navswitch.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
font.o: ../../utils/font.c ../../drivers/avr/system.h ../../utils/font.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer.o: ../../utils/pacer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
tinygl.o: ../../utils/tinygl.c ../../drivers/avr/system.h ../../drivers/display.h ../../utils/font.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab3-ex3.out: lab3-ex3.o pio.o system.o timer.o display.o ledmat.o navswitch.o font.o pacer.o tinygl.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab3-ex3.out
|
||||
$(OBJCOPY) -O ihex lab3-ex3.out lab3-ex3.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab3-ex3.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,64 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for lab3-ex3
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wstrict-prototypes -Wlab3-extra -g -I../../drivers/test -I../../drivers -I../../fonts -I../../utils
|
||||
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab3-ex3
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab3-ex3-test.o: lab3-ex3.c ../../drivers/display.h ../../drivers/navswitch.h ../../drivers/test/system.h ../../fonts/font5x7_1.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
display-test.o: ../../drivers/display.c ../../drivers/display.h ../../drivers/ledmat.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
ledmat-test.o: ../../drivers/ledmat.c ../../drivers/ledmat.h ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
navswitch-test.o: ../../drivers/navswitch.c ../../drivers/navswitch.h ../../drivers/test/avrtest.h ../../drivers/test/delay.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio-test.o: ../../drivers/test/pio.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system-test.o: ../../drivers/test/system.c ../../drivers/test/avrtest.h ../../drivers/test/mgetkey.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer-test.o: ../../drivers/test/timer.c ../../drivers/test/system.h ../../drivers/test/timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
font-test.o: ../../utils/font.c ../../drivers/test/system.h ../../utils/font.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer-test.o: ../../utils/pacer.c ../../drivers/test/system.h ../../drivers/test/timer.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
tinygl-test.o: ../../utils/tinygl.c ../../drivers/display.h ../../drivers/test/system.h ../../utils/font.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
|
||||
# Link: create lab3-executable file from object files.
|
||||
lab3-ex3: lab3-ex3-test.o display-test.o ledmat-test.o navswitch-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o font-test.o pacer-test.o tinygl-test.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) lab3-ex3 lab3-ex3-test.o display-test.o ledmat-test.o navswitch-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o font-test.o pacer-test.o tinygl-test.o
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex3 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,50 @@
|
||||
#include "system.h"
|
||||
#include "pacer.h"
|
||||
#include "navswitch.h"
|
||||
#include "tinygl.h"
|
||||
#include "../fonts/font5x7_1.h"
|
||||
|
||||
|
||||
#define PACER_RATE 500
|
||||
#define MESSAGE_RATE 10
|
||||
|
||||
|
||||
void display_character (char character)
|
||||
{
|
||||
char buffer[2];
|
||||
|
||||
buffer[0] = character;
|
||||
buffer[1] = '\0';
|
||||
tinygl_text (buffer);
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
char character = 'A';
|
||||
|
||||
system_init ();
|
||||
|
||||
tinygl_init (PACER_RATE);
|
||||
tinygl_font_set (&font5x7_1);
|
||||
tinygl_text_speed_set (MESSAGE_RATE);
|
||||
|
||||
/* TODO: Initialise navigation switch driver. */
|
||||
|
||||
pacer_init (PACER_RATE);
|
||||
|
||||
while(1)
|
||||
{
|
||||
pacer_wait ();
|
||||
tinygl_update ();
|
||||
|
||||
/* TODO: Call the navswitch update function. */
|
||||
|
||||
/* TODO: Increment character if NORTH is pressed. */
|
||||
|
||||
/* TODO: Decrement character if SOUTH is pressed. */
|
||||
|
||||
display_character (character);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for lab3-ex4
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers -I../../fonts -I../../drivers/avr -I../../utils
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: lab3-ex4.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
lab3-ex4.o: lab3-ex4.c ../../drivers/avr/ir_uart.h ../../drivers/avr/system.h ../../drivers/display.h ../../drivers/navswitch.h ../../fonts/font5x7_1.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
ir_uart.o: ../../drivers/avr/ir_uart.c ../../drivers/avr/ir_uart.h ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/avr/timer0.h ../../drivers/avr/usart1.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
prescale.o: ../../drivers/avr/prescale.c ../../drivers/avr/prescale.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer.o: ../../drivers/avr/timer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer0.o: ../../drivers/avr/timer0.c ../../drivers/avr/bits.h ../../drivers/avr/prescale.h ../../drivers/avr/system.h ../../drivers/avr/timer0.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
usart1.o: ../../drivers/avr/usart1.c ../../drivers/avr/system.h ../../drivers/avr/usart1.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
display.o: ../../drivers/display.c ../../drivers/avr/system.h ../../drivers/display.h ../../drivers/ledmat.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
ledmat.o: ../../drivers/ledmat.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/ledmat.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
navswitch.o: ../../drivers/navswitch.c ../../drivers/avr/delay.h ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/navswitch.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
font.o: ../../utils/font.c ../../drivers/avr/system.h ../../utils/font.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer.o: ../../utils/pacer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
tinygl.o: ../../utils/tinygl.c ../../drivers/avr/system.h ../../drivers/display.h ../../utils/font.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
lab3-ex4.out: lab3-ex4.o ir_uart.o pio.o prescale.o system.o timer.o timer0.o usart1.o display.o ledmat.o navswitch.o font.o pacer.o tinygl.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: lab3-ex4.out
|
||||
$(OBJCOPY) -O ihex lab3-ex4.out lab3-ex4.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash lab3-ex4.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for ex4 docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,57 @@
|
||||
#include "system.h"
|
||||
#include "pacer.h"
|
||||
#include "navswitch.h"
|
||||
#include "ir_uart.h"
|
||||
#include "tinygl.h"
|
||||
#include "../fonts/font5x7_1.h"
|
||||
|
||||
|
||||
#define PACER_RATE 500
|
||||
#define MESSAGE_RATE 10
|
||||
|
||||
|
||||
void display_character (char character)
|
||||
{
|
||||
char buffer[2];
|
||||
buffer[0] = character;
|
||||
buffer[1] = '\0';
|
||||
tinygl_text (buffer);
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
char character = 'A';
|
||||
|
||||
system_init ();
|
||||
tinygl_init (PACER_RATE);
|
||||
tinygl_font_set (&font5x7_1);
|
||||
tinygl_text_speed_set (MESSAGE_RATE);
|
||||
navswitch_init ();
|
||||
|
||||
/* TODO: Initialise IR driver. */
|
||||
|
||||
|
||||
pacer_init (PACER_RATE);
|
||||
|
||||
while (1)
|
||||
{
|
||||
pacer_wait ();
|
||||
tinygl_update ();
|
||||
navswitch_update ();
|
||||
|
||||
if (navswitch_push_event_p (NAVSWITCH_NORTH))
|
||||
character++;
|
||||
|
||||
if (navswitch_push_event_p (NAVSWITCH_SOUTH))
|
||||
character--;
|
||||
|
||||
/* TODO: Transmit the character over IR on a NAVSWITCH_PUSH
|
||||
event. */
|
||||
|
||||
display_character (character);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,78 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for receiver
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers -I../../fonts -I../../drivers/avr -I../../utils
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: receiver.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
receiver.o: receiver.c ../../drivers/avr/ir_uart.h ../../drivers/avr/system.h ../../drivers/display.h ../../fonts/font5x7_1.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
ir_uart.o: ../../drivers/avr/ir_uart.c ../../drivers/avr/ir_uart.h ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/avr/timer0.h ../../drivers/avr/usart1.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
prescale.o: ../../drivers/avr/prescale.c ../../drivers/avr/prescale.h ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer.o: ../../drivers/avr/timer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
timer0.o: ../../drivers/avr/timer0.c ../../drivers/avr/bits.h ../../drivers/avr/prescale.h ../../drivers/avr/system.h ../../drivers/avr/timer0.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
usart1.o: ../../drivers/avr/usart1.c ../../drivers/avr/system.h ../../drivers/avr/usart1.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
display.o: ../../drivers/display.c ../../drivers/avr/system.h ../../drivers/display.h ../../drivers/ledmat.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
ledmat.o: ../../drivers/ledmat.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/ledmat.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
font.o: ../../utils/font.c ../../drivers/avr/system.h ../../utils/font.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pacer.o: ../../utils/pacer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
tinygl.o: ../../utils/tinygl.c ../../drivers/avr/system.h ../../drivers/display.h ../../utils/font.h ../../utils/tinygl.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
|
||||
# Link: create ELF output file from object files.
|
||||
receiver.out: receiver.o ir_uart.o pio.o prescale.o system.o timer.o timer0.o usart1.o display.o ledmat.o font.o pacer.o tinygl.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: receiver.out
|
||||
$(OBJCOPY) -O ihex receiver.out receiver.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash receiver.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for receiver docs
|
||||
|
||||
DEL = rm
|
||||
|
||||
all: file_dependencies.pdf module_dependencies.pdf makefile_dependencies.pdf build_dependencies.pdf callgraph.pdf
|
||||
|
||||
file_dependencies.pdf: files.d
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
module_dependencies.pdf: modules.d
|
||||
../../../etc/graphdeps.py $< --modules --out $@
|
||||
|
||||
makefile_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@
|
||||
|
||||
build_dependencies.pdf: ../Makefile
|
||||
../../../etc/graphdeps.py $< --out $@ --showops
|
||||
|
||||
callgraph.pdf: callgraph.d
|
||||
../../../etc/graphdeps.py --calls --modules $< --out $@ --showops
|
||||
|
||||
|
||||
files.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --files . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/files.d)
|
||||
|
||||
|
||||
modules.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --relpath --modules . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system > doc/modules.d)
|
||||
|
||||
|
||||
callgraph.d: ../Makefile
|
||||
(cd ..; ../../etc/makemake.py --cc="avr-gcc" --cflags="-Os -mmcu=atmega32u2" --relpath --calls . . ../../drivers ../../drivers/avr ../../utils ../../extra --exclude system.h > doc/callgraph.d)
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.d *.pdf
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
Running make in this directory will generate a number of PDF graphs.
|
||||
In the callgraph, the arrows means "calls". In the dependency graphs,
|
||||
the arrows means "requires" (or "depends upon").
|
||||
|
||||
callgraph.pdf This shows the callgraph, i.e., what functions each
|
||||
function in the program calls.
|
||||
module_dependencies.pdf This shows the dependencies between the modules.
|
||||
file_dependencies.pdf This shows the dependencies between the files.
|
||||
makefile_dependencies.pdf This shows the dependencies required by make when
|
||||
building the program.
|
||||
build_dependencies.pdf This is like makefile_dependencies.pdf but shows
|
||||
the operations performed to generate the new file.
|
||||
|
||||
callgraph.d This shows the callgraph in text format.
|
||||
files.d This shows the file dependencies in text format.
|
||||
modules.d This shows the module dependencies in text format.
|
||||
@ -0,0 +1,43 @@
|
||||
#include "system.h"
|
||||
#include "pacer.h"
|
||||
#include "ir_uart.h"
|
||||
#include "tinygl.h"
|
||||
#include "../fonts/font5x7_1.h"
|
||||
|
||||
|
||||
#define PACER_RATE 500
|
||||
#define MESSAGE_RATE 10
|
||||
|
||||
|
||||
void display_character (char character)
|
||||
{
|
||||
char buffer[2];
|
||||
buffer[0] = character;
|
||||
buffer[1] = '\0';
|
||||
tinygl_tlab3-ext (buffer);
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init ();
|
||||
tinygl_init (PACER_RATE);
|
||||
tinygl_font_set (&font5x7_1);
|
||||
tinygl_tlab3-ext_speed_set (MESSAGE_RATE);
|
||||
ir_uart_init ();
|
||||
|
||||
pacer_init (PACER_RATE);
|
||||
|
||||
while (1)
|
||||
{
|
||||
pacer_wait ();
|
||||
|
||||
tinygl_update ();
|
||||
|
||||
if (ir_uart_read_ready_p ())
|
||||
{
|
||||
display_character (ir_uart_getc ());
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in new issue