SPI MCP23S18 Sumotoy library

Hello,

I am using sumotoy's gpio_MCP23SXX library (GitHub - sumotoy/gpio_MCP23SXX: Fast,Full featured library for Microchip MC23Sxx series for many CPU's) to build asOutput.ino on VSCode for MCP23S18 GPIO extender through SPI. I get an error at gpio_MCP23SXX mcp1() which is as below:

asOutput:31:38: error: no matching function for call to 'gpio_MCP23SXX::gpio_MCP23SXX(gpio_MCP23SXX_chip, int, int)'
gpio_MCP23SXX mcp1(MCP23S18, 33, 0x20);

Could you please tell me If I need a function definition for mcp1? If so where is it defined in your code? And how do I add ESP_SPI library to my code?

Awaiting inputs. Thank you.

#include <gpio_MCP23SXX.h>
#include <SPI.h>
/*
   In this basic example the MCP GPIO Chip is used as OUT
*/

/*
  --- ESP8266
  MOSI(13) MISO(12) SCLK(14) CS(5,4,0,2) scl, sda, flash, txd1
  ESP12E Dev Board 0.9, 1.0
  MOSI: D7
  MISO: D6
  SCLK: D5
  CS:   D1,D2,D3,D4

*/

/*
  --- ESP8266
  MOSI(39) MISO(41) SCLK(40) CS(33,34,35,36)
  ESP32S2 Dev Board 0.9, 1.0
  MOSI: IO35
  MISO: IO37
  SCLK: IO36
  CS:   SPICS0, SPICLK, SPIQ, SPID

*/

//define CS pin and using HAEN or not
//to use HAEN, address should be 0x20 to 0x27 for MCP23S17
gpio_MCP23SXX mcp1(MCP23S18, 33, 0x20);

void setup() {
  Serial.begin(15200);
  //long unsigned debug_start = millis ();
  //while (!Serial && ((millis () - debug_start) <= 5000));
  Serial.println("started");
  mcp1.begin();//this initialize SPI bus as well
  mcp1.gpioPinMode(OUTPUT);//set every GPIO port as OUT
  mcp1.gpioPort(0xFFFF);//Set all port as '1'
}


void loop() {
  //ports() return the number of ports of the choosed GPIO chip
  for (int i = 0; i < mcp1.ports(); i++) {
    //gpioDigitalInvert reads internal tracked GPIO port value
    //and invert it, then update GPIO.
    mcp1.gpioDigitalInvert(i);
    delay(10);
  }

  for (int i = 0; i < mcp1.ports(); i++) {
    mcp1.gpioDigitalInvert(i);
    delay(10);
  }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.