工具与软件:
大家好、我想与 mfrc522通信。 我在 SPI 方面有问题。 自行控制 CS 引脚。 我连接了 GPIO。 我把我的连接留在下面。 您能检查我的软件是否有问题吗?
unsigned char MFRC522_SPIreceive (unsigned char address_rcv)
{
SPI_RECEIVE_ADDRESS =(((address_rcv << 1)& 0x7E)| 0x80);// Okuma işlemi için adres
MFRC_NSS_OFF;
DL_SPI_setControllerCommandDataModeConfig (SPI_0_INST、1);// 1 Bayt komut gönderilecek
DL_SPI_transmitData8 (SPI_0_INST、SPI_RECEIVE_ADDRESS);
while (DL_SPI_isBusy (SPI_0_INST))
;
DL_SPI_setControllerCommandDataModeConfig (SPI_0_INST、1);// 1 Bayt komut gönderilecek
DL_SPI_transmitData8 (SPI_0_INST、dummy);
while (DL_SPI_isBusy (SPI_0_INST))
;
SPI_RECEIVED_DATA = DL_SPI_receiveData8 (SPI_0_INST);
MFRC_NSS_ON;
返回 SPI_RECEIVED_DATA;
}
void MFRC522_SPIsend (unsigned char address_snd、unsigned char data_snd)
{
SPI_SEND_ADDRESS =((ADDRESS_SND << 1)且0x7E);// Yazma işlemi için adres
SPI_SEND_DATA = DATA_snd;
MFRC_NSS_OFF;
DL_SPI_setControllerCommandDataModeConfig (SPI_0_INST、1);// 1 Bayt komut gönderilecek
DL_SPI_transmitData8 (SPI_0_INST、SPI_SEND_ADDRESS);
while (DL_SPI_isBusy (SPI_0_INST))
;
DL_SPI_setControllerCommandDataModeConfig (SPI_0_INST、1);// 1 Bayt komut gönderilecek
DL_SPI_transmitData8 (SPI_0_INST、SPI_SEND_DATA);
while (DL_SPI_isBusy (SPI_0_INST))
;
MFRC_NSS_ON;
}