コード例 #1
0
ファイル: mtd25.cpp プロジェクト: char32/24aa
msg_t Mtd25::wait_op_complete(systime_t timeout) {

  systime_t start = chVTGetSystemTimeX();
  systime_t end = start + timeout;

  osalThreadSleepMilliseconds(2);

  while (chVTIsSystemTimeWithinX(start, end)) {
    uint8_t tmp;

#if SPI_USE_MUTUAL_EXCLUSION
    spiAcquireBus(this->spip);
#endif

    spiSelect(spip);
    spiPolledExchange(spip, S25_CMD_RDSR1);
    tmp = spiPolledExchange(spip, 0);
    spiUnselect(spip);

#if SPI_USE_MUTUAL_EXCLUSION
    spiReleaseBus(this->spip);
#endif

    if (tmp & S25_SR1_WIP) {
      continue;
    }
    else {
      if (tmp & (S25_SR1_PERR | S25_SR1_EERR))
        return MSG_RESET;
      else
        return MSG_OK;
    }

    osalThreadSleepMilliseconds(10);
  }

  /* time is out */
  return MSG_RESET;
}
コード例 #2
0
ファイル: ch.cpp プロジェクト: hmchen1/ChibiOS
  bool System::isTimeWithin(systime_t start, systime_t end) {

    return chVTIsSystemTimeWithinX(start, end);
  }