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

Thread: SPI drivers that prefer hardware CS/DC pins.

  1. #1
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,269

    Question SPI drivers that prefer hardware CS/DC pins.

    As I've been playing with ST7735 and SSD1351 displays (particularly with the uncanny eyes code), and thinking of adding radio support via SPI, I wonder which drivers are optimized to need CS and D/C pins from the limited hardware CS list?

    In a previous post Paul said ILI9341_t3, ST7735 and TFT_ILI9163C are the drivers he knew about at the time that used the hardware CS/DC pins, but I suspect other drivers (particularly other displays) have gotten optimizations added as people feel the need for speed:


    Are there other drivers that people know about that can use the special pins to optimize the device? At the moment, I am thinking of experimenting with various radio drivers (Adafruit RFM69HCW feather, Adafruit Bluetooth BLE SPI, nRF24L01+, and maybe ESP8266/ESP32 if there is a SPI variant instead of serial UART).

    This list would probably be good for the Wiki if it ever materializes.

    In terms of the hardware CS pins, the CS pins listed in the pinout cards are:
    • Teensy 3.1/3.2: SPI0: (9, 10, 15/A1, 20/A6, 21/A7)
    • Teensy 3.5/3.6: SPI0 (9, 10, 15/A1, 20/A6, 21/A7), SPI1 (31/A12), SPI2 (43, 54)
    • Teensy LC: SPI0 (10), SPI1 (6) -- though I'm not sure if the LC has hardware SPI optimization
    Last edited by MichaelMeissner; 02-27-2017 at 07:14 PM.

  2. #2
    Senior Member Epyon's Avatar
    Join Date
    Apr 2013
    Location
    Belgium
    Posts
    443
    The Ethernet lib did require D10 as CS, but I thought Paul fixed that in a recent release.

    The ESP-12 module has the SPI pins exposed and it would seem you can use this bus to transfer AT commands to and from it, though there is no official out-of-the-box firmware support for this afaik (there is for the WROOM-S2).
    Last edited by Epyon; 02-28-2017 at 09:03 AM.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,587
    Yup. Actually, Adafruit added Ethernet.init(cspin) to their fork of Arduino.org's Ethernet2 library. I adopted this change into Teensy's version, and optimized the code a bit for speed. But it's really following Adafruit's choice to call this "init" (not the normal naming convention Arduino typically uses).

  4. #4
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,428
    If this is added to a Wiki, it would be great if it actually listed all of the SPI CS pins (as well as MISO and MOSI and SCLK)
    Also would be good if it listed which Channel/Signal each of these pins map to as your program can only use one of a given signal (assuming both used for hardware CS).

    Examples:
    CS for SPI from (SPI.cpp)
    Code:
    uint8_t SPIClass::pinIsChipSelect(uint8_t pin)
    {
    	switch (pin) {
    	  case 10: return 0x01; // PTC4
    	  case 2:  return 0x01; // PTD0
    	  case 9:  return 0x02; // PTC3
    	  case 6:  return 0x02; // PTD4
    	  case 20: return 0x04; // PTD5
    	  case 23: return 0x04; // PTC2
    	  case 21: return 0x08; // PTD6
    	  case 22: return 0x08; // PTC1
    	  case 15: return 0x10; // PTC0
    #if defined(__MK64FX512__) || defined(__MK66FX1M0__)
    	  case 26: return 0x01;
    	  case 45: return 0x20; // CS5
    #endif
    	}
    
        return 0;
    }
    As you can see here you can use pins 6 and 9, BUT, only one of these two per program. Likewise for 2 and 10

    For SPI1: T3.5/T3.6 - Don't think LC is handled by this code. Also again note: pins 6 and 31 are the same signal, so can't use both as hardware CS in same program. This table also shows the extra CS pins if you use the SDCard pins.
    Code:
    uint8_t SPI1Class::pinIsChipSelect(uint8_t pin)
    {
    	switch (pin) {
    	  case 6:  return 0x01; // CS0
    	  case 31: return 0x01; // CS0
    	  case 58: return 0x02;	//CS1
    	  case 62: return 0x01;	//CS0
    	  case 63: return 0x04;	//CS2
    	}
    	return 0;
    }
    SPI2: T3.5/6
    Code:
    uint8_t SPI2Class::pinIsChipSelect(uint8_t pin)
    {
    	switch (pin) {
    	  case 43:  return 0x01; // CS0
    	  case 54: return 0x02; // CS1
    	  case 55:  return 0x01; // CS0
    	}
    	return 0;
    }
    You will note here that the cards do not show all of these pins. But it would be nice if the Wiki gave the additional information.

    As for other libraries that use these? Not sure I know that some of the other display drivers may have been updated, like ones by sumotoy.

Posting Permissions

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