Skip to content

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

Merged
merged 3 commits into from
Mar 4, 2024
Merged

Add WP control #30

merged 3 commits into from
Mar 4, 2024

Conversation

giminotron5
Copy link
Contributor

Added write protection pin control to the code.

@@ -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)
Copy link
Member

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

@@ -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);
Copy link
Member

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...

@@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove whitespace.

@@ -111,6 +111,8 @@ struct struct_memorySettings
uint8_t writeTime_ms;
bool pollForWriteComplete;
uint8_t addressSize_bytes;
bool usingWP;
Copy link
Member

@nseidle nseidle Nov 14, 2023

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(...

Copy link
Member

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.

@nseidle
Copy link
Member

nseidle commented Nov 14, 2023

This is a fine addition! Thanks. Please see my comments.

@giminotron5
Copy link
Contributor Author

Sure, It is my pleasure 🌹

@giminotron5 giminotron5 requested a review from nseidle March 2, 2024 11:07
Copy link
Contributor Author

@giminotron5 giminotron5 left a 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.

@nseidle
Copy link
Member

nseidle commented Mar 4, 2024

Excellent, thanks! Merging.

@nseidle nseidle merged commit 6c4e26d into sparkfun:main Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants