master/fsm.c
changeset 395 8b1194e51cf2
parent 391 7d67195702dd
child 397 c5d2fb08e43f
equal deleted inserted replaced
394:ff1b018a9b09 395:8b1194e51cf2
  1647 
  1647 
  1648     // check "busy bit"
  1648     // check "busy bit"
  1649     if (EC_READ_U8(datagram->data + 1) & 0x81) {
  1649     if (EC_READ_U8(datagram->data + 1) & 0x81) {
  1650         // still busy... timeout?
  1650         // still busy... timeout?
  1651         if (get_cycles() - fsm->sii_start >= (cycles_t) 10 * cpu_khz) {
  1651         if (get_cycles() - fsm->sii_start >= (cycles_t) 10 * cpu_khz) {
  1652             EC_ERR("SII: Timeout.\n");
  1652             EC_ERR("SII: Read timeout.\n");
  1653             fsm->sii_state = ec_fsm_error;
  1653             fsm->sii_state = ec_fsm_error;
  1654 #if 0
  1654 #if 0
  1655             EC_DBG("SII busy: %02X %02X %02X %02X\n",
  1655             EC_DBG("SII busy: %02X %02X %02X %02X\n",
  1656                    EC_READ_U8(datagram->data + 0),
  1656                    EC_READ_U8(datagram->data + 0),
  1657                    EC_READ_U8(datagram->data + 1),
  1657                    EC_READ_U8(datagram->data + 1),
  1658                    EC_READ_U8(datagram->data + 2),
  1658                    EC_READ_U8(datagram->data + 2),
  1659                    EC_READ_U8(datagram->data + 3));
  1659                    EC_READ_U8(datagram->data + 3));
  1660 #endif
  1660 #endif
       
  1661             return;
  1661         }
  1662         }
  1662 
  1663 
  1663         // issue check/fetch datagram again
  1664         // issue check/fetch datagram again
  1664         if (fsm->sii_mode) {
  1665         if (fsm->sii_mode) {
  1665             ec_datagram_nprd(datagram, fsm->slave->station_address, 0x502, 10);
  1666             ec_datagram_nprd(datagram, fsm->slave->station_address, 0x502, 10);
  1750     if (EC_READ_U8(datagram->data + 1) & 0x82) {
  1751     if (EC_READ_U8(datagram->data + 1) & 0x82) {
  1751         // still busy... timeout?
  1752         // still busy... timeout?
  1752         if (get_cycles() - fsm->sii_start >= (cycles_t) 10 * cpu_khz) {
  1753         if (get_cycles() - fsm->sii_start >= (cycles_t) 10 * cpu_khz) {
  1753             EC_ERR("SII: Write timeout.\n");
  1754             EC_ERR("SII: Write timeout.\n");
  1754             fsm->sii_state = ec_fsm_error;
  1755             fsm->sii_state = ec_fsm_error;
       
  1756             return;
  1755         }
  1757         }
  1756 
  1758 
  1757         // issue check/fetch datagram again
  1759         // issue check/fetch datagram again
  1758         ec_master_queue_datagram(fsm->master, datagram);
  1760         ec_master_queue_datagram(fsm->master, datagram);
  1759     }
  1761         return;
  1760     else if (EC_READ_U8(datagram->data + 1) & 0x40) {
  1762     }
       
  1763 
       
  1764     if (EC_READ_U8(datagram->data + 1) & 0x40) {
  1761         EC_ERR("SII: Write operation failed!\n");
  1765         EC_ERR("SII: Write operation failed!\n");
  1762         fsm->sii_state = ec_fsm_error;
  1766         fsm->sii_state = ec_fsm_error;
  1763     }
  1767         return;
  1764     else { // success
  1768     }
  1765         fsm->sii_state = ec_fsm_end;
  1769 
  1766     }
  1770     // success
       
  1771     fsm->sii_state = ec_fsm_end;
  1767 }
  1772 }
  1768 
  1773 
  1769 /******************************************************************************
  1774 /******************************************************************************
  1770  *  state change state machine
  1775  *  state change state machine
  1771  *****************************************************************************/
  1776  *****************************************************************************/