From 3705a9a84f77bae2e35b90a145b99637c09b7dca Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Tue, 11 Oct 2011 21:30:20 +0000 Subject: [PATCH] Add test program that gobbles echoed character --- apps/ir_uart_test3/Makefile | 85 +++++++++++++++++++++ apps/ir_uart_test3/Makefile.test | 70 +++++++++++++++++ apps/ir_uart_test3/doc/Makefile | 42 ++++++++++ apps/ir_uart_test3/doc/README | 16 ++++ apps/ir_uart_test3/doc/callgraph.d | 118 +++++++++++++++++++++++++++++ apps/ir_uart_test3/doc/files.d | 88 +++++++++++++++++++++ apps/ir_uart_test3/doc/modules.d | 26 +++++++ apps/ir_uart_test3/ir_uart_test3.c | 96 +++++++++++++++++++++++ 8 files changed, 541 insertions(+) create mode 100644 apps/ir_uart_test3/Makefile create mode 100644 apps/ir_uart_test3/Makefile.test create mode 100644 apps/ir_uart_test3/doc/Makefile create mode 100644 apps/ir_uart_test3/doc/README create mode 100644 apps/ir_uart_test3/doc/callgraph.d create mode 100644 apps/ir_uart_test3/doc/files.d create mode 100644 apps/ir_uart_test3/doc/modules.d create mode 100644 apps/ir_uart_test3/ir_uart_test3.c diff --git a/apps/ir_uart_test3/Makefile b/apps/ir_uart_test3/Makefile new file mode 100644 index 0000000..ee6c8fc --- /dev/null +++ b/apps/ir_uart_test3/Makefile @@ -0,0 +1,85 @@ +# File: Makefile +# Author: M. P. Hayes, UCECE +# Date: 12 Sep 2010 +# Descr: Makefile for ir_uart_test3 + +# 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: ir_uart_test3.out + + +# Compile: create object files from C source files. +ir_uart_test3.o: ir_uart_test3.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 ../../utils/uint8toa.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 $@ + +uint8toa.o: ../../utils/uint8toa.c ../../drivers/avr/system.h + $(CC) -c $(CFLAGS) $< -o $@ + + + + +# Link: create output file (executable) from object files. +ir_uart_test3.out: ir_uart_test3.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 uint8toa.o + $(CC) $(CFLAGS) $^ -o $@ -lm + $(SIZE) $@ + + +# Target: clean project. +.PHONY: clean +clean: + -$(DEL) *.o *.out *.hex + + +# Target: program project. +.PHONY: program +program: ir_uart_test3.out + $(OBJCOPY) -O ihex ir_uart_test3.out ir_uart_test3.hex + dfu-programmer atmega32u2 erase; dfu-programmer atmega32u2 flash ir_uart_test3.hex; dfu-programmer atmega32u2 start + + diff --git a/apps/ir_uart_test3/Makefile.test b/apps/ir_uart_test3/Makefile.test new file mode 100644 index 0000000..21eb34d --- /dev/null +++ b/apps/ir_uart_test3/Makefile.test @@ -0,0 +1,70 @@ +# File: Makefile +# Author: M. P. Hayes, UCECE +# Date: 11 Sep 2010 +# Descr: Makefile for ir_uart_test3 + +CC = gcc +CFLAGS = -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/test -I../../drivers -I../../fonts -I../../utils + +DEL = rm + + +# Default target. +all: ir_uart_test3 + + +# Compile: create object files from C source files. +ir_uart_test3-test.o: ir_uart_test3.c ../../drivers/display.h ../../drivers/navswitch.h ../../drivers/test/ir_uart.h ../../drivers/test/system.h ../../fonts/font3x5_1.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h ../../utils/uint8toa.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 $@ + +ir_uart-test.o: ../../drivers/test/ir_uart.c ../../drivers/test/ir_uart.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 $@ + +uint8toa-test.o: ../../utils/uint8toa.c ../../drivers/test/system.h + $(CC) -c $(CFLAGS) $< -o $@ + + + + +# Link: create executable file from object files. +ir_uart_test3: ir_uart_test3-test.o display-test.o ledmat-test.o navswitch-test.o ir_uart-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o font-test.o pacer-test.o tinygl-test.o uint8toa-test.o + $(CC) $(CFLAGS) $^ -o $@ -lrt + + +# Clean: delete derived files. +.PHONY: clean +clean: + -$(DEL) ir_uart_test3 ir_uart_test3-test.o display-test.o ledmat-test.o navswitch-test.o ir_uart-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o font-test.o pacer-test.o tinygl-test.o uint8toa-test.o + + + diff --git a/apps/ir_uart_test3/doc/Makefile b/apps/ir_uart_test3/doc/Makefile new file mode 100644 index 0000000..3a7ace3 --- /dev/null +++ b/apps/ir_uart_test3/doc/Makefile @@ -0,0 +1,42 @@ +# File: Makefile +# Author: M. P. Hayes, UCECE +# Date: 11 Sep 2010 +# Descr: Makefile for ir_uart_test3 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/apps/ir_uart_test3/doc/README b/apps/ir_uart_test3/doc/README new file mode 100644 index 0000000..39a9712 --- /dev/null +++ b/apps/ir_uart_test3/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/apps/ir_uart_test3/doc/callgraph.d b/apps/ir_uart_test3/doc/callgraph.d new file mode 100644 index 0000000..d6c1059 --- /dev/null +++ b/apps/ir_uart_test3/doc/callgraph.d @@ -0,0 +1,118 @@ +system_clock_init@system.c: + +system_watchdog_timer_init@system.c: + +system_init@system.c: system_clock_init system_watchdog_timer_init + +pio_config_set@pio.c: + +ledmat_init@ledmat.c: pio_config_set pio_config_set + +display_clear@display.c: + +display_init@display.c: ledmat_init display_clear + +tinygl_text_speed_set@tinygl.c: + +tinygl_clear@tinygl.c: display_clear + +tinygl_init@tinygl.c: display_init tinygl_text_speed_set tinygl_clear + +tinygl_font_set@tinygl.c: + +tinygl_text_mode_set@tinygl.c: + +navswitch_init@navswitch.c: + +timer0_mode_set@timer0.c: + +timer0_init@timer0.c: timer0_mode_set + +prescale_select@prescale.c: + +timer0_prescaler_get@timer0.c: + +timer0_running_p@timer0.c: timer0_prescaler_get + +timer0_prescaler_set@timer0.c: + +timer0_period_set@timer0.c: prescale_select timer0_running_p timer0_prescaler_set + +timer0_output_set@timer0.c: + +timer0_start@timer0.c: timer0_prescaler_set + +usart1_baud_divisor_set@usart1.c: + +usart1_init@usart1.c: usart1_baud_divisor_set + +ir_uart_init@ir_uart.c: pio_config_set timer0_init timer0_period_set timer0_mode_set timer0_output_set timer0_start usart1_init + +timer_init@timer.c: + +pacer_init@pacer.c: timer_init + +tinygl_draw_message@tinygl.c: strncpy strlen + +tinygl_text@tinygl.c: tinygl_draw_message + +show_char@ir_uart_test3.c: tinygl_text + +timer_get@timer.c: + +timer_wait_until@timer.c: timer_get + +pacer_wait@pacer.c: timer_wait_until + +tinygl_point@tinygl.c: + +font_pixel_get@font.c: + +tinygl_font_pixel_get@tinygl.c: font_pixel_get + +display_pixel_set@display.c: + +tinygl_draw_point@tinygl.c: display_pixel_set + +tinygl_draw_char@tinygl.c: tinygl_point tinygl_font_pixel_get tinygl_draw_point tinygl_point tinygl_draw_point tinygl_point tinygl_font_pixel_get tinygl_draw_point tinygl_point tinygl_draw_point + +tinygl_draw_string@tinygl.c: tinygl_draw_char + +tinygl_text_advance@tinygl.c: tinygl_draw_string tinygl_draw_string + +pio_output_high@pio.c: + +pio_output_low@pio.c: + +ledmat_display_column@ledmat.c: pio_output_high pio_output_low pio_output_high pio_output_low + +display_update@display.c: ledmat_display_column + +tinygl_update@tinygl.c: tinygl_text_advance display_update + +pio_config_get@pio.c: + +_delay_loop_1@navswitch.c: + +pio_input_get@pio.c: + +navswitch_update@navswitch.c: pio_config_get pio_config_set pio_config_set _delay_loop_1 pio_input_get pio_config_set + +navswitch_push_event_p@navswitch.c: + +usart1_write_ready_p@usart1.c: + +usart1_putc@usart1.c: usart1_putc usart1_write_ready_p + +ir_uart_putc@ir_uart.c: usart1_putc + +usart1_read_ready_p@usart1.c: + +ir_uart_read_ready_p@ir_uart.c: usart1_read_ready_p + +usart1_getc@usart1.c: usart1_read_ready_p + +ir_uart_getc@ir_uart.c: usart1_getc + +main@ir_uart_test3.c: system_init tinygl_init tinygl_font_set tinygl_text_speed_set tinygl_text_mode_set navswitch_init ir_uart_init pacer_init show_char pacer_wait tinygl_update navswitch_update navswitch_push_event_p ir_uart_putc navswitch_push_event_p ir_uart_putc ir_uart_read_ready_p ir_uart_getc show_char + diff --git a/apps/ir_uart_test3/doc/files.d b/apps/ir_uart_test3/doc/files.d new file mode 100644 index 0000000..d0c5207 --- /dev/null +++ b/apps/ir_uart_test3/doc/files.d @@ -0,0 +1,88 @@ +../../drivers/avr/timer.h: + +../../drivers/avr/timer.c: ../../drivers/avr/timer.h + +../../drivers/avr/timer.o: ../../drivers/avr/timer.c + +../../drivers/avr/pio.h: + +../../drivers/ledmat.h: + +../../drivers/ledmat.c: ../../drivers/avr/pio.h ../../drivers/ledmat.h + +../../drivers/ledmat.o: ../../drivers/ledmat.c + +../../drivers/navswitch.h: + +../../drivers/avr/delay.h: + +../../drivers/navswitch.c: ../../drivers/navswitch.h ../../drivers/avr/delay.h ../../drivers/avr/pio.h + +../../drivers/navswitch.o: ../../drivers/navswitch.c + +../../drivers/display.h: + +../../utils/font.h: + +../../utils/tinygl.h: ../../drivers/display.h ../../utils/font.h + +../../utils/tinygl.c: ../../utils/tinygl.h ../../drivers/display.h ../../utils/font.h + +../../utils/tinygl.o: ../../utils/tinygl.c + +../../utils/pacer.h: + +../../drivers/avr/ir_uart.h: + +../../fonts/font5x7_1.h: ../../utils/font.h + +ir_uart_test3.c: ../../drivers/navswitch.h ../../utils/tinygl.h ../../utils/pacer.h ../../drivers/avr/ir_uart.h ../../fonts/font5x7_1.h + +ir_uart_test3.o: ir_uart_test3.c + +../../utils/font.c: ../../utils/font.h + +../../utils/font.o: ../../utils/font.c + +../../drivers/avr/pio.c: ../../drivers/avr/pio.h + +../../drivers/avr/pio.o: ../../drivers/avr/pio.c + +../../utils/pacer.c: ../../drivers/avr/timer.h ../../utils/pacer.h + +../../utils/pacer.o: ../../utils/pacer.c + +../../drivers/display.c: ../../drivers/ledmat.h ../../drivers/display.h + +../../drivers/display.o: ../../drivers/display.c + +../../drivers/avr/system.c: + +../../drivers/avr/system.o: ../../drivers/avr/system.c + +../../drivers/avr/prescale.h: + +../../drivers/avr/prescale.c: ../../drivers/avr/prescale.h + +../../drivers/avr/prescale.o: ../../drivers/avr/prescale.c + +../../drivers/avr/usart1.h: + +../../drivers/avr/timer0.h: + +../../drivers/avr/ir_uart.c: ../../drivers/avr/ir_uart.h ../../drivers/avr/usart1.h ../../drivers/avr/timer0.h ../../drivers/avr/pio.h + +../../drivers/avr/ir_uart.o: ../../drivers/avr/ir_uart.c + +../../drivers/avr/bits.h: + +../../drivers/avr/timer0.c: ../../drivers/avr/timer0.h ../../drivers/avr/bits.h ../../drivers/avr/prescale.h + +../../drivers/avr/timer0.o: ../../drivers/avr/timer0.c + +../../drivers/avr/usart1.c: ../../drivers/avr/usart1.h + +../../drivers/avr/usart1.o: ../../drivers/avr/usart1.c + +ir_uart_test3.out: ../../drivers/avr/timer.o ../../drivers/ledmat.o ../../drivers/navswitch.o ../../utils/tinygl.o ir_uart_test3.o ../../utils/font.o ../../drivers/avr/pio.o ../../utils/pacer.o ../../drivers/display.o ../../drivers/avr/system.o ../../drivers/avr/prescale.o ../../drivers/avr/ir_uart.o ../../drivers/avr/timer0.o ../../drivers/avr/usart1.o + diff --git a/apps/ir_uart_test3/doc/modules.d b/apps/ir_uart_test3/doc/modules.d new file mode 100644 index 0000000..e3e2dad --- /dev/null +++ b/apps/ir_uart_test3/doc/modules.d @@ -0,0 +1,26 @@ +pio: + +navswitch: pio + +ledmat: pio + +display: ledmat + +font: + +tinygl: display font + +timer: + +pacer: timer + +usart1: + +prescale: + +timer0: prescale + +ir_uart: usart1 timer0 pio + +ir_uart_test3: navswitch tinygl pacer ir_uart + diff --git a/apps/ir_uart_test3/ir_uart_test3.c b/apps/ir_uart_test3/ir_uart_test3.c new file mode 100644 index 0000000..18ae809 --- /dev/null +++ b/apps/ir_uart_test3/ir_uart_test3.c @@ -0,0 +1,96 @@ +/** @file ir_uart_test3.c + @author M. P. Hayes, UCECE + @date 12 October 2011 + @brief Test program for IR serial communications. + + @defgroup ir_uart_test3 Test program for IR serial communications. +*/ + +#include "system.h" +#include "navswitch.h" +#include "tinygl.h" +#include "pacer.h" +#include "uint8toa.h" +#include "ir_uart.h" +#include "../fonts/font3x5_1.h" + + +/* Define polling rate in Hz. */ +#define LOOP_RATE 300 + +/* Define text update rate (characters per 10 s). */ +#define MESSAGE_RATE 10 + + +static void show_byte (uint8_t byte) +{ + char buffer[6]; + + uint8toa (byte, buffer, 0); + + tinygl_text (buffer); +} + + +int main (void) +{ + int count; + uint8_t data = 'M'; + + system_init (); + tinygl_init (LOOP_RATE); + tinygl_font_set (&font3x5_1); + tinygl_text_speed_set (MESSAGE_RATE); + tinygl_text_mode_set (TINYGL_TEXT_MODE_SCROLL); + tinygl_text_dir_set (TINYGL_TEXT_DIR_ROTATE); + + navswitch_init (); + ir_uart_init (); + + pacer_init (LOOP_RATE); + + show_byte ('M'); + + count = 0; + + /* Paced loop. */ + while (1) + { + /* Wait for next tick. */ + pacer_wait (); + + tinygl_update (); + + count++; + if (count > 20) + { + count = 0; + + navswitch_update (); + + if (navswitch_push_event_p (NAVSWITCH_WEST)) + { + ir_uart_putc (--data); + /* Gobble echoed character. */ + ir_uart_getc (); + } + + if (navswitch_push_event_p (NAVSWITCH_EAST)) + { + ir_uart_putc (++data); + /* Gobble echoed character. */ + ir_uart_getc (); + } + } + + if (ir_uart_read_ready_p ()) + { + uint8_t data; + + data = ir_uart_getc (); + show_byte (data); + } + } + + return 0; +}