Tried to compile with WinAVR and got the following error :
Code: Select all
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c a7105.c -o a7105.o
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c flysky_a7105.c -o flysky_a7105.o
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c hubsan_a7105.c -o hubsan_a7105.o
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c misc.c -o misc.o
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c spi.c -o spi.o
avr-gcc -DF_CPU=16000000 -I. -ffreestanding -ffunction-sections -Wall -Os -DNRF_CHECK_MODULE -mmcu=atmega168 -c ppm2spi.c -o ppm2spi.o
ppm2spi.c:38: error: 'FLYSKY' undeclared here (not in a function)
make: *** [ppm2spi.o] Error 1
The line avr-gcc is complaining about is in global variables :
uint8_t proto_mode = FLYSKY;
it is defined as "extern" in common.h
extern uint8_t proto_mode;
As a trial and error fix, I tried to replace FLYSKY by FLYSKY_STD and got the following errors :
ppm2spi.o: In function `main':
ppm2spi.c:(.text.main+0xb8): undefined reference to `HUBSAN_Cmds'
ppm2spi.c:(.text.main+0xce): undefined reference to `FLYSKY_Cmds'
ppm2spi.c:(.text.main+0xda): undefined reference to `FLYSKY_Cmds'
make: *** [ppm2spi.hex] Error 1
I'm lost, help
EDIT:
Think I found it :
- reverted to : uint8_t proto_mode = FLYSKY;
- mapped DEBUG_2 to PORTC 5.
- edited the makefile to read :
Code: Select all
...
CFLAGS = -Wall -gdwarf-2 -std=gnu99 -DPROTODEF -DPROTO_HAS_A7105 -DFLYSKY -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -DNRF_CHECK_MODULE
LFLAGS = -Wl,--relax,--gc-sections
OBJECTS = a7105.o flysky_a7105.o hubsan_a7105.o misc.o spi.o $(TARGET).o
...
I didn't include spi_bitbang.o in the object files because it generates a bunch of errors.
Since we are using hardware SPI, and the stuff belonging to bitbang in pp2spi.c is commented, I assume it's not necessary.
I'm I right ?
Anyway it compiled without further warnings or errors :
Code: Select all
avr-objcopy -j .text -j .data -O ihex ppm2spi.elf ppm2spi.hex
avr-size -C --mcu=atmega168 ppm2spi.elf
AVR Memory Usage
----------------
Device: atmega168
Program: 4562 bytes (27.8% Full)
(.text + .data + .bootloader)
Data: 429 bytes (41.9% Full)
(.data + .bss + .noinit)
Now to see if it works...