I'm trying to port an Arduino sketch to Maple because I need the 18MHz SPI Speed. After changing over all the SPI calls, I'm getting tons of errors, and can't figure any of them out. Can someone lend a hand?
HardwareSPI Spi(1);
const int initTable[24] = {0x30,0x08,0x00,0x00,0x30,0x08,0x00,0x00,0x80,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x00,0x40};
const byte tableHi[] = {0x07,0x07,0x07,0x06,0x06,0x05,0x05,0x05,0x05,0x04,0x04,0x04,0x03,0x03,0x03,0x03,0x03,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
const byte tableLo[] = {0xF1,0x80,0x13,0xAD,0x4D,0xF3,0x9D,0x4D,0x00,0xB8,0x75,0x35,0xF8,0xBF,0x89,0x56,0x26,0xF9,0xCE,0xA6,0x7F,0x5C,0x3A,0x1A,0xFB,0xDF,0xC4,0xAB,0x93,0x7C,0x67,0x52,0x3F,0x2D,0x1C,0x0C,0xFD,0xEF,0xE2,0xD2,0xC9,0xBD,0xB3,0xA9,0x9F,0x96,0x8E,0x86,0x7E,0x77,0x70,0x6A,0x64,0x5E,0x59,0x54};
//These tables were taken from http://www.freewebs.com/the_bott/NotesTableNTSC.txt
//tableHi is the top 3 bits for $4003, tableLo is the bottom 8 bits for $4002
int latchPin = 8;
volatile boolean state = false; //switch to make sure I write values at the right time
void writeData(){ //routine to switch state while NES is BRKing
state=true; //switch state
}
void sendAddrData(byte address, byte data){ //routine to send address and data along to '245s when interrupt is thrown
state = false; //set switch
while (state!=true); //wait for interrupt to throw switch back
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
Spi.send(address, sizeof(byte));
Spi.send(data, sizeof(byte));
}
void setup() {
Spi.begin(SPI_18MHZ, MSBFIRST, 0);
pinMode(latchPin, OUTPUT);
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
Spi.send(0x15, sizeof(byte));
Spi.send(0x1F, sizeof(byte));
attachInterrupt(0, writeData, RISING); //begin interrupt function on pin 21, calls writeData on falling edge
for (byte n = 0; n < 0x18; n++) sendAddrData(n,initTable[(int)n]);
}
void loop() { //main loop
sendAddrData(0x15, 0x1F); //Turn on all channels
sendAddrData(0x00, 0xBF); //Turn square wave to max volume, 50% duty, etc
sendAddrData(0x01, 0x08); //Negate sweeps
for(int n; n < sizeof(tableHi)/sizeof(int); n++)
{
sendAddrData(0x02, tableLo[n]); //increment through the note table posted above, low bits
sendAddrData(0x03, tableHi[n]); //increment through the note table posted above, high bits
sendAddrData(0x1F, 0x00); //end write, NES does its thing now
delay(125); //note duration
}
sendAddrData(0x15, 0x00); //silence all channels
sendAddrData(0x1F, 0x00); //end write
}
Errors:
<BUILD>\sketch_nov24a.cpp: In function 'void sendAddrData(byte, byte)':
<BUILD>\sketch_nov24a.cpp:26: error: invalid conversion from 'byte' to 'uint8*'
<BUILD>\sketch_nov24a.cpp:26: error: initializing argument 1 of 'uint8 HardwareSPI::send(uint8*, uint32)'
<BUILD>\sketch_nov24a.cpp:27: error: invalid conversion from 'byte' to 'uint8*'
<BUILD>\sketch_nov24a.cpp:27: error: initializing argument 1 of 'uint8 HardwareSPI::send(uint8*, uint32)'
<BUILD>\sketch_nov24a.cpp: In function 'void setup()':
<BUILD>\sketch_nov24a.cpp:35: error: invalid conversion from 'int' to 'uint8*'
<BUILD>\sketch_nov24a.cpp:35: error: initializing argument 1 of 'uint8 HardwareSPI::send(uint8*, uint32)'
<BUILD>\sketch_nov24a.cpp:36: error: invalid conversion from 'int' to 'uint8*'
<BUILD>\sketch_nov24a.cpp:36: error: initializing argument 1 of 'uint8 HardwareSPI::send(uint8*, uint32)'
<BUILD>\sketch_nov24a.cpp: In function 'void loop()':
<BUILD>\sketch_nov24a.cpp:45: warning: comparison between signed and unsigned integer expressions