PN532

Dependents:   PN532_GPIO PN532_ReadUid EX_encoder_PID_QianYuyangV4

Fork of LibPN532 by dotnfc Tang

Revision:
2:d8e57d5776b3
Parent:
0:db8030e71f55
--- a/PN532/PN532.cpp	Tue Sep 13 06:17:35 2016 +0000
+++ b/PN532/PN532.cpp	Thu Dec 28 03:05:46 2017 +0000
@@ -162,7 +162,7 @@
     @returns 1 if everything executed properly, 0 for an error
 */
 /**************************************************************************/
-bool PN532::writeGPIO(uint8_t pinstate)
+bool PN532::writeGPIOP3(uint8_t pinstate)
 {
     // Make sure pinstate does not try to toggle P32 or P34
     pinstate |= (1 << PN532_GPIO_P32) | (1 << PN532_GPIO_P34);
@@ -183,6 +183,26 @@
     return (0 < HAL(readResponse)(pn532_packetbuffer, sizeof(pn532_packetbuffer)));
 }
 
+bool PN532::writeGPIOP7(uint8_t pinstate)
+{
+    pinstate &= (1 << PN532_GPIO_P70) | (1 << PN532_GPIO_P71) | (1 << PN532_GPIO_P72);
+
+    // Fill command buffer
+    pn532_packetbuffer[0] = PN532_COMMAND_WRITEGPIO;
+    pn532_packetbuffer[1] = 0x00;  // P3 Pins are not changed
+    pn532_packetbuffer[2] = PN532_GPIO_VALIDATIONBIT | pinstate;  // P7 Pins
+
+    DMSG("Writing P7 GPIO: ");
+    DMSG_HEX(pn532_packetbuffer[1]);
+    DMSG("\n");
+
+    // Send the WRITEGPIO command (0x0E)
+    if (HAL(writeCommand)(pn532_packetbuffer, 3))
+        return 0;
+
+    return (0 < HAL(readResponse)(pn532_packetbuffer, sizeof(pn532_packetbuffer)));
+}
+
 /**************************************************************************/
 /*!
     Reads the state of the PN532's GPIO pins