Generate callgraph

This commit is contained in:
Michael Hayes
2011-08-27 01:46:08 +00:00
commit 513810e138
233 changed files with 22993 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
# File: Makefile
# Author: M. P. Hayes, UCECE
# Date: 12 Sep 2010
# Descr: Makefile for bounce5
# Definitions.
CC = avr-gcc
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I. -I../../utils -I../../fonts -I../../drivers -I../../drivers/avr
OBJCOPY = avr-objcopy
SIZE = avr-size
DEL = rm
# Default target.
all: bounce5.out
# Compile: create object files from C source files.
bounce5.o: bounce5.c ../../drivers/avr/system.h ../../drivers/display.h ../../utils/boing.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 $@
boing.o: ../../utils/boing.c ../../drivers/avr/system.h ../../drivers/display.h ../../utils/boing.h ../../utils/font.h ../../utils/tinygl.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.
bounce5.out: boing.o bounce5.o display.o ledmat.o pacer.o pio.o system.o timer.o tinygl.o
$(CC) $(CFLAGS) $^ -o $@ -lm
$(SIZE) $@
# Target: clean project.
.PHONY: clean
clean:
-$(DEL) *.o *.out *.hex
# Target: program project.
.PHONY: program
program: bounce5.out
$(OBJCOPY) -O ihex bounce5.out bounce5.hex
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash bounce5.hex; dfu-programmer atmega32u2 start
+60
View File
@@ -0,0 +1,60 @@
# File: Makefile
# Author: M. P. Hayes, UCECE
# Date: 11 Sep 2010
# Descr: Makefile for bounce5
CC = gcc
CFLAGS = -Wall -Wstrict-prototypes -Wextra -g -I. -I../../utils -I../../drivers -I../../drivers/test
DEL = rm
# Default target.
all: bounce5
# Compile: create object files from C source files.
timer-test.o: ../../drivers/test/timer.c ../../drivers/test/timer.h ../../drivers/test/system.h
$(CC) -c $(CFLAGS) $< -o $@
display-test.o: ../../drivers/display.c ../../drivers/ledmat.h ../../drivers/display.h ../../drivers/test/system.h
$(CC) -c $(CFLAGS) $< -o $@
pio-test.o: ../../drivers/test/pio.c
$(CC) -c $(CFLAGS) $< -o $@
pacer-test.o: ../../utils/pacer.c ../../drivers/test/timer.h ../../utils/pacer.h ../../drivers/test/system.h
$(CC) -c $(CFLAGS) $< -o $@
boing-test.o: ../../utils/boing.c ../../drivers/display.h ../../utils/boing.h ../../utils/font.h ../../utils/tinygl.h ../../drivers/test/system.h
$(CC) -c $(CFLAGS) $< -o $@
bounce5-test.o: bounce5.c ../../drivers/test/system.h ../../utils/font.h ../../utils/tinygl.h ../../utils/pacer.h ../../drivers/display.h ../../utils/boing.h
$(CC) -c $(CFLAGS) $< -o $@
ledmat-test.o: ../../drivers/ledmat.c ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/ledmat.h ../../drivers/test/system.h
$(CC) -c $(CFLAGS) $< -o $@
tinygl-test.o: ../../utils/tinygl.c ../../drivers/display.h ../../utils/font.h ../../utils/tinygl.h ../../drivers/test/system.h
$(CC) -c $(CFLAGS) $< -o $@
system-test.o: ../../drivers/test/system.c ../../drivers/test/pio.h ../../drivers/test/avrtest.h ../../drivers/test/mgetkey.h ../../drivers/test/system.h
$(CC) -c $(CFLAGS) $< -o $@
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
$(CC) -c $(CFLAGS) $< -o $@
# Link: create executable file from object files.
bounce5: timer-test.o display-test.o pio-test.o pacer-test.o boing-test.o bounce5-test.o ledmat-test.o tinygl-test.o system-test.o mgetkey-test.o
$(CC) $(CFLAGS) $^ -o $@ -lrt
# Clean: delete derived files.
.PHONY: clean
clean:
-$(DEL) bounce5 timer-test.o display-test.o pio-test.o pacer-test.o boing-test.o bounce5-test.o ledmat-test.o tinygl-test.o system-test.o mgetkey-test.o
+96
View File
@@ -0,0 +1,96 @@
/** @file bounce5.c
@author M. P. Hayes, UCECE
@date 24 August 2009
@brief Multiple bouncing dot program
@defgroup bounce5 Bounce5 application
*/
#include "system.h"
#include "pacer.h"
#include "tinygl.h"
#include "boing.h"
/* Define polling rate in Hz. */
#define LOOP_RATE 200
/* Determine if two balls have collided
@param balls array of all the ball states
@param num_balls number of balls in array
@param this_ball index of ball to check
@return index of ball collided with or -1 for no collision */
static int collision_detect (boing_state_t *balls, int num_balls, int this_ball)
{
int i;
for (i = 0; i < num_balls; i++)
{
/* Cannot collide with self. */
if (i == this_ball)
continue;
if (balls[i].pos.x == balls[this_ball].pos.x
&& balls[i].pos.y == balls[this_ball].pos.y)
return i;
}
return -1;
}
int main (void)
{
int tick;
boing_state_t balls[3];
system_init ();
tinygl_init (LOOP_RATE);
pacer_init (LOOP_RATE);
tick = 0;
balls[0] = boing_init (0, 1, DIR_NE);
balls[1] = boing_init (4, 5, DIR_SE);
balls[2] = boing_init (4, 5, DIR_SW);
/* Paced loop. */
while (1)
{
/* Wait for next tick. */
pacer_wait ();
tick++;
/* Flash the first two balls at different rates. */
tinygl_draw_point (balls[0].pos, tick % 2 < 1);
tinygl_draw_point (balls[1].pos, tick % 4 < 2);
if (tick >= 40)
{
int i;
tick = 0;
for (i = 0; i < 3; i++)
{
/* Erase previous position. */
tinygl_draw_point (balls[i].pos, 0);
/* Check for collision; if so reverse direction. */
balls[i] = boing_update (balls[i]);
/* Perhaps should make ball that is hit reverse as well? */
if (collision_detect (balls, 2, i) > 0)
{
balls[i] = boing_reverse (balls[i]);
}
/* Draw previous position. */
tinygl_draw_point (balls[i].pos, 1);
}
}
tinygl_update ();
}
}