Created
May 9, 2018 07:30
-
-
Save boseji/fa25fa64bae203c9b6ca1017a6835ef1 to your computer and use it in GitHub Desktop.
RTL8711 to SPI Flash connection and checking of Device Signature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include "PinNames.h" | |
// 11 - GPIOC_2 - SPI0_MOSI = Connected to Chip SPI MOSI | |
// 12 - GPIOC_3 - SPI0_MISO = Connected to Chip SPI MISO | |
// 13 - GPIOC_1 - SPI0_CLK = Connected to Chip SPI SCK | |
// GPIOC_4 - SPI0_CS1 = Connected to Chip SPI CS | |
#define CS PC_4 | |
SPISettings settings = SPISettings(20000000, MSBFIRST, SPI_MODE0); | |
void setup() { | |
Serial.begin(9600); | |
pinMode(CS,OUTPUT); | |
digitalWrite(CS, HIGH); | |
SPI.begin(); | |
Serial.println(F("Ready!")); | |
} | |
void loop() { | |
Serial.println (); | |
Serial.println (F("SPI Signature Read")); | |
digitalWrite(CS, LOW); | |
SPI.beginTransaction(settings); | |
SPI.transfer(0x9F); | |
SPI.transfer(0x00); | |
Serial.println(SPI.transfer(0x00),HEX); | |
Serial.println(SPI.transfer(0x00),HEX); | |
SPI.endTransaction(); | |
digitalWrite(CS, HIGH); | |
digitalWrite(CS, LOW); | |
SPI.beginTransaction(settings); | |
SPI.transfer(0x90); | |
SPI.transfer(0x00); | |
SPI.transfer(0x00); | |
SPI.transfer(0x00); | |
Serial.println(SPI.transfer(0x00),HEX); | |
Serial.println(SPI.transfer(0x00),HEX); | |
SPI.endTransaction(); | |
digitalWrite(CS, HIGH); | |
Serial.println(); | |
Serial.println(F("Done.")); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment