Hello there Im working on a project based on arduino and I would like to get you involved in it.
What I'm trying to do is an arduino reader and writer for spi, i2c and parallel eeproms. When I finish this project I will make it fully open source and I will share it with all of you so because of that I want to hear your opinion what should be done, what to consider as option in software, code look up to see if I missed something and so on.
So far I came up with this:
I already started writing code for SPI and I figure out it will be hard to make it as simple as possible but still easy to adopt to any eeprom. So here I have a question about ready bit in status register. Many of manufacturers calls them RDY but winbond calls it BUSY instead so how give a clue to user when searching the datasheet what to look for?
In the attachment is visual basic code for windows side app and here is an arduino part:
#include <SPI.h>
int CS;
int CSPinAL = 0;
int SO;
int SOPinAL = 0;
int WP;
int WPPinAL = 0;
int SI;
int SIPinAL = 0;
int SCLK;
int SCKPinAL = 0;
int HOLD;
int HOLDPinAL = 0;
int Addressbitlength = 0;
int HighestAddressBit = 0;
int DataBit = 0;
int WRDIint = 0;
int RDRSint = 0;
int WRSRint = 0;
int READint = 0;
int WRITEint = 0;
int WRENint = 0;
int WEN = 0;
int RDY = 0;
int WENAL = 0;
int RDYAL = 0;
String Serial_Data;
int Protocol;
void setup() {
Serial.begin(115200);
Serial.setTimeout(5);
Serial.print("Ready");
do {//Used to send board info
if(Serial.available()){
Serial_Data = Serial.readStringUntil('\n');
}
if (Serial_Data == "B"){
Serial.print("Nano");
Serial_Data = "";
break;
}
} while (1 == 1);
do {
if(Serial.available()){
Serial_Data = Serial.readStringUntil('\n');
}
if (Serial_Data == "2"){
Serial.print("SPI");
Serial_Data = "";
Protocol = 3;
break;
}
} while (1 == 1);
if (Protocol == 3){
int CSPin = 0;
do { //CS pin setup
if(Serial.available()){
CSPin = Serial.parseInt();
}
if (CSPin != 0){
CS = CSPin;
Serial.print(CSPin);
break;
}
} while (1 == 1);
do { //CS pin active low or high
if(Serial.available()){
CSPinAL = Serial.parseInt();
}
if (CSPinAL != 0){//cs pin active low
Serial.print(CSPinAL);
break;
}
} while (1 == 1);
int SOPin = 0;
do { //SO pin setup
if(Serial.available()){
SOPin = Serial.parseInt();
}
if (SOPin != 0){
SO = SOPin;
Serial.print(SOPin);
break;
}
} while (1 == 1);
do { //SO pin active low or high
if(Serial.available()){
SOPinAL = Serial.parseInt();
}
if (SOPinAL != 0){//so pin active low
Serial.print(SOPinAL);
break;
}
} while (1 == 1);
int WPPin = 0;
do { //WP pin setup
if(Serial.available()){
WPPin = Serial.parseInt();
}
if (WPPin != 0){
WP = WPPin;
Serial.print(WPPin);
break;
}
} while (1 == 1);
do { //WP pin active low or high
if(Serial.available()){
WPPinAL = Serial.parseInt();
}
if (WPPinAL != 0){//WP pin active low
Serial.print(WPPinAL);
break;
}
} while (1 == 1);
int SIPin = 0;
do { //SI pin setup
if(Serial.available()){
SIPin = Serial.parseInt();
}
if (SIPin != 0){
SI = SIPin;
Serial.print(SIPin);
break;
}
} while (1 == 1);
do { //SI pin active low or high
if(Serial.available()){
SIPinAL = Serial.parseInt();
}
if (SIPinAL != 0){//SI pin active low
Serial.print(SIPinAL);
break;
}
} while (1 == 1);
int SCKPin = 0;
do { //SCK pin setup
if(Serial.available()){
SCKPin = Serial.parseInt();
}
if (SCKPin != 0){
SCLK = SCKPin;
Serial.print(SCKPin);
break;
}
} while (1 == 1);
do { //SCK pin active low or high
if(Serial.available()){
SCKPinAL = Serial.parseInt();
}
if (SCKPinAL != 0){//SCK pin active low
Serial.print(SCKPinAL);
break;
}
} while (1 == 1);
int HOLDPin = 0;
do { //HOLD pin setup
if(Serial.available()){
HOLDPin = Serial.parseInt();
}
if (HOLDPin != 0){
HOLD = HOLDPin;
Serial.print(HOLDPin);
break;
}
} while (1 == 1);
do { //HOLD pin active low or high
if(Serial.available()){
HOLDPinAL = Serial.parseInt();
}
if (HOLDPinAL != 0){//HOLD pin active low
Serial.print(HOLDPinAL);
break;
}
} while (1 == 1);
do { //Address bit length
if(Serial.available()){
Addressbitlength= Serial.parseInt();
}
if (Addressbitlength != 0){//Address bit length isnot 0
Serial.print(Addressbitlength);
break;
}
} while (1 == 1);
do { //ActualAddressLenth
if(Serial.available()){
HighestAddressBit = Serial.parseInt();
}
if (HighestAddressBit != 0){//HighestAddressBit isnot 0
Serial.print(HighestAddressBit);
break;
}
} while (1 == 1);
do { //DataBitLenth
if(Serial.available()){
DataBit = Serial.parseInt();
}
if (DataBit != 0){//DataBit lenth isnot 0
Serial.print(DataBit);
break;
}
} while (1 == 1);
do { //WRDIint WRDI as integer
if(Serial.available()){
WRDIint = Serial.parseInt();
}
if (WRDIint != 0){//WRDIint as integer > 0
Serial.print(WRDIint);
break;
}
} while (1 == 1);
do { //RDRSint RDRS as integer
if(Serial.available()){
RDRSint = Serial.parseInt();
}
if (RDRSint != 0){//RDRSint as integer > 0
Serial.print(RDRSint);
break;
}
} while (1 == 1);
do { //WRSRint WRSR as integer
if(Serial.available()){
WRSRint = Serial.parseInt();
}
if (WRSRint != 0){//WRSRint as integer > 0
Serial.print(WRSRint);
break;
}
} while (1 == 1);
do { //READint READ as integer
if(Serial.available()){
READint = Serial.parseInt();
}
if (READint != 0){//READint as integer > 0
Serial.print(READint);
break;
}
} while (1 == 1);
do { //WRITEint WRITE as integer
if(Serial.available()){
WRITEint = Serial.parseInt();
}
if (WRITEint != 0){//WRITEint as integer > 0
Serial.print(WRITEint);
break;
}
} while (1 == 1);
do { //WRENint WREN as integer
if(Serial.available()){
WRENint = Serial.parseInt();
}
if (WRENint != 0){//WRENint as integer > 0
Serial.print(WRENint);
break;
}
} while (1 == 1);
do {//Status register setup
Serial_Data = "";
if(Serial.available()){
Serial_Data = Serial.readStringUntil('\n');
}
if (Serial_Data == "E"){
Serial.print(Serial_Data);
Serial_Data = "";
int WENr = 0;
do { //WEN register setup
if(Serial.available()){
WENr = Serial.parseInt();
}
if (WENr != 0){
WEN = WENr;
Serial.print(WENr);
break;
}
} while (1 == 1);
do { //WEN bit active low or high
if(Serial.available()){
WENAL = Serial.parseInt();
}
if (WENAL != 0){//WEN bit active low
Serial.print(WENAL);
break;
}
} while (1 == 1);
}
if (Serial_Data == "W"){
Serial.print(Serial_Data);
Serial_Data = "";
int RDYr = 0;
do { //RDY register setup
if(Serial.available()){
RDYr = Serial.parseInt();
}
if (RDYr != 0){
RDY = RDYr;
Serial.print(RDYr);
break;
}
} while (1 == 1);
do { //RDY bit active low or high
if(Serial.available()){
RDYAL = Serial.parseInt();
}
if (RDYAL != 0){//RDY bit active low
Serial.print(RDYAL);
break;
}
} while (1 == 1);
}
} while (Serial_Data != "Z");
Serial.print(Serial_Data);
Serial_Data = "";
pinMode(13, OUTPUT);
digitalWrite(13,HIGH);
delay(1000);
}
}
void loop() {
}
And that's it for now I work every day on it so Im sorry it is not too well commented and there are some mess in code but that's just for now. When I will have time i will clean it up a bit.
Looking for your suggestions, support or how ever you can help
RW.txt (94.8 KB)