Generate callgraph
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 12 Sep 2010
|
||||
# Descr: Makefile for bounce1
|
||||
|
||||
# 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: bounce1.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
bounce1.o: bounce1.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.
|
||||
bounce1.out: bounce1.o pacer.o pio.o system.o timer.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) *.o *.out *.hex
|
||||
|
||||
|
||||
# Target: program project.
|
||||
.PHONY: program
|
||||
program: bounce1.out
|
||||
$(OBJCOPY) -O ihex bounce1.out bounce1.hex
|
||||
dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash bounce1.hex; dfu-programmer atmega32u2 start
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# File: Makefile
|
||||
# Author: M. P. Hayes, UCECE
|
||||
# Date: 11 Sep 2010
|
||||
# Descr: Makefile for bounce1
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wstrict-prototypes -Wextra -g -I. -I../../utils -I../../drivers -I../../drivers/test
|
||||
|
||||
DEL = rm
|
||||
|
||||
|
||||
# Default target.
|
||||
all: bounce1
|
||||
|
||||
|
||||
# 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 $@
|
||||
|
||||
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
bounce1-test.o: bounce1.c ../../utils/pacer.h ../../drivers/test/pio.h ../../drivers/test/avrtest.h ../../drivers/test/system.h
|
||||
$(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 $@
|
||||
|
||||
pio-test.o: ../../drivers/test/pio.c
|
||||
$(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 $@
|
||||
|
||||
|
||||
|
||||
|
||||
# Link: create executable file from object files.
|
||||
bounce1: timer-test.o mgetkey-test.o bounce1-test.o pacer-test.o pio-test.o system-test.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) bounce1 timer-test.o mgetkey-test.o bounce1-test.o pacer-test.o pio-test.o system-test.o
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/** @file bounce1.c
|
||||
@author M. P. Hayes, UCECE
|
||||
@date 24 August 2009
|
||||
@brief Simple bouncing dot program
|
||||
|
||||
@defgroup bounce1 Bounce1 application
|
||||
*/
|
||||
#include "system.h"
|
||||
#include "pacer.h"
|
||||
#include "pio.h"
|
||||
|
||||
|
||||
/* Define polling rate in Hz. */
|
||||
#define LOOP_RATE 10
|
||||
|
||||
|
||||
/* Define PIO pins driving LED matrix rows and columns. */
|
||||
static pio_t ledmat_rows[] =
|
||||
{
|
||||
LEDMAT_ROW1_PIO, LEDMAT_ROW2_PIO, LEDMAT_ROW3_PIO, LEDMAT_ROW4_PIO,
|
||||
LEDMAT_ROW5_PIO, LEDMAT_ROW6_PIO, LEDMAT_ROW7_PIO
|
||||
};
|
||||
static pio_t ledmat_cols[] =
|
||||
{
|
||||
LEDMAT_COL1_PIO, LEDMAT_COL2_PIO, LEDMAT_COL3_PIO,
|
||||
LEDMAT_COL4_PIO, LEDMAT_COL5_PIO
|
||||
};
|
||||
|
||||
|
||||
/** Turn single LED within matrix on or off.
|
||||
@param col LED column number
|
||||
@param row LED row number
|
||||
@param state LED state */
|
||||
static void ledmat_pixel_set (int col, int row, bool state)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
pio_output_low (ledmat_rows[row]);
|
||||
pio_output_low (ledmat_cols[col]);
|
||||
}
|
||||
else
|
||||
{
|
||||
pio_output_high (ledmat_rows[row]);
|
||||
pio_output_high (ledmat_cols[col]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Initialise LED matrix PIO pins. */
|
||||
static void ledmat_init (void)
|
||||
{
|
||||
uint8_t row;
|
||||
uint8_t col;
|
||||
|
||||
for (row = 0; row < 7; row++)
|
||||
{
|
||||
pio_config_set (ledmat_rows[row], PIO_OUTPUT_HIGH);
|
||||
pio_output_high (ledmat_rows[row]);
|
||||
}
|
||||
|
||||
for (col = 0; col < 5; col++)
|
||||
{
|
||||
pio_config_set (ledmat_cols[col], PIO_OUTPUT_HIGH);
|
||||
pio_output_high (ledmat_cols[col]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int row;
|
||||
int col;
|
||||
int rowinc;
|
||||
int colinc;
|
||||
|
||||
system_init ();
|
||||
ledmat_init ();
|
||||
|
||||
row = 3;
|
||||
col = 2;
|
||||
rowinc = 1;
|
||||
colinc = 1;
|
||||
|
||||
ledmat_pixel_set (col, row, 1);
|
||||
|
||||
pacer_init (LOOP_RATE);
|
||||
|
||||
/* Paced loop. */
|
||||
while (1)
|
||||
{
|
||||
/* Wait for next tick. */
|
||||
pacer_wait ();
|
||||
|
||||
ledmat_pixel_set (col, row, 0);
|
||||
|
||||
col += colinc;
|
||||
row += rowinc;
|
||||
|
||||
if (row > 6 || row < 0)
|
||||
{
|
||||
row -= rowinc * 2;
|
||||
rowinc = -rowinc;
|
||||
}
|
||||
|
||||
if (col > 4 || col < 0)
|
||||
{
|
||||
col -= colinc * 2;
|
||||
colinc = -colinc;
|
||||
}
|
||||
|
||||
ledmat_pixel_set (col, row, 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user