Hi!
Let me try to give some background on this:
1.) SPI is known to perform full-duplex transfers, i.e. while sending data, also reception of data happens. PN5180, however, uses SPI in half-duplex mode.
2.) Because PN5180 uses half-duplex mode communication only, at logical communication layer there are two types of instructions: SET instructions (for instance WriteRegister) and GET instructions (for instance ReadRegister)
In order to execute a SET instruction one needs to setup *one* SPI transfer, with Tx buffer containing the SET instruction. At the end of the transfer, data received in the Rx Buffer can be ignored, i.e. contains only dummy data)
In order to execute a GET instruction one needs to setup *two* SPI transfers. The first SPI transfer contains the GET instruction within the Tx buffer. After this first transfer the data received in the RxBuffer can be ignored. Then, the second SPI is used to retrieve the actual response to the GET instruction. For this, one needs to fill the TxBuffer with dummy data. Dummy means, it can be any data. The length of the TxBuffer (=length of the SPI transfer) is equal to the expected length of the GET response. At the end of the second transfer, the RxBuffer then contains the GET instruction response.
So what about the BUSY? BUSY is used on PN5180 as flow control line. A host controller can only start new SPI transfer after PN5180 has finished processing the previous transfer. This is indicated by BUSY signal. So you need to check for BUSY low condition *every* time before your host controller starts a new SPI transfer. The sequence for checking for BUSY low condition has been described by Isaac in his post.
Let me also give an example. Let's assume you want to read out Register 0x0 (SYSTEM_CONFIG) using READ_REGISTER. Since it is a GET instruction it requires two SPI transfers. First SPI transfer contains the instruction within TxBuffer, which is composed of command/instruction code (1Byte) and the address of the Register to be read (1Byte) (See Table 10 in [1]). The second SPI transfer is used to retrieve the response of the GET instruction and has a length of 4 bytes (in fact, the content of the read out register). See also Table 10 in [1]
1. Make sure BUSY is low
2. Assert NSS
3. Perform SPI exchange with length of 2 bytes, with the following TxBuffer content { 0x04, 0x00 }
4. Wait for BUSY high condition
5. De-Assert NSS
6. Wait for BUSY low condition
( RxBuffer of the finished SPI exchange contains two dummy bytes, you can ignore)
7. Make sure BUSY is low
8. Assert NSS
9. Perform SPI exchange with a length of 4 bytes, with the any TxBuffer content { 0xxx, 0xxx, 0xxx, 0xxx }
10. Wait for BUSY high condition
11. De-Assert NSS
12. Wait for BUSY low condition
RxBuffer now contains the 4 byte response, in fact the value of SYSTEM_CONFIG Register
Hope that helps,
Christian.
[1] http://www.nxp.com/documents/data_sheet/PN5180.pdf Rev 3.0