Closed fabianoriccardi closed 1 year ago
Sorry. Just now seeing this.
@fabianoriccardi This can be done by changing the existing constructor:
Adafruit_PN532(uint8_t ss); // Hardware SPI
to:
Adafruit_PN532(uint8_t ss, SPIClass *theSPI = &SPI); // Hardware SPI
and then change the existing code to pass that in:
Adafruit_PN532::Adafruit_PN532(uint8_t ss, SPIClass *theSPI) {
spi_dev =
new Adafruit_SPIDevice(ss, 1000000, SPI_BITORDER_LSBFIRST, SPI_MODE0, theSPI);
}
That won't break anything in terms of backwards compatibility. It also does not require creating the SPIDevice instance in user code like your example above.
I don't fully know the codebase, so forgive me if I'm wrong. With the following line:
new Adafruit_SPIDevice(ss, 1000000, SPI_BITORDER_LSBFIRST, SPI_MODE0, theSPI);
you are setting the frequency to 1MHz, which is the problem with ESP32.
@ladyada This is a generic issue - How to expose the other parameters of SPIDevice
? I don't think we want to do this by having the SPIDevice
instance created in user code?
Closing. Ability to specify SPI bus added with #112. The frequency used is confirmed working with ESP32.
If there is still a need to specify an alternate frequency, please open a new issue with information about what is not working with current library code.
I have added a constructor to personalize the frequency of hardware SPI. The issue #80 is still open, so this pull request may help.
To initialize the PN532 class you will have to type: