Created
September 30, 2013 20:30
-
-
Save dagon666/6769790 to your computer and use it in GitHub Desktop.
generating tones with libpca
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "pca.h" | |
| int main(void) | |
| { | |
| // initialize timer 0 as a tone generator | |
| // TDELAY_IMPLEMENT_T0_INT must be set to 1 in config.h | |
| beeper_init(E_TIMER0); | |
| for (uint8_t i = 0; i < 10; i++) { | |
| // start generating tone with timer 0, of frequency (440 + (110*i)), | |
| // lasting 300 ms | |
| beeper_beep(E_TIMER0, 440 + (100*i), 300); | |
| // wait until tone generation is finished | |
| beeper_block(E_TIMER0); | |
| } | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TARGET=beep_libpca | |
| SOURCES=beep_libpca.c | |
| DEPS= | |
| COBJ=$(SOURCES:.c=.o) | |
| PCA_PREFIX=../pca | |
| CC=avr-gcc | |
| OBJC=avr-objcopy | |
| MCU=atmega328p | |
| CFLAGS=-I. -I$(PCA_PREFIX)/include/ -Wall -Os -DF_CPU=16000000UL -std=c99 | |
| LDFLAGS=-lpca -L$(PCA_PREFIX) | |
| ISPPORT=/dev/ttyACM0 | |
| ISPDIR=/usr/share/arduino/hardware/tools | |
| ISP=$(ISPDIR)/avrdude | |
| ISPFLAGS=-c arduino -p $(MCU) -P $(ISPPORT) -b 115200 -C $(ISPDIR)/avrdude.conf | |
| all: $(TARGET) | |
| %.o: %.c $(DEPS) | |
| @echo -e "\tCC" $< | |
| @$(CC) -mmcu=$(MCU) -c -o $@ $< $(CFLAGS) | |
| libpca.a: | |
| @echo -e "\tBUILDING PURE C ARDUINO LIB" | |
| $(MAKE) -C $(PCA_PREFIX) | |
| $(TARGET): $(COBJ) libpca.a | |
| @echo -e "\tLINKING CC" $< | |
| @$(CC) -mmcu=$(MCU) -o $(TARGET) $(COBJ) $(LDFLAGS) | |
| $(OBJC) -O ihex -R .eeprom $(TARGET) $(TARGET).hex | |
| $(OBJC) -O binary -R .eeprom $(TARGET) $(TARGET).bin | |
| clean: | |
| $(MAKE) -C $(PCA_PREFIX) clean | |
| @echo ========== cleanup ========== | |
| rm -rf *.o *.bin *.hex $(TARGET) | |
| read: | |
| $(ISP) $(ISPFLAGS) -U flash:r:$(TARGET)_backup.hex:i | |
| install: | |
| $(ISP) $(ISPFLAGS) -U flash:w:$(TARGET).hex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment