Hi there
I'm using the ESP32-WROON-32 with MCP2515 controller and MCP2551 transceiver
with the VSCode PlatformIO and ESP-IDF framework.
Need help to use the MCP2515 driver.
gpio_config_t io_conf = {};
io_conf.intr_type = GPIO_INTR_DISABLE; // A biblioteca ISOBUS++ vai gerenciar a interrupção
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_up_en = GPIO_PULLUP_ENABLE; // O MCP2515 mantém o INT em HIGH e puxa para LOW no sinal
gpio_config(&io_conf);
spi_bus_config_t buscfg = {};
buscfg.miso_io_num = GPIO_NUM_19; // MISO
buscfg.mosi_io_num = GPIO_NUM_23; // MOSI
buscfg.sclk_io_num = GPIO_NUM_18; // SCK
buscfg.quadwp_io_num = -1;
buscfg.quadhd_io_num = -1;
spi_device_interface_config_t devcfg = {};
devcfg.clock_speed_hz = 1000000; // 1 MHz (seguro pra MCP2515)
devcfg.mode = 0;
devcfg.spics_io_num = GPIO_NUM_15; // CS
devcfg.queue_size = 1;
// Inicializa o barramento SPI (VSPI ou HSPI)
esp_err_t ret = spi_bus_initialize(VSPI_HOST, &buscfg, SPI_DMA_CH_AUTO);
if (ret != ESP_OK) {
ESP_LOGE("AgIsoStack", "SPI bus failure");
return;
} else {
ESP_LOGE("AgIsoStack", "SPI bus online!!");
}
auto spiPlugin = std::make_shared<isobus::SPIInterfaceESP>(&devcfg, VSPI_HOST);
auto canDriver = std::make_shared<isobus::MCP2515CANInterface>(spiPlugin.get(), 0x03, 0xAC, 0x03);
isobus::CANHardwareInterface::set_number_of_can_channels(1);
isobus::CANHardwareInterface::assign_can_channel_frame_handler(0, canDriver);
isobus::CANHardwareInterface::set_periodic_update_interval(10);
if (!isobus::CANHardwareInterface::start() || !canDriver->get_is_valid())
{
ESP_LOGE("AgIsoStack", "Failed to start hardware interface, the CAN driver might be invalid");
}
Could check what's happening with my code?
Hi there
I'm using the ESP32-WROON-32 with MCP2515 controller and MCP2551 transceiver
with the VSCode PlatformIO and ESP-IDF framework.
Need help to use the MCP2515 driver.
gpio_config_t io_conf = {};
io_conf.intr_type = GPIO_INTR_DISABLE; // A biblioteca ISOBUS++ vai gerenciar a interrupção
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_up_en = GPIO_PULLUP_ENABLE; // O MCP2515 mantém o INT em HIGH e puxa para LOW no sinal
gpio_config(&io_conf);
Could check what's happening with my code?