Skip to content

Commit

Permalink
Use more atomic operation to write flash memory
Browse files Browse the repository at this point in the history
  • Loading branch information
ShinHub committed Sep 15, 2019
1 parent 998d3c0 commit 810e493
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
6 changes: 1 addition & 5 deletions Firmware/ChameleonMini/Memory/SPIFlash.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,9 @@ bool FlashBufferedBytesWrite(const void* Buffer, uint32_t Address, uint32_t Byte
OPStop();
WaitForReadyFlash();
OPStart();
sendAddrOp(FLASH_OP_BUF1_WRITE, Offset);
sendAddrOp(FLASH_OP_BUF1_WRITE_PAGE, (PageNum | Offset));
SPIWriteBlock(Buffer+Head, ByteRoll);
OPStop();
WaitForReadyFlash();
OPStart();
sendAddrOp(FLASH_OP_BUF1_TO_PAGE, PageNum);
OPStop();
ByteCount -= ByteRoll;
Address += ByteRoll;
Head += ByteRoll;
Expand Down
7 changes: 1 addition & 6 deletions Firmware/ChameleonMini/Memory/SPIFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@

#define FLASH_OP_READ 0x0B // Random access continuous read (max freq)
#define FLASH_OP_PAGE_TO_BUF1 0x53 // Load a page to buffer 1
#define FLASH_OP_BUF1_WRITE 0x84 // Write into buffer 1
#define FLASH_OP_BUF1_TO_PAGE 0x83 // Dump buffer 1 into page
#define FLASH_OP_BUF1_WRITE_PAGE 0x82 // Main Memory Page Program Through Buffer
#define FLASH_OP_RWM_WITH_BUF1 0x58 // Read-Modify-Write through buffer 1
// Note thats tests with Read-Modify-Write atomic
// operations (58 and 59) failed.
#define FLASH_OP_GET_STATUS 0xD7 // Read status
#define FLASH_OP_SECTOR_ERASE 0x7C // Erase a sector
#define FLASH_OP_BLOCK_ERASE 0x50 // Erase a block
Expand All @@ -86,7 +81,7 @@
#define FLASH_BSIZE 8 // Bits

#define FLASH_SEQ_PAGE_SIZE_BINARY 0x3D, 0x2A, 0x80, 0xA6 // Binary page size (256 bytes)
#define FLASH_SEQ_CHIP_ERASE 0xC7, 0x94, 0x80, 0x9A // erase entire chip
#define FLASH_SEQ_CHIP_ERASE 0xC7, 0x94, 0x80, 0x9A // Erase entire chip

#define FLASH_SECTOR_ADDR_0A 0x00
#define FLASH_SECTOR_ADDR_0B 0x01
Expand Down

0 comments on commit 810e493

Please sign in to comment.