I'm working on SD code, and the code for the card init compiles successfully, but with extended warning messages that say I'm doing something I don't think I'm doing. This is obviously a case of my not knowing what I'm doing in C++. If anyone can help me out, I would appreciate it. Below are the warnings, and the code.
C:\Arduino\Portable\sketchbook\MySD\MySD.ino: In function 'byte initCard()':
C:\Arduino\Portable\sketchbook\MySD\MySD.ino:67:19: warning: invalid conversion from 'int' to 'unsigned char*' [-fpermissive]
t = sendCmd(58);
^
C:\Arduino\Portable\sketchbook\MySD\MySD.ino:91:6: note: initializing argument 1 of 'byte sendCmd(unsigned char*)'
byte sendCmd (unsigned char *cmd) {
^
C:\Arduino\Portable\sketchbook\MySD\MySD.ino:79:19: warning: invalid conversion from 'int' to 'unsigned char*' [-fpermissive]
t = sendCmd(16);
^
C:\Arduino\Portable\sketchbook\MySD\MySD.ino:91:6: note: initializing argument 1 of 'byte sendCmd(unsigned char*)'
byte sendCmd (unsigned char *cmd) {
^
byte CSpin = 10;
byte i,j,k,t,z;
byte rIn, SDHC;
bool type2;
unsigned long prevmillis;
byte CSDELAY = 14;
unsigned char CMD0[] = {0x40,0,0,0,0,0x95}; //intialization commands
unsigned char CMD8[] = {0x48,0,0,1,0xAA,0x87};
unsigned char CMD16[] = {0x50,0,0,2,0,0x15};
unsigned char CMD55[] = {0x77,0,0,0,0,0x65};
unsigned char CMD411[]= {0x69,0,0,0,0,0xE5};
unsigned char CMD412[]= {0x69,0x40,0,0,0,0x77};
unsigned char CMD12[] = {0x4C,0,0,0,0,0x61};
unsigned char CMD58[] = {0x7A,0,0,0,0,0xFD};
void setup() {
delay(3000);
Serial.begin(9600);
Serial.println("Starting...");
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(13, OUTPUT);
pinMode(12, INPUT_PULLUP);
SPCR = (1 << SPE) | (1 << MSTR) | (1 << SPR1); //250k
z = initCard();
Serial.println (z);
}
byte initCard() {
digitalWrite(CSpin, HIGH);
for (k = 0; k< 10; k++) {
GetByte();
}
digitalWrite(CSpin, LOW);
delay(100);
for (k = 10; k > 0 ; k--) {
t = sendCmd(CMD0);
if (t == 1) break;
}
if (t != 1) return 1;
t = sendCmd(CMD8);
if (t == 1) {
for (k = 0; k < 4; k++) {
InByte();
}
if (rIn = 0XAA) type2 = true;
else return 2;
}
else if (t == 5) type2 = false;
else return 3;
prevmillis = millis();
while (1) {
if (sendCmd(CMD55) == 5) return 4;
if (type2 == false) t = sendCmd(CMD411);
else t = sendCmd(CMD412);
if (t == 0) break;
if ((millis() - prevmillis) > 2000) return 5;
}
for (k = 10; k > 0; k--) {
t = sendCmd(58); // should be (CMD58)
if (t != 0) continue;
SDHC = GetByte();
TM1();
if ((SDHC & 0x80) == 0) continue;
SDHC &= 0x40; // flag not zero if SDHC
break;
}
if (k == 0) return 6;
if (SDHC == 0) {
t = sendCmd(16); /// should be (CMD16)
if (t != 0) return 7;
}
return 0;
}
void TM1() {
InByte();
InByte();
InByte();
}
byte sendCmd (unsigned char *cmd) {
GetByte();
digitalWrite (CSpin,HIGH);
Delay();
digitalWrite (CSpin,LOW);
Delay();
for (i = 0; i < 6; i++) {
SPDR = cmd[i];
while (!(SPSR & (1 << SPIF)))
rIn = SPDR;
}
InByte();
return rIn;
}
void InByte() {
for (i = 0; i < 11; i++) {
rIn = GetByte();
if (rIn != 0xFF) break;
}
}
byte GetByte () {
SPDR = 0xFF;
while (!(SPSR & (1 << SPIF)));
return SPDR;
}
void Delay(){
for (i = 0; i < CSDELAY; i++);
}
void loop() {
}