LieBtrau / arduino-ntag

Arduino library to interface with the NXP NTAG (NT3H1101 and NT3H1201)
GNU General Public License v2.0
29 stars 7 forks source link

Any chance of making setFd_ReaderHandshake function configurable #14

Closed Gerriko closed 1 year ago

Gerriko commented 5 years ago

I see in the following function you have provided comments on different behaviours for the FD pin.

bool Ntag::setFd_ReaderHandshake(){ //return writeRegister(NC_REG, 0x3C,0x18); return writeRegister(NC_REG, 0x3C,0x28); //0x28: FD_OFF=10b, FD_ON=10b : FD constant low //Start of read by reader always clears the FD-pin. //At the end of the read by reader, the FD-pin becomes high (most of the times) //0x18: FD pulse high (13.9ms wide) at the beginning of the read sequence, no effect on write sequence. //0x14: FD_OFF=01b, FD_ON=01b : FD constant high //0x24: FD constant high }

Any chance of creating a public typedef enum, as follows (or something like this - wasn't sure how 0x24 behaved) to allow user to choose:

typedef enum { FD_CONSTLO = 0x28, FD_PULSEHI = 0x18, FD_CONSTHI = 0x14, FD_HI = 0x24 } FDPIN_MODE;

Then define function as bool Ntag::setFd_ReaderHandshake(FDPIN_MODE fdpinMode){...}

THEN... I also noticed that in Ntag constructor you set FD pinmode to INPUT -- pinMode(_fd_pin, INPUT);

Surely, this should be set to INPUT_PULLUP as FD pin is open drain.

LieBtrau commented 5 years ago

You're always free to create pull requests.

Gerriko commented 5 years ago

Ok, will create a pull request.

I also had one question about pinmode (input vs input_pullup) tagged at the bottom that's still to be answered.

LieBtrau commented 5 years ago

You're right: FD is open drain, so input_pullup is desirable.