Open AnatoliyChel opened 1 year ago
You need to set up the spi structure If you want i created a fork to do it here: https://github.com/GiovanniRaseraF/esp32-SIM800-mcp2515
You can find the setup and use it if you want,
In my case i had to set this parameters:
I also modified the code for the MCP2515 constructor like this:
MCP2515::MCP2515(spi_device_handle_t *s)
{
spi = s;
// ESP32SIM800 START
esp_err_t ret;
spi_bus_config_t buscfg={};
buscfg.miso_io_num=MISO;
buscfg.mosi_io_num=MOSI;
buscfg.sclk_io_num=SCK;
buscfg.quadwp_io_num=-1;
buscfg.quadhd_io_num=-1;
spi_device_interface_config_t devcfg={};
devcfg.clock_speed_hz=1*1000*1000, //Clock out at 1 MHz
devcfg.mode=0,
devcfg.spics_io_num=SS, //Chip select
devcfg.queue_size=7,
//Initialize the SPI bus
ret=spi_bus_initialize(HSPI_HOST, &buscfg, 1);
assert(ret==ESP_OK);
//Attach the MCP2515 to the SPI bus
ret=spi_bus_add_device(HSPI_HOST, &devcfg, &*spi);
assert(ret==ESP_OK);
// ESP32SIM800 END
}
Its not a good solution but i dont want to set spi parameters in void setup();
Could you please explain what is spi means in this code? It has a type spi_device_handle_t and i can't find any description of this. Please give example.