Hello everyone! I have a spa sd card reader connected to a arduino giga on SPI1 but I am unable to access it with the following code:
#include <SPI.h>
const uint8_t SPI_CS_PIN = 10; // Chip select pin (adjust according to your setup)
void setup() {
Serial.begin(115200);
// Initialize SPI1
SPI1.begin();
// Configure SPI settings (modify based on your device's requirements)
SPI1.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
// Configure chip select pin
pinMode(SPI_CS_PIN, OUTPUT);
digitalWrite(SPI_CS_PIN, HIGH); // Set the chip select pin high initially
Serial.println("SPI1 Initialized.");
}
void loop() {ta
digitalWrite(SPI_CS_PIN, LOW); // Select the device
// Send a dummy byte and receive data
uint8_t sentData = 0x00;
uint8_t receivedData = SPI1.transfer(sentData);
digitalWrite(SPI_CS_PIN, HIGH); // Deselect the device
// Print sent and received data
Serial.print("Sent Data: ");
Serial.print(sentData, HEX);
Serial.print(" Received Data: ");
Serial.println(receivedData, HEX);
// Add delay
delay(1000);
}
// Add debugging to check chip select pin state
Serial.print("CS Pin State: ");
Serial.println(digitalRead(SPI_CS_PIN));
// Send and receive da