diff --git a/labs/README b/labs/README new file mode 100644 index 0000000..12d3b56 --- /dev/null +++ b/labs/README @@ -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. + diff --git a/labs/lab1-ex1/Makefile b/labs/lab1-ex1/Makefile new file mode 100644 index 0000000..29871c7 --- /dev/null +++ b/labs/lab1-ex1/Makefile @@ -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 + + diff --git a/labs/lab1-ex1/doc/Makefile b/labs/lab1-ex1/doc/Makefile new file mode 100644 index 0000000..a56a688 --- /dev/null +++ b/labs/lab1-ex1/doc/Makefile @@ -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 + diff --git a/labs/lab1-ex1/doc/README b/labs/lab1-ex1/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab1-ex1/doc/README @@ -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. diff --git a/labs/lab1-ex1/lab1-ex1.c b/labs/lab1-ex1/lab1-ex1.c new file mode 100644 index 0000000..0b42015 --- /dev/null +++ b/labs/lab1-ex1/lab1-ex1.c @@ -0,0 +1,20 @@ +#include +#include "system.h" + +int main (void) +{ + system_init (); + + /* Initialise port to drive LED 1. */ + + /* TODO. */ + + while (1) + { + + /* Turn LED 1 on. */ + + /* TODO. */ + + } +} diff --git a/labs/lab1-ex2/Makefile b/labs/lab1-ex2/Makefile new file mode 100644 index 0000000..26501df --- /dev/null +++ b/labs/lab1-ex2/Makefile @@ -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 + + diff --git a/labs/lab1-ex2/doc/Makefile b/labs/lab1-ex2/doc/Makefile new file mode 100644 index 0000000..374146d --- /dev/null +++ b/labs/lab1-ex2/doc/Makefile @@ -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 + diff --git a/labs/lab1-ex2/doc/README b/labs/lab1-ex2/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab1-ex2/doc/README @@ -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. diff --git a/labs/lab1-ex2/lab1-ex2.c b/labs/lab1-ex2/lab1-ex2.c new file mode 100644 index 0000000..99e0b45 --- /dev/null +++ b/labs/lab1-ex2/lab1-ex2.c @@ -0,0 +1,64 @@ +#include +#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 (); + } + } +} diff --git a/labs/lab1-ex3/Makefile b/labs/lab1-ex3/Makefile new file mode 100644 index 0000000..508cf00 --- /dev/null +++ b/labs/lab1-ex3/Makefile @@ -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 + + diff --git a/labs/lab1-ex3/Makefile.test b/labs/lab1-ex3/Makefile.test new file mode 100644 index 0000000..a06f0e9 --- /dev/null +++ b/labs/lab1-ex3/Makefile.test @@ -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 + + + diff --git a/labs/lab1-ex3/button.c b/labs/lab1-ex3/button.c new file mode 100644 index 0000000..6dfa2c4 --- /dev/null +++ b/labs/lab1-ex3/button.c @@ -0,0 +1,17 @@ +#include +#include "button.h" + + +/** Return non-zero if button pressed. */ +int button_pressed_p (void) +{ + /* TODO. */ +} + + +/** Initialise button1. */ +void button_init (void) +{ + /* TODO. */ +} + diff --git a/labs/lab1-ex3/button.h b/labs/lab1-ex3/button.h new file mode 100644 index 0000000..3069454 --- /dev/null +++ b/labs/lab1-ex3/button.h @@ -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 diff --git a/labs/lab1-ex3/doc/Makefile b/labs/lab1-ex3/doc/Makefile new file mode 100644 index 0000000..44da50e --- /dev/null +++ b/labs/lab1-ex3/doc/Makefile @@ -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 + diff --git a/labs/lab1-ex3/doc/README b/labs/lab1-ex3/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab1-ex3/doc/README @@ -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. diff --git a/labs/lab1-ex3/lab1-ex3.c b/labs/lab1-ex3/lab1-ex3.c new file mode 100644 index 0000000..a23916f --- /dev/null +++ b/labs/lab1-ex3/lab1-ex3.c @@ -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 (); + } + } +} diff --git a/labs/lab1-ex3/led.c b/labs/lab1-ex3/led.c new file mode 100644 index 0000000..726c733 --- /dev/null +++ b/labs/lab1-ex3/led.c @@ -0,0 +1,23 @@ +#include +#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! */ +} diff --git a/labs/lab1-ex3/led.h b/labs/lab1-ex3/led.h new file mode 100644 index 0000000..7f1c039 --- /dev/null +++ b/labs/lab1-ex3/led.h @@ -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 diff --git a/labs/lab1-ex4/Makefile b/labs/lab1-ex4/Makefile new file mode 100644 index 0000000..ecde80e --- /dev/null +++ b/labs/lab1-ex4/Makefile @@ -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 + + diff --git a/labs/lab1-ex4/Makefile.test b/labs/lab1-ex4/Makefile.test new file mode 100644 index 0000000..eefa511 --- /dev/null +++ b/labs/lab1-ex4/Makefile.test @@ -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 + + + diff --git a/labs/lab1-ex4/button.c b/labs/lab1-ex4/button.c new file mode 100644 index 0000000..24402db --- /dev/null +++ b/labs/lab1-ex4/button.c @@ -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. */ +} + diff --git a/labs/lab1-ex4/button.h b/labs/lab1-ex4/button.h new file mode 100644 index 0000000..3069454 --- /dev/null +++ b/labs/lab1-ex4/button.h @@ -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 diff --git a/labs/lab1-ex4/doc/Makefile b/labs/lab1-ex4/doc/Makefile new file mode 100644 index 0000000..6d37994 --- /dev/null +++ b/labs/lab1-ex4/doc/Makefile @@ -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 + diff --git a/labs/lab1-ex4/doc/README b/labs/lab1-ex4/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab1-ex4/doc/README @@ -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. diff --git a/labs/lab1-ex4/lab1-ex4.c b/labs/lab1-ex4/lab1-ex4.c new file mode 100644 index 0000000..a23916f --- /dev/null +++ b/labs/lab1-ex4/lab1-ex4.c @@ -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 (); + } + } +} diff --git a/labs/lab1-ex4/led.c b/labs/lab1-ex4/led.c new file mode 100644 index 0000000..d73f944 --- /dev/null +++ b/labs/lab1-ex4/led.c @@ -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! */ +} diff --git a/labs/lab1-ex4/led.h b/labs/lab1-ex4/led.h new file mode 100644 index 0000000..7f1c039 --- /dev/null +++ b/labs/lab1-ex4/led.h @@ -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 diff --git a/labs/lab1-ex5/Makefile b/labs/lab1-ex5/Makefile new file mode 100644 index 0000000..d2fc475 --- /dev/null +++ b/labs/lab1-ex5/Makefile @@ -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 + + diff --git a/labs/lab1-ex5/Makefile.test b/labs/lab1-ex5/Makefile.test new file mode 100644 index 0000000..c291043 --- /dev/null +++ b/labs/lab1-ex5/Makefile.test @@ -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 + + + diff --git a/labs/lab1-ex5/doc/Makefile b/labs/lab1-ex5/doc/Makefile new file mode 100644 index 0000000..2a6c678 --- /dev/null +++ b/labs/lab1-ex5/doc/Makefile @@ -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 + diff --git a/labs/lab1-ex5/doc/README b/labs/lab1-ex5/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab1-ex5/doc/README @@ -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. diff --git a/labs/lab1-ex5/lab1-ex5.c b/labs/lab1-ex5/lab1-ex5.c new file mode 100644 index 0000000..f02333f --- /dev/null +++ b/labs/lab1-ex5/lab1-ex5.c @@ -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. */ + + } +} diff --git a/labs/lab2-ex1/Makefile b/labs/lab2-ex1/Makefile new file mode 100644 index 0000000..3cf340a --- /dev/null +++ b/labs/lab2-ex1/Makefile @@ -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 + + diff --git a/labs/lab2-ex1/doc/Makefile b/labs/lab2-ex1/doc/Makefile new file mode 100644 index 0000000..a56a688 --- /dev/null +++ b/labs/lab2-ex1/doc/Makefile @@ -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 + diff --git a/labs/lab2-ex1/doc/README b/labs/lab2-ex1/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab2-ex1/doc/README @@ -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. diff --git a/labs/lab2-ex1/lab2-ex1.c b/labs/lab2-ex1/lab2-ex1.c new file mode 100644 index 0000000..30ff88f --- /dev/null +++ b/labs/lab2-ex1/lab2-ex1.c @@ -0,0 +1,28 @@ +#include +#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. */ + + } + +} diff --git a/labs/lab2-ex2/Makefile b/labs/lab2-ex2/Makefile new file mode 100644 index 0000000..d69a5bf --- /dev/null +++ b/labs/lab2-ex2/Makefile @@ -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 + + diff --git a/labs/lab2-ex2/doc/Makefile b/labs/lab2-ex2/doc/Makefile new file mode 100644 index 0000000..374146d --- /dev/null +++ b/labs/lab2-ex2/doc/Makefile @@ -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 + diff --git a/labs/lab2-ex2/doc/README b/labs/lab2-ex2/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab2-ex2/doc/README @@ -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. diff --git a/labs/lab2-ex2/lab2-ex2.c b/labs/lab2-ex2/lab2-ex2.c new file mode 100644 index 0000000..8d23148 --- /dev/null +++ b/labs/lab2-ex2/lab2-ex2.c @@ -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); + } +} diff --git a/labs/lab2-ex2/timer.c b/labs/lab2-ex2/timer.c new file mode 100644 index 0000000..6e776e3 --- /dev/null +++ b/labs/lab2-ex2/timer.c @@ -0,0 +1,19 @@ +#include +#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. */ +} diff --git a/labs/lab2-ex2/timer.h b/labs/lab2-ex2/timer.h new file mode 100644 index 0000000..80d70f2 --- /dev/null +++ b/labs/lab2-ex2/timer.h @@ -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 diff --git a/labs/lab2-ex3/Makefile b/labs/lab2-ex3/Makefile new file mode 100644 index 0000000..1e5ccdd --- /dev/null +++ b/labs/lab2-ex3/Makefile @@ -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 + + diff --git a/labs/lab2-ex3/doc/Makefile b/labs/lab2-ex3/doc/Makefile new file mode 100644 index 0000000..44da50e --- /dev/null +++ b/labs/lab2-ex3/doc/Makefile @@ -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 + diff --git a/labs/lab2-ex3/doc/README b/labs/lab2-ex3/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab2-ex3/doc/README @@ -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. diff --git a/labs/lab2-ex3/lab2-ex3.c b/labs/lab2-ex3/lab2-ex3.c new file mode 100644 index 0000000..2d247dd --- /dev/null +++ b/labs/lab2-ex3/lab2-ex3.c @@ -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; + } +} diff --git a/labs/lab2-ex3/pacer.c b/labs/lab2-ex3/pacer.c new file mode 100644 index 0000000..615e626 --- /dev/null +++ b/labs/lab2-ex3/pacer.c @@ -0,0 +1,22 @@ +#include +#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. */ + +} diff --git a/labs/lab2-ex3/pacer.h b/labs/lab2-ex3/pacer.h new file mode 100644 index 0000000..3bb1cf0 --- /dev/null +++ b/labs/lab2-ex3/pacer.h @@ -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 diff --git a/labs/lab2-ex4/Makefile b/labs/lab2-ex4/Makefile new file mode 100644 index 0000000..97278fc --- /dev/null +++ b/labs/lab2-ex4/Makefile @@ -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 + + diff --git a/labs/lab2-ex4/doc/Makefile b/labs/lab2-ex4/doc/Makefile new file mode 100644 index 0000000..6d37994 --- /dev/null +++ b/labs/lab2-ex4/doc/Makefile @@ -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 + diff --git a/labs/lab2-ex4/doc/README b/labs/lab2-ex4/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab2-ex4/doc/README @@ -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. diff --git a/labs/lab2-ex4/lab2-ex4.c b/labs/lab2-ex4/lab2-ex4.c new file mode 100644 index 0000000..c6a4b86 --- /dev/null +++ b/labs/lab2-ex4/lab2-ex4.c @@ -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. */ + } +} diff --git a/labs/lab2-ex4/pacer.c b/labs/lab2-ex4/pacer.c new file mode 100644 index 0000000..615e626 --- /dev/null +++ b/labs/lab2-ex4/pacer.c @@ -0,0 +1,22 @@ +#include +#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. */ + +} diff --git a/labs/lab2-ex4/pacer.h b/labs/lab2-ex4/pacer.h new file mode 100644 index 0000000..3bb1cf0 --- /dev/null +++ b/labs/lab2-ex4/pacer.h @@ -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 diff --git a/labs/lab2-ex5/Makefile b/labs/lab2-ex5/Makefile new file mode 100644 index 0000000..7fc2ba5 --- /dev/null +++ b/labs/lab2-ex5/Makefile @@ -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 + + diff --git a/labs/lab2-ex5/Makefile.test b/labs/lab2-ex5/Makefile.test new file mode 100644 index 0000000..b4a7e60 --- /dev/null +++ b/labs/lab2-ex5/Makefile.test @@ -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 + + + diff --git a/labs/lab2-ex5/doc/Makefile b/labs/lab2-ex5/doc/Makefile new file mode 100644 index 0000000..2a6c678 --- /dev/null +++ b/labs/lab2-ex5/doc/Makefile @@ -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 + diff --git a/labs/lab2-ex5/doc/README b/labs/lab2-ex5/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab2-ex5/doc/README @@ -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. diff --git a/labs/lab2-ex5/lab2-ex5.c b/labs/lab2-ex5/lab2-ex5.c new file mode 100644 index 0000000..96309cd --- /dev/null +++ b/labs/lab2-ex5/lab2-ex5.c @@ -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; + } + } +} diff --git a/labs/lab3-ex1/Makefile b/labs/lab3-ex1/Makefile new file mode 100644 index 0000000..62935b8 --- /dev/null +++ b/labs/lab3-ex1/Makefile @@ -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 + + diff --git a/labs/lab3-ex1/Makefile.test b/labs/lab3-ex1/Makefile.test new file mode 100644 index 0000000..55efcb4 --- /dev/null +++ b/labs/lab3-ex1/Makefile.test @@ -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 + + + diff --git a/labs/lab3-ex1/doc/Makefile b/labs/lab3-ex1/doc/Makefile new file mode 100644 index 0000000..a56a688 --- /dev/null +++ b/labs/lab3-ex1/doc/Makefile @@ -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 + diff --git a/labs/lab3-ex1/doc/README b/labs/lab3-ex1/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab3-ex1/doc/README @@ -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. diff --git a/labs/lab3-ex1/lab3-ex1.c b/labs/lab3-ex1/lab3-ex1.c new file mode 100644 index 0000000..1d7f4c9 --- /dev/null +++ b/labs/lab3-ex1/lab3-ex1.c @@ -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; +} diff --git a/labs/lab3-ex2/Makefile b/labs/lab3-ex2/Makefile new file mode 100644 index 0000000..cf9b195 --- /dev/null +++ b/labs/lab3-ex2/Makefile @@ -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 + + diff --git a/labs/lab3-ex2/Makefile.test b/labs/lab3-ex2/Makefile.test new file mode 100644 index 0000000..da46db7 --- /dev/null +++ b/labs/lab3-ex2/Makefile.test @@ -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 + + + diff --git a/labs/lab3-ex2/doc/Makefile b/labs/lab3-ex2/doc/Makefile new file mode 100644 index 0000000..374146d --- /dev/null +++ b/labs/lab3-ex2/doc/Makefile @@ -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 + diff --git a/labs/lab3-ex2/doc/README b/labs/lab3-ex2/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab3-ex2/doc/README @@ -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. diff --git a/labs/lab3-ex2/lab3-ex2.c b/labs/lab3-ex2/lab3-ex2.c new file mode 100644 index 0000000..ac83b83 --- /dev/null +++ b/labs/lab3-ex2/lab3-ex2.c @@ -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; +} diff --git a/labs/lab3-ex3/Makefile b/labs/lab3-ex3/Makefile new file mode 100644 index 0000000..bf9a248 --- /dev/null +++ b/labs/lab3-ex3/Makefile @@ -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 + + diff --git a/labs/lab3-ex3/Makefile.test b/labs/lab3-ex3/Makefile.test new file mode 100644 index 0000000..f48c772 --- /dev/null +++ b/labs/lab3-ex3/Makefile.test @@ -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 + + + diff --git a/labs/lab3-ex3/doc/Makefile b/labs/lab3-ex3/doc/Makefile new file mode 100644 index 0000000..44da50e --- /dev/null +++ b/labs/lab3-ex3/doc/Makefile @@ -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 + diff --git a/labs/lab3-ex3/doc/README b/labs/lab3-ex3/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab3-ex3/doc/README @@ -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. diff --git a/labs/lab3-ex3/lab3-ex3.c b/labs/lab3-ex3/lab3-ex3.c new file mode 100644 index 0000000..9d1099c --- /dev/null +++ b/labs/lab3-ex3/lab3-ex3.c @@ -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; +} diff --git a/labs/lab3-ex4/Makefile b/labs/lab3-ex4/Makefile new file mode 100644 index 0000000..625b4b7 --- /dev/null +++ b/labs/lab3-ex4/Makefile @@ -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 + + diff --git a/labs/lab3-ex4/Makefile.test b/labs/lab3-ex4/Makefile.test new file mode 100644 index 0000000..e69de29 diff --git a/labs/lab3-ex4/doc/Makefile b/labs/lab3-ex4/doc/Makefile new file mode 100644 index 0000000..6d37994 --- /dev/null +++ b/labs/lab3-ex4/doc/Makefile @@ -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 + diff --git a/labs/lab3-ex4/doc/README b/labs/lab3-ex4/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/lab3-ex4/doc/README @@ -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. diff --git a/labs/lab3-ex4/lab3-ex4.c b/labs/lab3-ex4/lab3-ex4.c new file mode 100644 index 0000000..62671ca --- /dev/null +++ b/labs/lab3-ex4/lab3-ex4.c @@ -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; +} diff --git a/labs/receiver/Makefile b/labs/receiver/Makefile new file mode 100644 index 0000000..02251f0 --- /dev/null +++ b/labs/receiver/Makefile @@ -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 + + diff --git a/labs/receiver/Makefile.test b/labs/receiver/Makefile.test new file mode 100644 index 0000000..e69de29 diff --git a/labs/receiver/doc/Makefile b/labs/receiver/doc/Makefile new file mode 100644 index 0000000..5606cae --- /dev/null +++ b/labs/receiver/doc/Makefile @@ -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 + diff --git a/labs/receiver/doc/README b/labs/receiver/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/labs/receiver/doc/README @@ -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. diff --git a/labs/receiver/receiver.c b/labs/receiver/receiver.c new file mode 100644 index 0000000..fdbd7f7 --- /dev/null +++ b/labs/receiver/receiver.c @@ -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; +}