nfc.c:1244:19: warning: Dereference of undefined pointer value
for (int i = 0; nmt[i]; i++) {
^~~~~~
nfc.c:1256:23: warning: Dereference of undefined pointer value
for (int j = 0; nbr[j]; j++) {
^~~~~~
pn53x.c:1746:15: warning: Function call argument is an uninitialized value
*cycles = __pn53x_get_timer(pnd, pbtTxRaw[szTx + 1]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The datasheet is wrong for the pn532_i2c. After having constant issues
with the device failing to respond on the bus and after contacting NXP
about this, it turns out 1.3 ms is too tight. The official timing spec
is unknown for now, but we tested 4 and 5 ms without problems. Thus we
have choosen 5 ms as a safe delay.
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Currently, we very occasionally can EXNIO errors from pn532_i2c_write() ->
i2c_write() -> write(). This may happen about once every 30 seconds.
Based from the kernel sources, EXNIO happens if the chip no longer
responds to its own address.
To make sure we do not loose any sent packets, we retry to send
PN532_SEND_RETRIES number of times. Since we miss 1 every 30 or so
seconds, doing 1 retry should be fine.
This might be considered a hack as the failure may be some other timing
related issue.
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
The pn532 user manual states that after a i2c stop condition and before a i2c
start condition there should be a delay of minimally 1.3 milliseconds.
This is probably a limitation of the i2c peripheral or the firmware. In
any case, each i2c_read and i2c_write creates the packets which are
complemented with start/stop markers. It is thus required to take care
of timing in these two functions.
We solve this by wrapping the lower i2c_read and i2c_write functions for
the pn532, as this requirement is not for all chips.
Currently, we keep time using local variable, and thus the code is not
thread-safe. With libnfc being single threaded and only one instances of
libnfc can open a bus anyway, this is not yet a problem.
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>