Simplify
This commit is contained in:
+5
-2
@@ -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 ../../utils/pacer.h
|
||||
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
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
||||
@@ -31,6 +31,9 @@ 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 $@
|
||||
|
||||
@@ -38,7 +41,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 pacer.o
|
||||
beep1.out: beep1.o pio.o system.o timer.o button.o led.o pacer.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||
$(SIZE) $@
|
||||
|
||||
|
||||
@@ -14,12 +14,15 @@ all: beep1
|
||||
|
||||
|
||||
# Compile: create object files from C source files.
|
||||
beep1-test.o: beep1.c ../../drivers/button.h ../../drivers/test/avrtest.h ../../drivers/test/delay.h ../../drivers/test/pio.h ../../drivers/test/system.h ../../utils/pacer.h
|
||||
beep1-test.o: beep1.c ../../drivers/button.h ../../drivers/led.h ../../drivers/test/avrtest.h ../../drivers/test/delay.h ../../drivers/test/pio.h ../../drivers/test/system.h ../../utils/pacer.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
button-test.o: ../../drivers/button.c ../../drivers/button.h ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
led-test.o: ../../drivers/led.c ../../drivers/led.h ../../drivers/test/avrtest.h ../../drivers/test/pio.h ../../drivers/test/system.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
|
||||
$(CC) -c $(CFLAGS) $< -o $@
|
||||
|
||||
@@ -39,14 +42,14 @@ pacer-test.o: ../../utils/pacer.c ../../drivers/test/system.h ../../drivers/test
|
||||
|
||||
|
||||
# Link: create executable file from object files.
|
||||
beep1: beep1-test.o button-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o pacer-test.o
|
||||
beep1: beep1-test.o button-test.o led-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o pacer-test.o
|
||||
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||
|
||||
|
||||
# Clean: delete derived files.
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-$(DEL) beep1 beep1-test.o button-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o pacer-test.o
|
||||
-$(DEL) beep1 beep1-test.o button-test.o led-test.o mgetkey-test.o pio-test.o system-test.o timer-test.o pacer-test.o
|
||||
|
||||
|
||||
|
||||
|
||||
+10
-19
@@ -6,24 +6,21 @@
|
||||
#include "system.h"
|
||||
#include "pio.h"
|
||||
#include "pacer.h"
|
||||
#include "button.h"
|
||||
#include "delay.h"
|
||||
|
||||
/* Connect piezo tweeter to pins 6 and 8 of UCFK4 P1 connector
|
||||
for push-pull operation. */
|
||||
#define PIEZO1_PIO PIO_DEFINE (PORT_D, 4)
|
||||
#define PIEZO2_PIO PIO_DEFINE (PORT_D, 6)
|
||||
|
||||
/* Connect piezo tweeter to outermost pins of UCFK4 P1 connector. */
|
||||
#define PIEZO_PIO PIO_DEFINE (PORT_D, 6)
|
||||
|
||||
|
||||
#define LOOP_RATE 880
|
||||
|
||||
#define TONE_FREQUENCY 440
|
||||
#define LOOP_RATE (TONE_FREQUENCY * 2)
|
||||
|
||||
int main (void)
|
||||
{
|
||||
system_init ();
|
||||
|
||||
pio_config_set (PIEZO_PIO, PIO_OUTPUT_LOW);
|
||||
|
||||
button_init ();
|
||||
pio_config_set (PIEZO1_PIO, PIO_OUTPUT_LOW);
|
||||
pio_config_set (PIEZO2_PIO, PIO_OUTPUT_HIGH);
|
||||
|
||||
pacer_init (LOOP_RATE);
|
||||
|
||||
@@ -32,14 +29,8 @@ int main (void)
|
||||
pacer_wait ();
|
||||
|
||||
/* Generate annoying tone. */
|
||||
pio_output_toggle (PIEZO_PIO);
|
||||
|
||||
/* While button down introduce delay to produce overrun. */
|
||||
if (button_down_p (BUTTON1))
|
||||
{
|
||||
delay_ms (2);
|
||||
}
|
||||
pio_output_toggle (PIEZO1_PIO);
|
||||
pio_output_toggle (PIEZO2_PIO);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user