diff options
author | Sherry Smith <sherrys@broadcom.com> | 2014-06-02 11:01:54 -0700 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2014-06-26 09:26:27 -0700 |
commit | 67fe610c4b6462d96e252fa2c68d67ce63787fcb (patch) | |
tree | 95b07cb0b00201b361a0de016680188ed4749f07 | |
parent | 818b56eda129e0370afe6bcb808b0ed55c898d13 (diff) | |
download | libnfc-nci-67fe610c4b6462d96e252fa2c68d67ce63787fcb.tar.gz |
Add padding for type-3 tag's timeout calculation to avoid premature timeout.
Change-Id: I5781bfff3b532ac615ae05e54c804708d04a491c
-rw-r--r-- | src/nfc/tags/rw_t3t.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/nfc/tags/rw_t3t.c b/src/nfc/tags/rw_t3t.c index b24eefa..7db0fac 100644 --- a/src/nfc/tags/rw_t3t.c +++ b/src/nfc/tags/rw_t3t.c @@ -49,7 +49,7 @@ #define RW_T3T_POLL_CMD_TIMEOUT_TICKS ((RW_T3T_TOUT_RESP*2*QUICK_TIMER_TICKS_PER_SEC) / 1000) #define RW_T3T_DEFAULT_CMD_TIMEOUT_TICKS ((RW_T3T_TOUT_RESP*QUICK_TIMER_TICKS_PER_SEC) / 1000) #define RW_T3T_RAW_FRAME_CMD_TIMEOUT_TICKS (RW_T3T_DEFAULT_CMD_TIMEOUT_TICKS * 4) -#define RW_T3T_MIN_TIMEOUT_TICKS 3 +#define RW_T3T_MIN_TIMEOUT_TICKS 10 /* Macro to extract major version from NDEF version byte */ #define T3T_GET_MAJOR_VERSION(ver) (ver>>4) @@ -184,9 +184,13 @@ static UINT32 rw_t3t_check_timeout (UINT16 num_blocks) { tRW_T3T_CB *p_cb = &rw_cb.tcb.t3t; UINT32 timeout; + UINT32 extra; + timeout = (p_cb->check_tout_a + num_blocks * p_cb->check_tout_b)*QUICK_TIMER_TICKS_PER_SEC/1000000; - if (timeout < RW_T3T_MIN_TIMEOUT_TICKS) - timeout = RW_T3T_MIN_TIMEOUT_TICKS; + /* allow some extra time for driver */ + extra = (timeout / 10) + RW_T3T_MIN_TIMEOUT_TICKS; + timeout += extra; + return timeout; } @@ -203,9 +207,13 @@ static UINT32 rw_t3t_update_timeout (UINT16 num_blocks) { tRW_T3T_CB *p_cb = &rw_cb.tcb.t3t; UINT32 timeout; + UINT32 extra; + timeout = (p_cb->update_tout_a + num_blocks * p_cb->update_tout_b)*QUICK_TIMER_TICKS_PER_SEC/1000000; - if (timeout < RW_T3T_MIN_TIMEOUT_TICKS) - timeout = RW_T3T_MIN_TIMEOUT_TICKS; + /* allow some extra time for driver */ + extra = (timeout / 10) + RW_T3T_MIN_TIMEOUT_TICKS; + timeout += extra; + return timeout; } /******************************************************************************* |