+
+void iso14a_set_ATS_timeout(uint8_t *ats) {
+
+ uint8_t tb1;
+ uint8_t fwi;
+ uint32_t fwt;
+
+ if (ats[0] > 1) { // there is a format byte T0
+ if ((ats[1] & 0x20) == 0x20) { // there is an interface byte TB(1)
+ if ((ats[1] & 0x10) == 0x10) { // there is an interface byte TA(1) preceding TB(1)
+ tb1 = ats[3];
+ } else {
+ tb1 = ats[2];
+ }
+ fwi = (tb1 & 0xf0) >> 4; // frame waiting indicator (FWI)
+ fwt = 256 * 16 * (1 << fwi); // frame waiting time (FWT) in 1/fc
+
+ iso14a_set_timeout(fwt/(8*16));
+ }
+ }
+}
+
+