Example #1
0
/*
 * Wait for a write/erase operation to finish.
 */
static unsigned
wait_ready(void)
{
  unsigned u;
  do {
    u = read_status_register();
  } while(u & 0x01);		/* WIP=1, write in progress */
  return u;
}
Example #2
0
int wait_not_busy()
{
	uint32_t status;
	DEBUG(fprintf(stderr, "Wait not busy\n"));
	if (dev_fd == -1)
		return 1; // Debug mode
	usleep(1000);
	while (read_busy_status())
		usleep(1000);
	while (status = read_status_register())
	{
		if (READ_STATUS_FAIL(status))
			return status;
		if (!READ_STATUS_BUSY(status))
			break;
	}
	return 1;
}