Skip to content

Commit

Permalink
Fix #293: don't clobber user's write buffer in catena_Mx25v8035f::pro…
Browse files Browse the repository at this point in the history
…gramPage()
  • Loading branch information
terrillmoore committed Apr 10, 2021
1 parent a68787b commit 87ad3ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Catena_Mx25v8035f.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ class Catena_Mx25v8035f
void read(uint32_t Address, uint8_t *pBuffer, size_t nBuffer);

// program a buffer
void program(uint32_t Address, uint8_t *pBuffer, size_t nBuffer);
size_t programPage(uint32_t Address, uint8_t *pBuffer, size_t nBuffer);
void program(uint32_t Address, const uint8_t *pBuffer, size_t nBuffer);
size_t programPage(uint32_t Address, const uint8_t *pBuffer, size_t nBuffer);

// power management
void powerDown(void);
Expand Down
11 changes: 6 additions & 5 deletions src/lib/stm32/Catena_Mx25v8035f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,13 @@ Name: Catena_Mx25v8035f::programPage

size_t Catena_Mx25v8035f::programPage(
uint32_t Address,
uint8_t *pBuffer,
const uint8_t *pBuffer,
size_t nBuffer
)
{
SPIClass * const pSpi = this->m_pSpi;
uint8_t status[2];
uint8_t data[4];
uint8_t data[MX25V8035F_PAGE_SIZE];
size_t programSize;

data[0] = MX25V8035F_CMD_PP;
Expand All @@ -628,7 +628,8 @@ size_t Catena_Mx25v8035f::programPage(
this->setWel();

pSpi->transfer(this->m_CS, data, sizeof(data), SPI_CONTINUE);
pSpi->transfer(this->m_CS, pBuffer, programSize, SPI_LAST);
memcpy(data, pBuffer, programSize);
pSpi->transfer(this->m_CS, data, programSize, SPI_LAST);

this->pollWip(1 /* ms */);

Expand All @@ -645,7 +646,7 @@ Name: Catena_Mx25v8035f::program
Definition:
void Catena_Mx25v8035f::program(
uint32_t Address,
uint8_t *pBuffer,
const uint8_t *pBuffer,
size_t nBuffer
);
Expand All @@ -659,7 +660,7 @@ Name: Catena_Mx25v8035f::program

void Catena_Mx25v8035f::program(
uint32_t Address,
uint8_t *pBuffer,
const uint8_t *pBuffer,
size_t nBuffer
)
{
Expand Down

0 comments on commit 87ad3ec

Please sign in to comment.