PN532
Dependents: PN532_GPIO PN532_ReadUid EX_encoder_PID_QianYuyangV4
Fork of LibPN532 by
Revision 2:d8e57d5776b3, committed 2017-12-28
- Comitter:
- zhangyx
- Date:
- Thu Dec 28 03:05:46 2017 +0000
- Parent:
- 1:b5922b3b3257
- Child:
- 3:685e0bf1409d
- Commit message:
- add GPIO P7;
Changed in this revision
PN532/PN532.cpp | Show annotated file Show diff for this revision Revisions of this file |
PN532/PN532.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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
--- a/PN532/PN532.h Tue Sep 13 06:17:35 2016 +0000 +++ b/PN532/PN532.h Thu Dec 28 03:05:46 2017 +0000 @@ -109,6 +109,10 @@ #define PN532_GPIO_P34 (4) #define PN532_GPIO_P35 (5) +#define PN532_GPIO_P70 (0) +#define PN532_GPIO_P71 (1) +#define PN532_GPIO_P72 (2) + class PN532 { public: @@ -119,7 +123,8 @@ // Generic PN532 functions bool SAMConfig(void); uint32_t getFirmwareVersion(void); - bool writeGPIO(uint8_t pinstate); + bool writeGPIOP3(uint8_t pinstate); + bool writeGPIOP7(uint8_t pinstate); uint8_t readGPIO(void); bool setPassiveActivationRetries(uint8_t maxRetries);