kpg
June 3, 2020, 7:57pm
1
Having got a PN532 working on hardware SPI with an 1351 OLED on hardware SPI, I want to swap them to get more OLED speed.
Am I setting the two devices up correctly? I cant find any good references for PN532 software SPI.
#include <SPI.h>
#include <PN532_SPI.h>
#include "PN532.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1351.h>
#define dc A2//oled
#define cs 53//oled
#define rst 4//oled
#define mosi A5//oled//rfid. Oled wired to 51.
#define sclk A6//oled//rfid. Oled is wired to 52
#define ss 10//oled
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
PN532 nfc(pn532spi);
Adafruit_SSD1351 tft = Adafruit_SSD1351(cs, dc, rst);
Turn on the power, run and tell what's happening if You don't want to attach schematics and have them checked.
Why slow software SPI if you have hardware SPI?
Then PN532 also can do I2C in parallel to other SPI devices.
kpg
June 4, 2020, 12:11pm
4
Sorry guys.
The reason this has come up is I had both as hardware SPI and then found out the OLED and RFID run two different speeds and bit orders and it looks like the OLED cant be changed.
I had already made a PCB assuming both would work on HW SPI together and they dont.
So I posted this question BEFORE I start rewiring the PCB. I understand I could use I2C but again the PCB is done .
I just wanted a sanity check on my setup......Pin assigns should show the wiring...
You can reconfigure the SPI hardware before every transmission. Or use I2C with the PN532.
kpg
June 4, 2020, 11:01pm
6
I probably can reset the spi at each transmission but i'm not sure I have the skills for that, hence the simpler config question in the first post.
I can run with a slow rfid but not a slow oled.......
I probably can reset the spi at each transmission but i'm not sure I have the skills for that
Here is a pretty good thread on dynamically reconfiguring the SPI bus for two devices.
https://forum.arduino.cc/index.php?topic=185306.0
My bet is that you can do it.
kpg
June 5, 2020, 7:14am
8
Brilliant. Thanks.
I did try a simple approach with just calling tft.begin() each time I used the OLED but that didnt work.
Will do some reading.
I would still like to understand the software SPI config for the RFID though. I cant seem to find any examples. I think I have it right in......
#include <SPI.h>
#include <PN532_SPI.h>
#include "PN532.h"
#define mosi A5//mosi of RFID is in ICSP mosi pin
#define sclk A6
#define ss 10
Adafruit_PN532 nfc(PN532_SCK, PN532_MISO, PN532_MOSI, PN532_SS);
PN532 nfc(pn532spi);