Используйте библиотеки Arduino в программе AVR

Я пытаюсь перейти от использования платы разработки, такой как Arduino Uno, к программированию прямо на AVR. Тем не менее, библиотеки Arduino, а также некоторые сторонние библиотеки Arduino очень полезны, и я хотел бы иметь возможность их использовать, но у меня возникают проблемы с настройкой make-файла, чтобы включить их. В настоящее время я просто пытаюсь включить библиотеку "TimerOne", которую я скачал. Он просто предоставляет удобные методы для использования таймеров AVR и ISR. Мое очень простое тестовое приложение просто пытается переключать светодиоды каждую секунду.

Мой make-файл выглядит так:

# Name: Makefile
#
# A simple program for the ATMEGA32A-PU that blinks an LED.
#

DEVICE     = atmega32
CLOCK      = 1000000
PROGRAMMER = -c avrisp 
OBJECTS    = main.o

# List any extra directories to look for include files here.
#     Each directory must be seperated by a space.
EXTRAINCDIRS = -IC:\WinAVR-20100110\avr\include\Timer1

# for ATTiny85 - unset CKDIV8
FUSES       = -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m 

# Tune the lines below only if you know what you are doing:

AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
COMPILE = avr-g++ $(EXTRAINCDIRS) -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)

# symbolic targets:
all:  main.hex

.c.o:
    $(COMPILE) -c $< -o $@
.cpp.o:
    $(COMPILE) -c $< -o $@

.S.o:
    $(COMPILE) -x assembler-with-cpp -c $< -o $@
# "-x assembler-with-cpp" should not be necessary since this is the default
# file type for the .S (with capital S) extension. However, upper case
# characters are not always preserved on Windows. To ensure WinAVR
# compatibility define the file type manually.

.c.s:
    $(COMPILE) -S $< -o $@
.cpp.s:
    $(COMPILE) -S $< -o $@

flash:  all
    $(AVRDUDE) -U flash:w:main.hex:i

fuse:
    $(AVRDUDE) $(FUSES)

# Xcode uses the Makefile targets "", "clean" and "install"
install: flash fuse

# if you use a bootloader, change the command below appropriately:
load: all
    bootloadHID main.hex

clean:
    rm -f main.hex main.elf $(OBJECTS)

# file targets:
main.elf: $(OBJECTS)
    $(COMPILE) -o main.elf $(OBJECTS)

main.hex: main.elf
    rm -f main.hex
    avr-objcopy -j .text -j .data -O ihex main.elf main.hex
    avr-size --format=avr --mcu=$(DEVICE) main.elf
# If you have an EEPROM section, you must also create a hex file for the
# EEPROM and add it to the "flash" target.

# Targets for code debugging and analysis:
disasm: main.elf
    avr-objdump -d main.elf

cpp:
    $(COMPILE) -E main.c

main.c

#include "TimerOne.h"
#include <avr/io.h>
void refresh();
int main(void)
{

  DDRD |= 0xff;     //Set PortD Pins as an output
  PORTD |= 0xff;    //Set PortD Pins high to turn on LEDs
  Timer1.initialize(1000000); // 1000000us = 1s
  Timer1.attachInterrupt(refresh);

  while(1) { }          //Loop forever, interrupts do the rest
}

void refresh()
{
    PORTD ^= 0XFF;
}

Ошибка, которую я получаю при запуске make:

avr-g++ -IC:\WinAVR-20100110\avr\include\Timer1 -Wall -Os -DF_CPU=1000000 -mmcu=atmega32 -c main.c -o main.o
avr-g++ -IC:\WinAVR-20100110\avr\include\Timer1 -Wall -Os -DF_CPU=1000000 -mmcu=atmega32 -o main.elf main.o
main.o: In function `main':
main.c:(.text+0x12): undefined reference to `Timer1'
main.c:(.text+0x14): undefined reference to `Timer1'
main.c:(.text+0x1e): undefined reference to `TimerOne::initialize(long)'
main.c:(.text+0x22): undefined reference to `Timer1'
main.c:(.text+0x24): undefined reference to `Timer1'
main.c:(.text+0x32): undefined reference to `TimerOne::attachInterrupt(void (*)(), long)'
make: *** [main.elf] Error 1  

Судя по всему, похоже, что я не сказал компилятору, как правильно строить библиотеку TimerOne. Что мне не хватает?
Я использую Windows10 x64.

0 ответов

Другие вопросы по тегам