Hello, All!
What is my task:
I want call external ASM function from main CPP file
files:
main.cpp - is the main program file:
#include <Arduino.h>
#include "wait.h"
extern void wait();
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, ! digitalRead(LED_BUILTIN));
wait();
}
wait.S - asm file which contains external function wait:
.global wait
wait:
ldi r18, 50
ldi r19, 255
ldi r20, 255
_wait_loop:
dec r20
brne _wait_loop
dec r19
brne _wait_loop
dec r18
brne _wait_loop
ret
there is also wait.h file:
#ifdef __ASSEMBLER__
.global wait
#endif
#ifndef __ASSEMBLER__
extern void wait();
#endif
But i can’t create a execute file for Arduino.
Processing uno (platform: atmelavr; board: uno; framework: arduino)
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR 2.0.0 > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
PACKAGES: toolchain-atmelavr 1.50400.190710 (5.4.0), framework-arduino-avr 5.0.0
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 5 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Compiling .pio/build/uno/src/main.cpp.o
Linking .pio/build/uno/firmware.elf
/var/folders/_f/qkt_p2mj2g719nvf5gf92hvc0000gn/T//cch1kis8.ltrans0.ltrans.o: In function `main':
<artificial>:(.text.startup+0x148): undefined reference to `wait()'
collect2: error: ld returned 1 exit status
*** [.pio/build/uno/firmware.elf] Error 1
**undefined reference to wait()** !!!
I make tests:
“main.cpp” with external “wait.cpp” - OK!
"main.S with external “wait.S” - OK!
but “main.cpp” with “wait.S” - Wrong!!!
Help me please someone who knows the solution.