/* Polls the status of the Write In Progress (WIP) flag in the FLASH's status register and loop until write opertaion has completed.  */
void sFLASH_WaitForWriteEnd(void)
/* Polls the status of the Write In Progress (WIP) flag in the FLASH's status register and loop until write opertaion has completed.  */
void sFLASH_WaitForWriteEnd(void)
{
  uint8_t flashstatus = 0;
  sFLASH_CS_LOW();
  sFLASH_SendByte(sFLASH_CMD_RDSR);
  do
  {
    flashstatus = sFLASH_SendByte(sFLASH_DUMMY_BYTE);
  }
  while ((flashstatus & sFLASH_WIP_FLAG) == SET);
  sFLASH_CS_HIGH();
}