diff --git a/apps/beep1/Makefile b/apps/beep1/Makefile index d7d8c4a..a47830b 100644 --- a/apps/beep1/Makefile +++ b/apps/beep1/Makefile @@ -5,7 +5,7 @@ # Definitions. CC = avr-gcc -CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr -I../../drivers -I../../utils +CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr -I../../utils OBJCOPY = avr-objcopy SIZE = avr-size DEL = rm @@ -16,7 +16,7 @@ all: beep1.out # Compile: create object files from C source files. -beep1.o: beep1.c ../../drivers/avr/delay.h ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/button.h ../../drivers/led.h ../../utils/pacer.h +beep1.o: beep1.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 @@ -28,12 +28,6 @@ system.o: ../../drivers/avr/system.c ../../drivers/avr/system.h 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 $@ - -led.o: ../../drivers/led.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/led.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 $@ @@ -41,7 +35,7 @@ pacer.o: ../../utils/pacer.c ../../drivers/avr/system.h ../../drivers/avr/timer. # Link: create output file (executable) from object files. -beep1.out: beep1.o pio.o system.o timer.o button.o led.o pacer.o +beep1.out: beep1.o pio.o system.o timer.o pacer.o $(CC) $(CFLAGS) $^ -o $@ -lm $(SIZE) $@ diff --git a/apps/beep1/doc/Makefile b/apps/beep1/doc/Makefile index 2fd302c..5fea900 100644 --- a/apps/beep1/doc/Makefile +++ b/apps/beep1/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for squeak1 docs +# Descr: Makefile for beep1 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/beep2/Makefile b/apps/beep2/Makefile index 879c10e..d30e6db 100644 --- a/apps/beep2/Makefile +++ b/apps/beep2/Makefile @@ -16,7 +16,7 @@ all: beep2.out # Compile: create object files from C source files. -beep2.o: beep2.c ../../drivers/avr/delay.h ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/button.h ../../drivers/led.h ../../utils/pacer.h +beep2.o: beep2.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/button.h ../../utils/pacer.h $(CC) -c $(CFLAGS) $< -o $@ pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h @@ -31,9 +31,6 @@ timer.o: ../../drivers/avr/timer.c ../../drivers/avr/system.h ../../drivers/avr/ button.o: ../../drivers/button.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/button.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: ../../utils/pacer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h ../../utils/pacer.h $(CC) -c $(CFLAGS) $< -o $@ @@ -41,7 +38,7 @@ pacer.o: ../../utils/pacer.c ../../drivers/avr/system.h ../../drivers/avr/timer. # Link: create output file (executable) from object files. -beep2.out: beep2.o pio.o system.o timer.o button.o led.o pacer.o +beep2.out: beep2.o pio.o system.o timer.o button.o pacer.o $(CC) $(CFLAGS) $^ -o $@ -lm $(SIZE) $@ diff --git a/apps/beep2/doc/Makefile b/apps/beep2/doc/Makefile index 2fd302c..211e384 100644 --- a/apps/beep2/doc/Makefile +++ b/apps/beep2/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for squeak1 docs +# Descr: Makefile for beep2 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/ir_spam1/doc/Makefile b/apps/ir_spam1/doc/Makefile index 00afecd..a3ec8fd 100644 --- a/apps/ir_spam1/doc/Makefile +++ b/apps/ir_spam1/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for ir_uart_test1 docs +# Descr: Makefile for ir_spam1 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/ir_uart_demo1/doc/Makefile b/apps/ir_uart_demo1/doc/Makefile index 195c459..d77c744 100644 --- a/apps/ir_uart_demo1/doc/Makefile +++ b/apps/ir_uart_demo1/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for ir_uart_test3 docs +# Descr: Makefile for ir_uart_demo1 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/ir_uart_test1/Makefile b/apps/ir_uart_test1/Makefile index 1e977ce..3701393 100644 --- a/apps/ir_uart_test1/Makefile +++ b/apps/ir_uart_test1/Makefile @@ -19,7 +19,7 @@ all: ir_uart_test1.out ir_uart_test1.o: ir_uart_test1.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 +ir_uart.o: ../../drivers/avr/ir_uart.c ../../drivers/avr/delay.h ../../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 diff --git a/apps/ir_uart_test2/Makefile b/apps/ir_uart_test2/Makefile index e34b37a..1ea65d6 100644 --- a/apps/ir_uart_test2/Makefile +++ b/apps/ir_uart_test2/Makefile @@ -19,7 +19,7 @@ all: ir_uart_test2.out ir_uart_test2.o: ir_uart_test2.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 +ir_uart.o: ../../drivers/avr/ir_uart.c ../../drivers/avr/delay.h ../../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 diff --git a/apps/ir_uart_test3/Makefile b/apps/ir_uart_test3/Makefile index 3d77367..90b2925 100644 --- a/apps/ir_uart_test3/Makefile +++ b/apps/ir_uart_test3/Makefile @@ -19,7 +19,7 @@ all: ir_uart_test3.out ir_uart_test3.o: ir_uart_test3.c ../../drivers/avr/ir_uart.h ../../drivers/avr/system.h ../../drivers/display.h ../../drivers/navswitch.h ../../fonts/font3x5_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 +ir_uart.o: ../../drivers/avr/ir_uart.c ../../drivers/avr/delay.h ../../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 diff --git a/apps/ir_uart_test3/doc/callgraph.d b/apps/ir_uart_test3/doc/callgraph.d index 2fcb1fe..b1943dd 100644 --- a/apps/ir_uart_test3/doc/callgraph.d +++ b/apps/ir_uart_test3/doc/callgraph.d @@ -116,7 +116,11 @@ usart1_write_ready_p@usart1.c: usart1_putc@usart1.c: usart1_write_ready_p -ir_uart_putc@ir_uart.c: usart1_putc +usart1_write_finished_p@usart1.c: -main@ir_uart_test3.c: system_init tinygl_init tinygl_font_set tinygl_text_speed_set tinygl_text_mode_set tinygl_text_dir_set navswitch_init ir_uart_init pacer_init show_byte pacer_wait tinygl_update ir_uart_read_ready_p ir_uart_getc show_byte navswitch_update navswitch_push_event_p ir_uart_putc ir_uart_getc navswitch_push_event_p ir_uart_putc ir_uart_getc +ir_uart_write_finished_p@ir_uart.c: usart1_write_finished_p + +ir_uart_putc@ir_uart.c: usart1_putc ir_uart_write_finished_p _delay_loop_1 ir_uart_read_ready_p ir_uart_getc + +main@ir_uart_test3.c: system_init tinygl_init tinygl_font_set tinygl_text_speed_set tinygl_text_mode_set tinygl_text_dir_set navswitch_init ir_uart_init pacer_init show_byte pacer_wait tinygl_update ir_uart_read_ready_p ir_uart_getc show_byte navswitch_update navswitch_push_event_p ir_uart_putc navswitch_push_event_p ir_uart_putc diff --git a/apps/ir_uart_test3/doc/files.d b/apps/ir_uart_test3/doc/files.d index aeb929e..acde90f 100644 --- a/apps/ir_uart_test3/doc/files.d +++ b/apps/ir_uart_test3/doc/files.d @@ -26,7 +26,9 @@ ../../drivers/avr/pio.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/delay.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/delay.h ../../drivers/avr/ir_uart.o: ../../drivers/avr/ir_uart.c @@ -80,8 +82,6 @@ ir_uart_test3.o: ir_uart_test3.c ../../drivers/avr/prescale.o: ../../drivers/avr/prescale.c -../../drivers/avr/delay.h: - ../../drivers/navswitch.c: ../../drivers/navswitch.h ../../drivers/avr/delay.h ../../drivers/avr/pio.h ../../drivers/navswitch.o: ../../drivers/navswitch.c diff --git a/apps/ir_uart_test4/doc/Makefile b/apps/ir_uart_test4/doc/Makefile index 195c459..87c8f09 100644 --- a/apps/ir_uart_test4/doc/Makefile +++ b/apps/ir_uart_test4/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for ir_uart_test3 docs +# Descr: Makefile for ir_uart_test4 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/jukebox1/doc/Makefile b/apps/jukebox1/doc/Makefile index eb29a6d..dc6e144 100644 --- a/apps/jukebox1/doc/Makefile +++ b/apps/jukebox1/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for squeak4 docs +# Descr: Makefile for jukebox1 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/ledpwm1/doc/Makefile b/apps/ledpwm1/doc/Makefile index c93d18c..cbae4f8 100644 --- a/apps/ledpwm1/doc/Makefile +++ b/apps/ledpwm1/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for led5 docs +# Descr: Makefile for ledpwm1 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/race1/doc/Makefile b/apps/race1/doc/Makefile index 195c459..83c8618 100644 --- a/apps/race1/doc/Makefile +++ b/apps/race1/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for ir_uart_test3 docs +# Descr: Makefile for race1 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/random1/doc/Makefile b/apps/random1/doc/Makefile index c93d18c..a37659a 100644 --- a/apps/random1/doc/Makefile +++ b/apps/random1/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for led5 docs +# Descr: Makefile for random1 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/random2/doc/Makefile b/apps/random2/doc/Makefile index c93d18c..5ac4e49 100644 --- a/apps/random2/doc/Makefile +++ b/apps/random2/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for led5 docs +# Descr: Makefile for random2 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/snake1/Makefile b/apps/snake1/Makefile index 8aed64a..5f9c37b 100644 --- a/apps/snake1/Makefile +++ b/apps/snake1/Makefile @@ -5,7 +5,7 @@ # Definitions. CC = avr-gcc -CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr -I../../fonts -I../../drivers -I../../utils +CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr -I../../drivers -I../../utils OBJCOPY = avr-objcopy SIZE = avr-size DEL = rm @@ -16,7 +16,7 @@ all: snake1.out # Compile: create object files from C source files. -snake1.o: snake1.c ../../drivers/avr/system.h ../../drivers/display.h ../../drivers/navswitch.h ../../fonts/font5x7_1.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h +snake1.o: snake1.c ../../drivers/avr/system.h ../../drivers/display.h ../../drivers/navswitch.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 diff --git a/apps/snake1/Makefile.test b/apps/snake1/Makefile.test index 44cab5b..a50e6e4 100644 --- a/apps/snake1/Makefile.test +++ b/apps/snake1/Makefile.test @@ -4,7 +4,7 @@ # Descr: Makefile for snake1 CC = gcc -CFLAGS = -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/test -I../../drivers -I../../fonts -I../../utils +CFLAGS = -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/test -I../../drivers -I../../utils DEL = rm @@ -14,7 +14,7 @@ all: snake1 # Compile: create object files from C source files. -snake1-test.o: snake1.c ../../drivers/display.h ../../drivers/navswitch.h ../../drivers/test/system.h ../../fonts/font5x7_1.h ../../utils/font.h ../../utils/pacer.h ../../utils/tinygl.h +snake1-test.o: snake1.c ../../drivers/display.h ../../drivers/navswitch.h ../../drivers/test/system.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 diff --git a/apps/stars1/doc/Makefile b/apps/stars1/doc/Makefile index c93d18c..31861ff 100644 --- a/apps/stars1/doc/Makefile +++ b/apps/stars1/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for led5 docs +# Descr: Makefile for stars1 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/apps/stars2/doc/Makefile b/apps/stars2/doc/Makefile index c93d18c..f13dba5 100644 --- a/apps/stars2/doc/Makefile +++ b/apps/stars2/doc/Makefile @@ -1,7 +1,7 @@ # File: Makefile # Author: M. P. Hayes, UCECE # Date: 11 Sep 2010 -# Descr: Makefile for led5 docs +# Descr: Makefile for stars2 docs # The scripts used to make the graphs require the program dot; this # is part of the graphviz package. diff --git a/drivers/avr/ir_uart.c b/drivers/avr/ir_uart.c index 361f47f..c2699c8 100644 --- a/drivers/avr/ir_uart.c +++ b/drivers/avr/ir_uart.c @@ -7,6 +7,7 @@ #include "usart1.h" #include "timer0.h" #include "pio.h" +#include "delay.h" /* Return non-zero if there is a character ready to be read. */ @@ -51,8 +52,25 @@ ir_uart_putc (char ch) /* Gobble echoed character. The echoing is due to an electrical common-path interference problem caused by a poor PCB layout of the - track powering the IR receiver. */ - ir_uart_getc (); + track powering the IR receiver. Unfortunately, it does not always + occur with some combination of UCFK4 boards and laptops. Perhaps + some laptops are more miserly with their current allocation and + some IR LEDs do not draw as much current? So as a workaround + we need to wait until the transmission has finished and then check + if something was immediately received. + + Having said all this, it is possible to get an optical reflection + of the transmitted signal. The following code should handle this + as well. */ + + while (! ir_uart_write_finished_p ()) + continue; + + /* Play safe and wait for receive complete flag to be set. */ + DELAY_US (1); + + if (ir_uart_read_ready_p ()) + ir_uart_getc (); return 1; } diff --git a/drivers/avr/system.h b/drivers/avr/system.h index 670542e..702b95b 100644 --- a/drivers/avr/system.h +++ b/drivers/avr/system.h @@ -8,8 +8,7 @@ /* Data typedefs. */ #include - -typedef uint8_t bool; +#include /** Useful macros. */