Post by engineerfreely on Aug 31, 2019 14:11:34 GMT -8
Feeling pretty defeated!
I have gotten the GD3 library to work and do some simple things on my FT812 7" Newhaven display with the Newhaven Uno Shield. Additionally, I got a canbus module to work on my Uno. Now I want to bring these together.
I am having a really hard time getting both SPIs to work right. As soon as I include my GD3.h library, it starts with this error.
Here is the code.. just a snippit, since the loop isnt relative.
I have gotten the GD3 library to work and do some simple things on my FT812 7" Newhaven display with the Newhaven Uno Shield. Additionally, I got a canbus module to work on my Uno. Now I want to bring these together.
I am having a really hard time getting both SPIs to work right. As soon as I include my GD3.h library, it starts with this error.
In file included from C:\Users\Matt\Documents\Arduino\Open_Dash_FT812\Open_Dash_FT812.ino:3:0:
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'void sdcard::desel()':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:146:5: error: 'SPI' was not declared in this scope
SPI.transfer(0xff); // force DO release
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'void sdcard::sd_delay(byte)':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:150:10: error: 'SPI' was not declared in this scope
DD SPI.transfer(0xff);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'void sdcard::cmd(byte, uint32_t, uint8_t)':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:165:8: error: 'SPI' was not declared in this scope
DD SPI.transfer(0x40 | cmd);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'byte sdcard::response()':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:177:9: error: 'SPI' was not declared in this scope
r = SPI.transfer(0xff);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'byte sdcard::R1()':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:188:5: error: 'SPI' was not declared in this scope
SPI.transfer(0xff); // trailing byte
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'byte sdcard::sdR3(uint32_t&)':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:195:26: error: 'SPI' was not declared in this scope
ocr = (ocr << 8) | SPI.transfer(0xff);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:196:5: error: 'SPI' was not declared in this scope
SPI.transfer(0xff); // trailing byte
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'byte sdcard::sdR7()':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:206:7: error: 'SPI' was not declared in this scope
SPI.transfer(0xff);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'void sdcard::begin(byte)':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:224:5: error: 'SPI' was not declared in this scope
SPI.setClockDivider(SPI_CLOCK_DIV64);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:224:25: error: 'SPI_CLOCK_DIV64' was not declared in this scope
SPI.setClockDivider(SPI_CLOCK_DIV64);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:297:25: error: 'SPI_CLOCK_DIV2' was not declared in this scope
SPI.setClockDivider(SPI_CLOCK_DIV2);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'void sdcard::cmd17(uint32_t)':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:350:12: error: 'SPI' was not declared in this scope
while (SPI.transfer(0xff) != 0xfe)
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'void sdcard::rdn(byte*, uint32_t, uint16_t)':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:358:7: error: 'SPI' was not declared in this scope
SPI.transfer(0xff);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:360:14: error: 'SPI' was not declared in this scope
*d++ = SPI.transfer(0xff);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:362:7: error: 'SPI' was not declared in this scope
SPI.transfer(0xff);
^
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h: In member function 'void Reader::fetch512(byte*)':
C:\Users\Matt\Documents\Arduino\libraries\GD3/GD3.h:695:5: error: 'SPI' was not declared in this scope
SPI.transfer(0xff);
^
exit status 1
Error compiling for board Arduino/Genuino Uno.
Here is the code.. just a snippit, since the loop isnt relative.
#include <EEPROM.h>
#include <GD3.h>
#include "SPI.h"
#include "mcp_can.h"
//byte address = 0x00;
/*SAMD core*/
#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
#define SERIAL SerialUSB
#else
#define SERIAL Serial
#endif
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int FT_SS = 10;
const int CAN_SS = 9;
const int LED = 8;
boolean ledON = 1;
// CAN BUS VARIABLES
unsigned char Flag_Recv = 0;
byte len = 1;
byte buf[8];
char str[20];
MCP_CAN CAN(CAN_SS);
unsigned int caseCan;
//CAN BUS VARIABLES
unsigned int rpm = 999;
unsigned int clt = 999;
unsigned int batt = 999;
unsigned int afr = 999;
unsigned int manpress = 999;
unsigned int mantemp = 999;
unsigned int ignadv = 999;
unsigned int tps = 999;
unsigned int afrtarget = 999;
unsigned int pw1 = 999;
unsigned int pw2 = 999;
void setup()
{
SERIAL.begin(115200);
SPI.begin();
pinMode(LED,OUTPUT);
// initialize the bus for a device on pin 9
pinMode(FT_SS,OUTPUT);
//digitalWrite(FT_SS, LOW);
// initialize the bus for a device on pin 10
pinMode(CAN_SS,OUTPUT);
//digitalWrite(CAN_SS_PIN, LOW);
GD.begin(0);
//SPI.begin(10);
//SPI.begin(9);
while (CAN_OK != CAN.begin(CAN_500KBPS)) // init can bus : baudrate = 500k
{
SERIAL.println("CAN BUS Initializng Failed");
SERIAL.println("Initializing CAN BUS again");
delay(100);
}
SERIAL.println("CAN BUS Initializing Sucessful");
delay(3000);
// Start CAN BUS
// baudrate = 500k
if(CAN_OK == CAN.begin(CAN_500KBPS))
{
// Serial.println("CAN BUS Initializing Sucessful!");
}
else
{
// Serial.println("CAN BUS Initializng Failed");
}
}
void loop()
{
// Read and Parse Data from CAN BUS
CAN.readMsgBuf(&len, buf);
caseCan = CAN.getCanId();
switch (caseCan) {
case 1512: