Simplify
This commit is contained in:
+5
-2
@@ -16,7 +16,7 @@ all: beep1.out
|
|||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C source files.
|
# 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 $@
|
$(CC) -c $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
pio.o: ../../drivers/avr/pio.c ../../drivers/avr/pio.h ../../drivers/avr/system.h
|
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
|
button.o: ../../drivers/button.c ../../drivers/avr/pio.h ../../drivers/avr/system.h ../../drivers/button.h
|
||||||
$(CC) -c $(CFLAGS) $< -o $@
|
$(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
|
pacer.o: ../../utils/pacer.c ../../drivers/avr/system.h ../../drivers/avr/timer.h ../../utils/pacer.h
|
||||||
$(CC) -c $(CFLAGS) $< -o $@
|
$(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.
|
# 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
|
$(CC) $(CFLAGS) $^ -o $@ -lm
|
||||||
$(SIZE) $@
|
$(SIZE) $@
|
||||||
|
|
||||||
|
|||||||
@@ -14,12 +14,15 @@ all: beep1
|
|||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C source files.
|
# 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 $@
|
$(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
|
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 $@
|
$(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
|
mgetkey-test.o: ../../drivers/test/mgetkey.c ../../drivers/test/mgetkey.h
|
||||||
$(CC) -c $(CFLAGS) $< -o $@
|
$(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.
|
# 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
|
$(CC) $(CFLAGS) $^ -o $@ -lrt
|
||||||
|
|
||||||
|
|
||||||
# Clean: delete derived files.
|
# Clean: delete derived files.
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
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 "system.h"
|
||||||
#include "pio.h"
|
#include "pio.h"
|
||||||
#include "pacer.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 TONE_FREQUENCY 440
|
||||||
#define PIEZO_PIO PIO_DEFINE (PORT_D, 6)
|
#define LOOP_RATE (TONE_FREQUENCY * 2)
|
||||||
|
|
||||||
|
|
||||||
#define LOOP_RATE 880
|
|
||||||
|
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
system_init ();
|
system_init ();
|
||||||
|
|
||||||
pio_config_set (PIEZO_PIO, PIO_OUTPUT_LOW);
|
pio_config_set (PIEZO1_PIO, PIO_OUTPUT_LOW);
|
||||||
|
pio_config_set (PIEZO2_PIO, PIO_OUTPUT_HIGH);
|
||||||
button_init ();
|
|
||||||
|
|
||||||
pacer_init (LOOP_RATE);
|
pacer_init (LOOP_RATE);
|
||||||
|
|
||||||
@@ -32,14 +29,8 @@ int main (void)
|
|||||||
pacer_wait ();
|
pacer_wait ();
|
||||||
|
|
||||||
/* Generate annoying tone. */
|
/* Generate annoying tone. */
|
||||||
pio_output_toggle (PIEZO_PIO);
|
pio_output_toggle (PIEZO1_PIO);
|
||||||
|
pio_output_toggle (PIEZO2_PIO);
|
||||||
/* While button down introduce delay to produce overrun. */
|
|
||||||
if (button_down_p (BUTTON1))
|
|
||||||
{
|
|
||||||
delay_ms (2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user