Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Teensy LC and using their 2 SPI connections.

  1. #1
    Junior Member Joena's Avatar
    Join Date
    Feb 2019

    Teensy LC and using their 2 SPI connections.

    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).

    1x Ethernet board (WIZ850IO) > to locally control a device through a plain socket (send/receive ASCII commands).

    1x Packet radio (RFM69HCW) > to send/receive sensor data to another Packet radio, which is connected to the Internet (Gateway).

    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)
    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

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Ayer Massachussetts
    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 by MichaelMeissner; 02-08-2019 at 01:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts