master/fsm_sii.c
changeset 1586 eb9185dfa8ac
parent 1583 017fa8fd9ac1
child 1599 fe338fe37923
equal deleted inserted replaced
1581:e51cf2af3ff9 1586:eb9185dfa8ac
   246 
   246 
   247 /**
   247 /**
   248    SII state: READ FETCH.
   248    SII state: READ FETCH.
   249    Fetches the result of an SII-read datagram.
   249    Fetches the result of an SII-read datagram.
   250 */
   250 */
   251 
       
   252 void ec_fsm_sii_state_read_fetch(
   251 void ec_fsm_sii_state_read_fetch(
   253         ec_fsm_sii_t *fsm /**< finite state machine */
   252         ec_fsm_sii_t *fsm /**< finite state machine */
   254         )
   253         )
   255 {
   254 {
   256     ec_datagram_t *datagram = fsm->datagram;
   255     ec_datagram_t *datagram = fsm->datagram;
   300                 return;
   299                 return;
   301             }
   300             }
   302         }
   301         }
   303 
   302 
   304         // issue check/fetch datagram again
   303         // issue check/fetch datagram again
       
   304         fsm->datagram->state = EC_DATAGRAM_INIT;
   305         fsm->retries = EC_FSM_RETRIES;
   305         fsm->retries = EC_FSM_RETRIES;
   306         return;
   306         return;
   307     }
   307     }
   308 
   308 
   309     // SII value received.
   309     // SII value received.
   433 #ifdef SII_DEBUG
   433 #ifdef SII_DEBUG
   434         EC_DBG("too early.\n");
   434         EC_DBG("too early.\n");
   435 #endif
   435 #endif
   436         // issue check datagram again
   436         // issue check datagram again
   437         fsm->retries = EC_FSM_RETRIES;
   437         fsm->retries = EC_FSM_RETRIES;
       
   438         fsm->datagram->state = EC_DATAGRAM_INIT;
   438         return;
   439         return;
   439     }
   440     }
   440 
   441 
   441     if (EC_READ_U8(datagram->data + 1) & 0x82) { /* busy bit or
   442     if (EC_READ_U8(datagram->data + 1) & 0x82) { /* busy bit or
   442                                                     write operation busy bit */
   443                                                     write operation busy bit */
   451             }
   452             }
   452         }
   453         }
   453 
   454 
   454         // issue check datagram again
   455         // issue check datagram again
   455         fsm->retries = EC_FSM_RETRIES;
   456         fsm->retries = EC_FSM_RETRIES;
       
   457         fsm->datagram->state = EC_DATAGRAM_INIT;
   456         return;
   458         return;
   457     }
   459     }
   458 
   460 
   459     if (EC_READ_U8(datagram->data + 1) & 0x40) {
   461     if (EC_READ_U8(datagram->data + 1) & 0x40) {
   460         EC_ERR("SII: Write operation failed!\n");
   462         EC_ERR("SII: Write operation failed!\n");