In the standard atmel lib only one configuration was possible.
On a GETDESCRIPTOR request the board would always return the full buffer
with both configurations.
The USB driver requests each configuration one after another, using the
configuration index number.
The atmel lib did not support more than one USB configuration.
But only when you program the chip. At some point it stops printing
the received bytes because the interrupt is not triggered anymore.
I do not know yet how and why this happens.
Even after restarting the board this state is maintained.
CLK_SIM, I/O_SIM, CLK_PHONE, I/O_PHONE: Each of these lines connect
two pins of the microcontroller. Therefore they should NEVER be
configured as output line simultaneously. Otherwise the uC might get
destroyed.
Serial smartcard reader sends data which should be processed.
In the USART1 IRQ a status variable is set to show that data has
arrived, which should be checked for in the main function.
The second argument for PIO_Configure is the list size,
which can be determined using the macro PIO_LISTSIZE.
You should pass the list (which is an array of pins) to it.
Refrain from passing the ADDRESS of the list to it, otherwise
the pin configuration is never applied and you find yourself
debugging for 3 days.
In other words:
It's working, don't touch it or it will break again!
For now the inttypes.h of the development computer is used.
Which is a bad state. The reason is
It should be fixed by creating a stdint.h in the Baselib, which
defines types like uint32_t, etc., or by entirely replacing the Baselibs
with the newlib.
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.
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..)