Sorry for the late reply.
Just to resume, I have one Arduino Mega2560 which is linked to a smart card connector. This smart card connector just redirects the contacts of a smart cart to 8 pins. In my case I'm focusing on the IO part. The way to communicate with a smart card is defined in the ISO 7816-3 http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-3.aspx
. Typically, the Arduino provided an external clock to the smart card to indicate the speed to use to transmit the data. Another wire is used for IO. So far I have one driver on Arduino which handle the communication but it's all in software, meaning managing the external clock + exchanging the bits are done in software, which brings some limitation, I cannot go faster than with a clock at 1MHz.
My idea is to handle my IO in hardware. I know some chip provides an UART hardware ISO 7816-3 compliant but I prefer to try first to solve this without adding any hardware part. My first idea is to reuse one of the hardware USART and trick it to be able to use it with a smartcard. But one problem is the speed, for USART it's related at one point at the internal clock. At first, I don't know why, I was block by SPI, but it seems a better solution and at least a more evident one regarding your comments. One think, it's dumb but i rather to be sure, in my environment the ground used by SPI should be link to the ground of the smartcard right?
To answer your previous comments, having my own library isn't a problem. I'm doing my project without the Arduino library, like this i have more registers / options to play with. First I was asking how to compute the baud rate because I wanted to trick my Arduino and send data like if my internal clock was at 1MHz. For Riva: The ISO 7816-3 specifies (at least at begining) that every bit duration is 372 clock pulses for a clock at 1MHz, meaning the OP needs the data bit to hold then change only every 372 clock pulses.
I think If I want to use SPI I'll need some pull up resistors as well in order to have a SPI over a single IO wire + clock + ground. What do you think ?
Thanks for your help.