Teensy LC and using their 2 SPI connections.

Status
Not open for further replies.

Joena

New member
Hi all,
I'm new to Teensy and perhaps willing to make the switch to use these board (instead of the Adafruit Feathers).

For my project I want to control a device (via a local Ethernet connection) remotely with a Packet radio.
For this setup to work I want to use these hardware components:


1x CPU board (Teensy LC).
https://www.antratek.nl/teensy-lc

1x Ethernet board (WIZ850IO) > to locally control a device through a plain socket (send/receive ASCII commands).
https://www.tinytronics.nl/shop/nl/communicatie/netwerk/w5500-ethernet-module-wiz850io-compatible

1x Packet radio (RFM69HCW) > to send/receive sensor data to another Packet radio, which is connected to the Internet (Gateway).
https://www.hobbyelectronica.nl/product/rfm69hcw-433-mhz-breakout/


I know know the Ethernet board (W5500) uses SPI, but the Packet radio also uses SPI.
The local Ethernet connection must be kept (alive) at all times (no interrupts).

Can I use a Teensy LC (2x SPI)
https://www.pjrc.com/teensy/teensylc_front_pinout.png
to keep my local Ethernet connection online - all the time (SPI 1),
in combination with the Packet radio through the other connection (SPI 2)??


With kind regards,
Jeroen Wolf
 
I don't know about either device, and a quick scan of the RadioHead library showed that it is a rather complex library. So this is more just background about having multiple SPI devices.

The generic problem is most of the Arduino drivers assume there is only one SPI hardware device, and typically only one SPI device on the one SPI bus. So most of the drivers for SPI devices just includes <Wire.h>, and uses the Wire global class variable to talk to the device. One solution is to copy the library to your Arduino directory, and rename it. Then edit references to Wire. to use Wire1. instead for devices on the 2nd SPI bus.

Some SPI devices can share the bus with other devices. Each device has a unique CS (chip select) pin, and possibly DC (data/command) pin. You would set CS high or low (depending on the device) when you are talking to the device, and change it when you are not talking to the device. The Teensy SPI has support for transactions to allow a single SPI device to be shared. Both drivers would have to use the transaction support to be shared. SPI devices can be shared even without SPI transaction support, but you likely have to do a lot of hand holding and library hacking to get it to work.

One of the users here (KurtE) has a set of libraries (SPIN) to more easily allow different devices to use different SPI buses:

Using 2 separate SPI buses probably works if the devices aren't prepared to share a SPI bus, but you likely will need to do a lot of library hacking to get the device on the second SPI bus to work. If the two devices can share the SPI bus, it may just work.
 
Last edited:
Status
Not open for further replies.
Back
Top