Hi Jing !
I have review one more time our requirement and find out that we can write data by 32 bytes aligned chunks only.
So what ever we write it always 32*n byte long and it help to cross page boundary.
For fullfll this requirement I follow your example and common sense and modify LUT table and create write 32 byte routine.
Could you look code below. How it is looks like ?
/* Seq4: Data Program */
/* CMD: 0x02 - Page Program, Single pad */
/* ADDR: 0x18 - 24bit address, Single pad */
[16] = QSPI_LUT_SEQ(QSPI_CMD, QSPI_PAD_1, 0x02, QSPI_ADDR, QSPI_PAD_1, 0x18),
[17] = QSPI_LUT_SEQ(QSPI_WRITE, QSPI_PAD_1, 32, 0, 0, 0), // 32 bytes only
/* Program 32byte into serial flash using QSPI polling way */
void program_data_32(uint32_t dest_addr, uint32_t *src_addr, size_t size) // size = 32 bytes always
{
assert(!(dest_addr % 32));
assert(!(size % 32));
while (QSPI_GetStatusFlags(EXAMPLE_QSPI) & kQSPI_Busy)
{
}
QSPI_ClearFifo(EXAMPLE_QSPI, kQSPI_TxFifo);
QSPI_SetIPCommandAddress(EXAMPLE_QSPI, dest_addr);
cmd_write_enable();
while (QSPI_GetStatusFlags(EXAMPLE_QSPI) & kQSPI_Busy)
{
}
/* Put data to fifo */
QSPI_WriteBlocking(EXAMPLE_QSPI, src_addr, size); // 32
/* Start the program */
QSPI_SetIPCommandSize(EXAMPLE_QSPI, size);
QSPI_ExecuteIPCommand(EXAMPLE_QSPI, 16U);
/* Wait until flash finished program */
check_if_finished();
while (QSPI_GetStatusFlags(EXAMPLE_QSPI) & (kQSPI_Busy | kQSPI_IPAccess))
{
}
}
Thank you !
Regards,
Eugene