/* Fill the given buffer with a pattern based on the sector number.  */
void fill_data_buffer(uint8_t *buffer, uint32_t sectorNumber, void *p)
/* Fill the given buffer with a pattern based on the sector number.  */
void fill_data_buffer(uint8_t *buffer, uint32_t sectorNumber, void *p)
{
    uint32_t i;
    for (i=0; i < SIZE_IN_WORDS(g_actualBufferBytes); ++i)
    {
        buffer[i] = (sectorNumber ^ ((~sectorNumber) << 8) ^ (sectorNumber << 16) ^ ((~sectorNumber) << 24)) ^ (uint32_t)p ^ 0x96f187e2 ^ i ^ (i << 8) ^ (i << 16) ^ (i << 24);
    }
}