Skip to content

Commit

Permalink
Merge pull request ARMmbed#8 from hesee/writeEnable
Browse files Browse the repository at this point in the history
Fix write_enable commands and method.
  • Loading branch information
geky authored May 24, 2018
2 parents 5aa9039 + ba46863 commit b7d2c1a
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions DataFlashBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ enum opcode {

/* non-exhaustive command list */
enum command {
DATAFLASH_COMMAND_WRITE_DISABLE = 0x3D2A7F9A,
DATAFLASH_COMMAND_WRITE_ENABLE = 0x3D2A7FA9,
DATAFLASH_COMMAND_WRITE_DISABLE = 0x3D2A7FA9,
DATAFLASH_COMMAND_WRITE_ENABLE = 0x3D2A7F9A,
DATAFLASH_COMMAND_BINARY_PAGE_SIZE = 0x3D2A80A6,
DATAFLASH_COMMAND_DATAFLASH_PAGE_SIZE = 0x3D2A80A7,
};
Expand Down Expand Up @@ -525,22 +525,20 @@ void DataFlashBlockDevice::_write_enable(bool enable)

/* enable writing, disable write protection */
if (enable) {
/* if not-write-protected pin is connected, select it */
if (_nwp.is_connected()) {
_nwp = 1;
}

/* send 4 byte command enabling writes */
_write_command(DATAFLASH_COMMAND_WRITE_ENABLE, NULL, 0);
} else {

/* if not-write-protected pin is connected, deselect it */
if (_nwp.is_connected()) {
_nwp = 0;
}

} else {

/* if not-write-protected pin is connected, select it */
if (_nwp.is_connected()) {
_nwp = 1;
}

/* send 4 byte command disabling writes */
_write_command(DATAFLASH_COMMAND_WRITE_DISABLE, NULL, 0);
}
Expand Down

0 comments on commit b7d2c1a

Please sign in to comment.