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

Thread: SPISlave_T4

  1. #1
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,697

    SPISlave_T4

    SPISlave_T4 has been released!

    You may download it at https://github.com/tonton81/SPISlave_T4
    An example is supplied as well.

    It is based on TSPISlave for Teensy 3.x, except it has an additional feature. Not using a callback will print out data being received to serial monitor.

    So far Teensy 4.0/4.1 are supported for SPI only on pins 10, 11, 12, 13. No additional pins needed (well, common ground is obviously a plus).

    I don't have the SPI1 or SPI2 pins broken out, but the library can easily support them as I am accessing the memory blocks directly with calculated offsets, rather than independant register names. Until then, SPI. is only supported.

    My setup consisted of a Teensy LC SPI master sending data to a Teensy 4.0 slave.
    Code:
    Pin layout for SPI:
    
    LC      T4
    
    12      11
    11      12
    10      10
    13      13
    
    
    No alternate pins are broken out for SPI on Teensy 4.0/4.1.
    Slave mode on Teensy 4 supports 8, 16, and 32bit transfers selectable in the constructor. Note that if you set 16 or 32bits, you need to send all the bits. Like for 16 bit you need to send 2x8bit transfers or one transfer16, or 4x 8bit transfers for 32bit or 2x transfer16's for 32bit.

    Enjoy!
    Last edited by tonton81; 02-25-2021 at 02:52 PM.

  2. #2
    Senior Member
    Join Date
    Dec 2013
    Location
    East Stroudsburg PA.
    Posts
    304
    Oh this is looking good
    I am wondering if I can use this to spy on my vintage Atari 1040 STE Microwire Interface (LMC1992 IC).

  3. #3
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,697
    As a spy? just don't hookup the return line so it wont try to send anything to it, it should be able to print out what it sees on the spi bus with the callback disabled

  4. #4
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,697
    Hey that is an interesting idea. We could setup the library to also be an SPI bus sniffer. The T4.x is capable of swapping the MISO/MOSI pins so you can log & sniff data going to and from the SPI devices. The outgoing pin could be disabled in sniff mode as well.

  5. #5
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,697
    Just updated the library. It now supports:

    mySPI.swapPins() --> swaps MISO with MOSI, so you can connect teensies together directly pin-to-pin:
    Code:
    13   13
    12   12
    11   11
    10   10
    and sniffer() : --> disables the slave output pin so it listens to traffic only.

Posting Permissions

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