Got MCP2521 to work
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
class MCP2521_Hardware_Handle_ESP : public MCP2521_Hardware_Handle {
|
||||
char spi_tmp_buffer;
|
||||
@@ -13,6 +15,15 @@ class MCP2521_Hardware_Handle_ESP : public MCP2521_Hardware_Handle {
|
||||
spi_device_interface_config_t spi_device_config;
|
||||
spi_device_handle_t spi_device_handle;
|
||||
|
||||
SemaphoreHandle_t canInterruptSemaphore = NULL;
|
||||
SemaphoreHandle_t spiMutex = NULL;
|
||||
TaskHandle_t canInterruptTaskHandle = NULL;
|
||||
|
||||
void spi_transmit(spi_transaction_t *t);
|
||||
|
||||
void * intHandlerArg = NULL;
|
||||
intHandlerFunction_t intHandler = NULL;
|
||||
|
||||
public:
|
||||
MCP2521_Hardware_Handle_ESP(
|
||||
spi_host_device_t spi_host,
|
||||
@@ -52,6 +63,10 @@ public:
|
||||
|
||||
spi_bus_config_t * getSPI_bus_config();
|
||||
|
||||
// ISR Stuff
|
||||
void isr_can_interrupt();
|
||||
void handleIntteruptTaskFn();
|
||||
|
||||
// Inherited from MCP2521_Hardware_Handle
|
||||
void execute(uint8_t cmd);
|
||||
void execute(uint8_t cmd, uint8_t address);
|
||||
@@ -65,6 +80,8 @@ public:
|
||||
void write(uint8_t cmd, uint8_t *data, size_t length);
|
||||
void write(uint8_t cmd, uint8_t data, uint8_t address);
|
||||
void write(uint8_t cmd, uint8_t data);
|
||||
|
||||
void registerIntHandler(intHandlerFunction_t handler, void * arg);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
#include <cstdint>
|
||||
#include <strings.h>
|
||||
|
||||
typedef void (*intHandlerFunction_t)(void *);
|
||||
|
||||
class MCP2521_Hardware_Handle {
|
||||
public:
|
||||
virtual void registerIntHandler(intHandlerFunction_t handler, void * arg) = 0;
|
||||
|
||||
virtual void execute(uint8_t cmd) = 0;
|
||||
virtual void execute(uint8_t cmd, uint8_t address) = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user