-
Notifications
You must be signed in to change notification settings - Fork 13
Add WP control #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WP control #30
Conversation
src/SparkFun_External_EEPROM.cpp
Outdated
@@ -66,6 +66,22 @@ bool ExternalEEPROM::begin(uint8_t deviceAddress, TwoWire &wirePort) | |||
|
|||
return true; | |||
} | |||
bool ExternalEEPROM::begin(uint8_t WP = LED_BUILTIN, uint8_t deviceAddress, TwoWire &wirePort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the WP setting the the end: deviceAddress, wirePort, WP
src/SparkFun_External_EEPROM.cpp
Outdated
@@ -876,6 +892,9 @@ int ExternalEEPROM::write(uint32_t eepromLocation, const uint8_t *dataToWrite, u | |||
while (isBusy(settings.deviceAddress) == true) // Poll device's original address, not the modified one | |||
delayMicroseconds(100); // This shortens the amount of time waiting between writes but hammers the I2C bus | |||
|
|||
// Check if we are using Write Protection then disable WP for write access | |||
if(settings.usingWP) digitalWrite(settings.wpPin, LOW); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the built-in Arduino formatter style. Please remove whitespace: usingWP) digitalWrite...
src/SparkFun_External_EEPROM.cpp
Outdated
@@ -885,6 +904,8 @@ int ExternalEEPROM::write(uint32_t eepromLocation, const uint8_t *dataToWrite, u | |||
settings.i2cPort->write(dataToWrite[recorded + x]); | |||
|
|||
result = settings.i2cPort->endTransmission(); // Send stop condition | |||
// Enable Write Protection if we are using WP | |||
if(settings.usingWP) digitalWrite(settings.wpPin, HIGH); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove whitespace.
src/SparkFun_External_EEPROM.h
Outdated
@@ -111,6 +111,8 @@ struct struct_memorySettings | |||
uint8_t writeTime_ms; | |||
bool pollForWriteComplete; | |||
uint8_t addressSize_bytes; | |||
bool usingWP; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than use a bool, I recommend setting the wpPin default to 255 and then test against it: if(settings.wpPin != 255) digitalWrite(...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a user sets the pin to something other than 255, WP control is enabled.
This is a fine addition! Thanks. Please see my comments. |
Sure, It is my pleasure 🌹 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code has been modified.
Excellent, thanks! Merging. |
Added write protection pin control to the code.