Add power control functions (#334)
* Update MFRC522.h Add new power control functions : PCD_SoftPowerDown PCD_SoftPowerUp
This commit is contained in:
@@ -43,6 +43,10 @@ PCD_GetAntennaGain KEYWORD2
|
|||||||
PCD_SetAntennaGain KEYWORD2
|
PCD_SetAntennaGain KEYWORD2
|
||||||
PCD_PerformSelfTest KEYWORD2
|
PCD_PerformSelfTest KEYWORD2
|
||||||
|
|
||||||
|
# Power control functions MFRC522
|
||||||
|
PCD_SoftPowerDown KEYWORD2
|
||||||
|
PCD_SoftPowerUp KEYWORD2
|
||||||
|
|
||||||
# Functions for communicating with PICCs
|
# Functions for communicating with PICCs
|
||||||
PCD_TransceiveData KEYWORD2
|
PCD_TransceiveData KEYWORD2
|
||||||
PCD_CommunicateWithPICC KEYWORD2
|
PCD_CommunicateWithPICC KEYWORD2
|
||||||
@@ -216,4 +220,4 @@ FIFO_SIZE LITERAL1
|
|||||||
BITRATE_106KBITS LITERAL1
|
BITRATE_106KBITS LITERAL1
|
||||||
BITRATE_212KBITS LITERAL1
|
BITRATE_212KBITS LITERAL1
|
||||||
BITRATE_424KBITS LITERAL1
|
BITRATE_424KBITS LITERAL1
|
||||||
BITRATE_848KBITS LITERAL1
|
BITRATE_848KBITS LITERAL1
|
||||||
|
|||||||
@@ -363,6 +363,35 @@ bool MFRC522::PCD_PerformSelfTest() {
|
|||||||
return true;
|
return true;
|
||||||
} // End PCD_PerformSelfTest()
|
} // End PCD_PerformSelfTest()
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Power control
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//IMPORTANT NOTE!!!!
|
||||||
|
//Calling any other function that uses CommandReg will disable soft power down mode !!!
|
||||||
|
//For more details about power control, refer to the datasheet - page 33 (8.6)
|
||||||
|
|
||||||
|
void MFRC522::PCD_SoftPowerDown(){//Note : Only soft power down mode is available throught software
|
||||||
|
byte val = PCD_ReadRegister(CommandReg); // Read state of the command register
|
||||||
|
val |= (1<<4);// set PowerDown bit ( bit 4 ) to 1
|
||||||
|
PCD_WriteRegister(CommandReg, val);//write new value to the command register
|
||||||
|
}
|
||||||
|
|
||||||
|
void MFRC522::PCD_SoftPowerUp(){
|
||||||
|
byte val = PCD_ReadRegister(CommandReg); // Read state of the command register
|
||||||
|
val &= ~(1<<4);// set PowerDown bit ( bit 4 ) to 0
|
||||||
|
PCD_WriteRegister(CommandReg, val);//write new value to the command register
|
||||||
|
// wait until PowerDown bit is cleared (this indicates end of wake up procedure)
|
||||||
|
const uint32_t timeout = (uint32_t)millis() + 500;// create timer for timeout (just in case)
|
||||||
|
|
||||||
|
while(millis()<=timeout){ // set timeout to 500 ms
|
||||||
|
val = PCD_ReadRegister(CommandReg);// Read state of the command register
|
||||||
|
if(!(val & (1<<4))){ // if powerdown bit is 0
|
||||||
|
break;// wake up procedure is finished
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Functions for communicating with PICCs
|
// Functions for communicating with PICCs
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -359,6 +359,12 @@ public:
|
|||||||
void PCD_SetAntennaGain(byte mask);
|
void PCD_SetAntennaGain(byte mask);
|
||||||
bool PCD_PerformSelfTest();
|
bool PCD_PerformSelfTest();
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Power control functions
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void PCD_SoftPowerDown();
|
||||||
|
void PCD_SoftPowerUp();
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Functions for communicating with PICCs
|
// Functions for communicating with PICCs
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
Reference in New Issue
Block a user