This was an example of a compiler warning when the switch -Waddress was passed:
atmel_softpack_libraries/usb/device/core/USBD.c: In function 'USBD_RequestHandler':
atmel_softpack_libraries/usb/device/core/USBD.c:149:14: warning: the address of
'USBDCallbacks_RequestReceived' will always evaluate as 'true' [-Waddress]
else if (USBDCallbacks_RequestReceived) {
The test for existense of USBDCallbacks_RequestReceived is removed since there
is always a default implementation of these function.
When the SIM card adapter, which is usually plugged into a phone,
is plugged into a CCID reader instead, the CCID reader triggers
the reset line of the RST line and therefore a PIO interrupt.
The reader then waits for an ATR from the smartcard,
which should be send next.
The return value of ISO7816_GetChar is 0 in case of a timeout
when trying to retrieve values, and status of US_CSR otherwise.
Proper handling of this return value is not yet implemented though.
With the naive approach of just not sending the ATR if it could not
be read the simtrace firmware did not work together with pcsc_scan
AT ALL.
Before this change pcsc_scan would always receive garbage
from the stack when the reset button was pressed on the
simtrace board. Because the return value of ISO7816_GetChar
is never checked anywhere. If there is a timeout in this function,
the non-initialized local variable values which happen to be
lying around on the stack are inserted into the ATR message
and send to the host.
This only helps mitigating the symptoms but does not remove
the reason for the behavior. On the other hand, is it really
feasable to check the return value on EVERY call to
ISO7816_GetChar..?
Currently the smartcard insertion interrupt is always triggered,
but when checking in PIO_ISR which pin triggered the interrupt
often times DTXD is returned (the debug transmit line which is printing
debug messages at the moment..)
I originally took the library files from https://github.com/zwizwa/simtrace
for cciddriver, etc.
Then I notices some things changed and between the AT91Lib for SAM7
and SAM3S I am using. Therefore I took the original files from the AT91Lib
which I downloaded for the SAM3S. Most lines only differ in comment convention.