Spi Software Implementation - Elatec TWN3 Mini Reader Mifare NFC Technical Manual

Transponder reader
Table of Contents

Advertisement

2.5.2 SPI Software Implementation

The following code demonstrates how to implement SPI communication in software for the host
system, e.g. for a microcontroller:
byte SPI_ReadWrite(byte
{
byte
i;
for
(i=0; i<8; i++)
{
if
(Data & 0x80)
else
SCK_HIGH;
Data <<= 1;
if
(READ_MISO)
SCK_LOW;
}
return
Data;
}
int
main(void)
{
byte
k;
byte
q;
byte
LengthByteRead;
byte
LengthByteWrite;
// ...
while(1)
{
LengthByteWrite = GetNumBytesInSendBuffer();
SS_LOW;
LengthByteRead = SPI_ReadWrite(LengthByteWrite);
while
{
}
SS_HIGH;
}
// ...
}
Data)
MOSI_HIGH;
MOSI_LOW;
Data |= 0x01;
((LengthByteRead > 0) || (LengthByteWrite > 0))
if
(LengthByteWrite > 0)
{
q = GetByteFromSendBuffer();
LengthByteWrite--;
}
else
q = 0x00;
k = SPI_ReadWrite(q);
if
(LengthByteRead > 0)
{
LengthByteRead--;
PushByteToReceiveBuffer(k);
}
else
LengthByteRead = k;
Elatec GmbH
Page 11 of 61

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the TWN3 Mini Reader Mifare NFC and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Twn3 reader mifare nfc

Table of Contents