hi!
Arduino IDE can link .ino with .h and .s files, but why can't it do that when I want, heh?
OK, let me explain:
I downloaded the following example form somewhere on this forum.
It's name is BasicSerial, and it contains the following 2 files in .....Arduino\libraries\BasicSerial:
BasicSerial.h:
extern "C" {
void TxByte(char);
}
BasicSerial.s:
#include <avr/io.h>
; the defines are not impotant for my question, but let them be there
#define UART_Port (PORTE-0x20)
#define UART_Tx 1
#define bitcnt r18
#define delayArg 19
#define TXDELAY 44
.global TxByte
TxByte:
cli
sbi UART_Port-1, UART_Tx ; set Tx line to output
ldi bitcnt, 10 ; 1 start + 8 bit + 1 stop
com r24 ; invert and set carry
; etc. some more code here, not important for my question
; asm code..asm code...
reti ; return and enable interrupts
And the BasicSerial.ino is:
#include <BasicSerial.h>
#define LEDPIN PINB1
void setup(){
DDRB |= (1<<LEDPIN); // set LED pin to output mode
}
void serOut(const char* str)
{
while (*str) TxByte (*str++);
}
void loop(){
serOut("Turning on LED\n");
PORTB |= (1<<LEDPIN); // turn on LED
delay(500); // 0.5 second delay
PORTB &= ~(1<<LEDPIN); // turn off LED
delay(1000); // 1 second delay
}
Ok, when I compile BasicSerial.ino, all goes well, no error messages.
My "test" program with similar 2 files in .....Arduino\libraries_TC1test
_TC1test.h:
extern "C" {
void CT1PFC();
}
_TC1test.s
#include <avr/io.h>
.global CT1PFC
CT1PFC:
nop
ret
And my _TC1test.ino:
#include <_TC1test.h>
extern void CT1PCF();
void setup(){
CT1PCF();
}
void loop()
{
}
When I compile the sketch, I get: error: undefined reference to `CT1PCF()
No matter what I try, it doesn't work. WHy doesn't it work and why does BasicSerial example work?
thx