Hi everyone,
Here is my problem: I'm trying to implement a new function in the PN532 libraries which would give me the possibility to shut down the PN532 module in order to reduce power consumption and heat production and then waking up from my code.
Here is the power down function in PN532 I wrote :
bool PN532::shutDown(){
pn532_packetbuffer[0] = PN532_COMMAND_POWERDOWN;
pn532_packetbuffer[1] = PN532_SPI_SOUCE; //Autorized wake up source.
DMSG("Shutting down RF module");
if(HAL(writeCommand)(pn532_packetbuffer, 2))
return pn532_packetbuffer[1];
delay(2); //Delay to make sure the module is off.
return (0 < HAL(readResponse)(pn532_packetbuffer, sizeof(pn532_packetbuffer)));
}
This part seems to work (the module is not found and stop to heat).
But now to wake up... even when calling begin() (which call wakeup defined in PN532_SPI, nothing happen and I'm oblige to Hard reset (and plug out & plugin) to recover the board.
I know in SPI mode the NSS line must be LOW as already done in PN532_SPI before sending command in order to wake up:
void PN532_SPI::begin()
{
pinMode(_ss, OUTPUT);
_spi->begin();
_spi->setDataMode(SPI_MODE0); // PN532 only supports mode0
_spi->setBitOrder(LSBFIRST);
#ifndef __SAM3X8E__
_spi->setClockDivider(SPI_CLOCK_DIV8); // set clock 2MHz(max: 5MHz)
#else
/** DUE spi library does not support SPI_CLOCK_DIV8 macro */
_spi->setClockDivider(42); // set clock 2MHz(max: 5MHz)
#endif
}
void PN532_SPI::wakeup()
{
digitalWrite(_ss, LOW);
delay(2);
digitalWrite(_ss, HIGH);
}
Documentation : http://www.nxp.com/documents/user_manual/141520.pdf (from p.98)
Any idea?
Thanks in advance!