Add ir_spam1 to show how to repeatedly send character over IR UART and update display at the same time
This commit is contained in:
+15
-3
@@ -5,7 +5,7 @@
|
||||
|
||||
# Definitions.
|
||||
CC = avr-gcc
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr -I../../utils
|
||||
CFLAGS = -mmcu=atmega32u2 -Os -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/avr -I../../fonts -I../../drivers -I../../utils
|
||||
OBJCOPY = avr-objcopy
|
||||
SIZE = avr-size
|
||||
DEL = rm
|
||||
@@ -16,7 +16,7 @@ all: ir_spam1.out
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
ir_spam1.o: ir_spam1.c ../../drivers/avr/ir_uart.h ../../drivers/avr/system.h ../../utils/pacer.h
|
||||
ir_spam1.o: ir_spam1.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
|
||||
@@ -40,14 +40,26 @@ timer0.o: ../../drivers/avr/timer0.c ../../drivers/avr/bits.h ../../drivers/avr/
|
||||
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 output file (executable) from object files.
|
||||
ir_spam1.out: ir_spam1.o ir_uart.o pio.o prescale.o system.o timer.o timer0.o usart1.o pacer.o
|
||||
ir_spam1.out: ir_spam1.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) $@
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# Descr: Makefile for ir_spam1
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/test -I../../utils
|
||||
CFLAGS = -Wall -Wstrict-prototypes -Wextra -g -I../../drivers/test -I../../drivers -I../../fonts -I../../utils
|
||||
|
||||
DEL = rm
|
||||
|
||||
@@ -14,7 +14,13 @@ all: ir_spam1
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
ir_spam1-test.o: ir_spam1.c ../../drivers/test/ir_uart.h ../../drivers/test/system.h ../../utils/pacer.h
|
||||
ir_spam1-test.o: ir_spam1.c ../../drivers/display.h ../../drivers/test/ir_uart.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 $@
|
||||
|
||||
ir_uart-test.o: ../../drivers/test/ir_uart.c ../../drivers/test/ir_uart.h ../../drivers/test/system.h
|
||||
@@ -32,21 +38,27 @@ system-test.o: ../../drivers/test/system.c ../../drivers/test/avrtest.h ../../dr
|
||||
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 executable file from object files.
|
||||
ir_spam1: ir_spam1-test.o ir_uart-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o pacer-test.o
|
||||
ir_spam1: ir_spam1-test.o display-test.o ledmat-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
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) ir_spam1 ir_spam1-test.o ir_uart-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o pacer-test.o
|
||||
-$(DEL) ir_spam1 ir_spam1-test.o display-test.o ledmat-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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,21 +3,27 @@
|
||||
@date 24 September 2013
|
||||
@brief Repeatedly send message over IR.
|
||||
*/
|
||||
|
||||
#include "system.h"
|
||||
#include "pacer.h"
|
||||
#include "ir_uart.h"
|
||||
#include "tinygl.h"
|
||||
#include "../fonts/font5x7_1.h"
|
||||
|
||||
/* Define polling rate in Hz. */
|
||||
#define LOOP_RATE 20
|
||||
#define LOOP_RATE 300
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
int count = 5;
|
||||
|
||||
uint16_t ticks = 0;
|
||||
|
||||
system_init ();
|
||||
|
||||
tinygl_init (LOOP_RATE);
|
||||
tinygl_font_set (&font5x7_1);
|
||||
|
||||
tinygl_draw_char ('*', tinygl_point (0, 0));
|
||||
|
||||
ir_uart_init ();
|
||||
|
||||
pacer_init (LOOP_RATE);
|
||||
@@ -27,8 +33,15 @@ int main (void)
|
||||
{
|
||||
/* Wait for next tick. */
|
||||
pacer_wait ();
|
||||
|
||||
ir_uart_putc ('A');
|
||||
|
||||
ticks++;
|
||||
if (ticks >= 10)
|
||||
{
|
||||
ticks = 0;
|
||||
ir_uart_putc ('2');
|
||||
}
|
||||
|
||||
tinygl_update ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user