Pin settings for connecting BBAI-64 and RFID RC522

First of all, the reason for proceeding with the process is to transmit the card tag information of the RFID RC522 module to the BBAI-64 board through SPI communication, and then transmit the received information to the PC through UART communication.
At this time, the code to connect the two devices was written similar to the Arduino board as below. Can I write it like this?? If not, how should I write to change it correctly?

#define SS_PIN 17 // P9_17
#define RST_PIN 10 // P9_10
#define MISO_PIN 21 // P9_21
#define MOSI_PIN 18 // P9_18
#define SCK_PIN 26 // P9_26

Unfortunately it is not so simple.

You will need to load a devicetree overlay at boot time to enable SPI6 and to make sure the pin muxing is set accordingly.

Luckily such a devicetree overlay does exist already, you just need to make sure it gets loaded.

you will need to edit /boot/firmware/extlinux/extlinux.conf

Make a copy of the file first !

you will need a line that says

fdtoverlays /overlays/BONE-SPI0_0.dtbo

If you already have some overlays being loaded, you can just append /overlays/BONE-SPI0_0.dtbo to the end of the line.

Rebooting should then load this overlay and enable the SPI interface.

It would be useful at this point if you have serial console cable in case things don’t work.

you can do a quick check after rebooting by doing

ls /sys/firmware/devicetree/base/chosen/overlays/

You should see BONE-SPI0_0.kernel if the overlay has been loaded.

I am not sure it is a good idea to connect the reset to P9_17. I am not sure exactly what this pin does. If you need to reset the module it would be better to connect it to any spare GPIO pin. That way you can reset the module from your software as needed, rather than resetting the whole board.

Reading and writing to the SPI & UART ports will also be very different compared to an Arduino.

Depending on your choice of language, you should be able to Goolge plenty of examples of using SPI and UARTs under Linux ( no need to search for BBAI-64 specific stuff) Probably Python will be the easiest to do assuming you know Python, but you should be able to find plenty of examples in C also

***** EDIT ****
I forgot to add you also need to edit

/etc/modules-load.d/modules.conf

Make sure you have spidev listed or the spidev driver will not be loaded.

# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
spidev

Also if you look in /opt/source/spidev-test there is a C example of using spidev.

2 Likes