Got MCP2521 to work

This commit is contained in:
AlexanderHD27
2024-11-06 22:01:28 +01:00
parent 4bfb1f533e
commit e7a0035041
17 changed files with 525 additions and 70 deletions

View File

@@ -2,8 +2,12 @@
#ifdef ESP_PLATFORM
#include "mcp2521_hardware_esp.hpp"
#include "driver/gpio.h"
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
MCP2521_Hardware_Handle_ESP::MCP2521_Hardware_Handle_ESP(
spi_host_device_t spi_host,
spi_bus_config_t *bus_config,
@@ -34,18 +38,6 @@ MCP2521_Hardware_Handle_ESP::~MCP2521_Hardware_Handle_ESP() {
}
void MCP2521_Hardware_Handle_ESP::initPins(
gpio_num_t int_pin
) {
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pin_bit_mask = 1 << int_pin;
io_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
io_conf.pull_up_en = GPIO_PULLUP_ENABLE;
gpio_config(&io_conf);
}
void MCP2521_Hardware_Handle_ESP::initSPIBus(
spi_host_device_t spi_host,
gpio_num_t mosi,
@@ -89,6 +81,8 @@ void MCP2521_Hardware_Handle_ESP::initSPIDevice(
};
spi_bus_add_device(spi_host, &this->spi_device_config, &this->spi_device_handle);
spiMutex = xSemaphoreCreateMutex();
}
spi_bus_config_t * MCP2521_Hardware_Handle_ESP::getSPI_bus_config() {