Created
September 26, 2013 21:18
-
-
Save dagon666/6720698 to your computer and use it in GitHub Desktop.
tdelay with libpca
This file contains 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" | |
#include <avr/io.h> | |
int main(void) | |
{ | |
DDRB = 0xff; | |
PORTB = 0x00; | |
tdelay_init(E_TIMER0); | |
while (1) { | |
PORTB ^= 0xff; | |
tdelay_ms(E_TIMER0, 1000); | |
} | |
return 0; | |
} |
This file contains 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=delay_tests | |
SOURCES=main.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