Read this to make sure you understand what I want to do.
- I want Xcode to compile, but only so that I can debug Xcode.
- I DO NOT want to use Xcode to compile or upload code to an Arduino board. Instead, I will use the Arduino IDE in Use External Editor mode.
What I did (as well as a future link for people who might want to do the same):
(If you installed Arduino.app somewhere other than the Applications folder, you will need to configure the paths accordingly.)
I included in main.cpp <WProgram.h>, but that was not enough. I received undefined identifier errors (for SPCR, SPE, MSTR, SPR1, SPR0) due to the inability to pass the -mmcu=somechipnameflag to the compiler, which the device did not detect and avr/io.hcannot include the file that defines these characters. I bypassed it manually, including <avr/iom328p.h>, which is the corresponding header file for my chip.
How far have I got.
Now I get the following errors:
Undefined symbols for architecture i386:
"_init", referenced from:
_main in main.o
"_setup", referenced from:
_main in main.o
"_loop", referenced from:
_main in main.o
"_pinMode", referenced from:
SBSetup() in main.o
"_digitalWrite", referenced from:
SBSetup() in main.o
The whole main.cpp, including the crime code, is this:
#include <WProgram.h>
#include <avr/iom328p.h> // Getting around warning "device type not defined"
#define NumLEDs 25
#define clockpin 13
#define enablepin 10
#define latchpin 9
#define datapin 11
int LEDChannels[NumLEDs][3] = {0};
int SB_CommandMode;
int SB_RedCommand;
int SB_GreenCommand;
int SB_BlueCommand;
void SBSetup(void) {
pinMode(datapin, OUTPUT);
pinMode(latchpin, OUTPUT);
pinMode(enablepin, OUTPUT);
pinMode(clockpin, OUTPUT);
SPCR = (1<<SPE)|(1<<MSTR)|(0<<SPR1)|(0<<SPR0);
digitalWrite(latchpin, LOW);
digitalWrite(enablepin, LOW);
}
int main(void)
{
init();
setup();
for (;;)
loop();
return 0;
}
What I need?