Squashed commit of the following:
commitc6fd825e39Author: AlexanderHD27 <alexander@hal> Date: Wed Nov 6 23:14:14 2024 +0100 Moved CAN Interface code to comment libary folder with symlink commite7a0035041Author: AlexanderHD27 <alexander@hal> Date: Wed Nov 6 22:01:28 2024 +0100 Got MCP2521 to work commit4bfb1f533eAuthor: AlexanderHD27 <alexander@hal> Date: Wed Oct 16 21:29:35 2024 +0200 Did something to YGantryMount. It works. trust me commit5683168a47Author: AlexanderHD27 <alexander@hal> Date: Wed Oct 16 21:28:36 2024 +0200 Implemented Command-Level Interaction with CAN Interface commit9c0c676be8Author: AlexanderHD27 <alexander@hal> Date: Mon Oct 14 09:20:37 2024 +0200 Added Vscode Profile file commitb150a905a3Author: AlexanderHD27 <alexander@hal> Date: Mon Oct 14 09:19:00 2024 +0200 Implemented Low Level Compunications commit7eebf619aeAuthor: AlexanderHD27 <alexander@hal> Date: Mon Oct 7 14:46:15 2024 +0200 Created Head Pipe Mount commit93c40e1805Author: AlexanderHD27 <alexander@hal> Date: Mon Oct 7 14:44:11 2024 +0200 First Revision of YGantryMount commit91c2125458Author: AlexanderHD27 <alexander@hal> Date: Thu Oct 3 19:52:37 2024 +0200 Added Kicad Backups 2 gitignore commit096a6c18d6Author: AlexanderHD27 <alexander@hal> Date: Thu Oct 3 19:49:21 2024 +0200 Created ESP-IDF for can-interface commit48fded7981Author: AlexanderHD27 <alexander@hal> Date: Sat Sep 28 19:54:29 2024 +0200 Added files from Pico sdk to gitignore commitec5e5cbf13Author: AlexanderHD27 <alexander@hal> Date: Sat Sep 14 21:09:50 2024 +0200 Create Marker for position Calibration commit58d31964b2Author: AlexanderHD27 <alexander@hal> Date: Wed Sep 11 23:32:55 2024 +0200 Upgrade to pico SDK 2.0.0
This commit is contained in:
@@ -0,0 +1,209 @@
|
||||
#include "mcp2521_hardware_handle.hpp"
|
||||
|
||||
#ifdef ESP_PLATFORM
|
||||
#include "mcp2521_hardware_esp.hpp"
|
||||
|
||||
const uint8_t null_buffer[32] = {0};
|
||||
|
||||
void MCP2521_Hardware_Handle_ESP::spi_transmit(spi_transaction_t *t) {
|
||||
xSemaphoreTake(spiMutex, portMAX_DELAY);
|
||||
spi_device_transmit(this->spi_device_handle, t);
|
||||
xSemaphoreGive(spiMutex);
|
||||
}
|
||||
|
||||
void MCP2521_Hardware_Handle_ESP::execute(uint8_t cmd) {
|
||||
spi_transaction_ext_t t = {
|
||||
.base = {
|
||||
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||
.cmd = cmd,
|
||||
.addr = 0,
|
||||
.length = 0,
|
||||
.rxlength = 0,
|
||||
.tx_buffer = NULL,
|
||||
.rx_buffer = NULL
|
||||
},
|
||||
.command_bits = 8,
|
||||
.address_bits = 0,
|
||||
.dummy_bits = 0,
|
||||
};
|
||||
|
||||
spi_transmit((spi_transaction_t*)(&t));
|
||||
}
|
||||
|
||||
void MCP2521_Hardware_Handle_ESP::execute(uint8_t cmd, uint8_t address) {
|
||||
spi_transaction_ext_t t = {
|
||||
.base = {
|
||||
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||
.cmd = cmd,
|
||||
.addr = address,
|
||||
.length = 0,
|
||||
.rxlength = 0,
|
||||
.tx_buffer = NULL,
|
||||
.rx_buffer = NULL
|
||||
},
|
||||
.command_bits = 8,
|
||||
.address_bits = 8,
|
||||
.dummy_bits = 0,
|
||||
};
|
||||
|
||||
spi_transmit((spi_transaction_t*)(&t));
|
||||
}
|
||||
|
||||
void MCP2521_Hardware_Handle_ESP::read(uint8_t cmd, uint8_t *data, size_t length, uint8_t address) {
|
||||
spi_transaction_ext_t t = {
|
||||
.base = {
|
||||
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||
.cmd = cmd,
|
||||
.addr = address,
|
||||
.length = 8*length,
|
||||
.rxlength = 8*length,
|
||||
.tx_buffer = null_buffer,
|
||||
.rx_buffer = data
|
||||
},
|
||||
.command_bits = 8,
|
||||
.address_bits = 8,
|
||||
.dummy_bits = 0,
|
||||
};
|
||||
|
||||
spi_transmit((spi_transaction_t*)(&t));
|
||||
}
|
||||
|
||||
void MCP2521_Hardware_Handle_ESP::read(uint8_t cmd, uint8_t *data, size_t length) {
|
||||
spi_transaction_ext_t t = {
|
||||
.base = {
|
||||
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||
.cmd = cmd,
|
||||
.addr = 0,
|
||||
.length = 8*length,
|
||||
.rxlength = 8*length,
|
||||
.tx_buffer = NULL,
|
||||
.rx_buffer = data
|
||||
},
|
||||
.command_bits = 8,
|
||||
.address_bits = 0,
|
||||
.dummy_bits = 0,
|
||||
};
|
||||
|
||||
spi_transmit((spi_transaction_t*)(&t));
|
||||
}
|
||||
|
||||
uint8_t MCP2521_Hardware_Handle_ESP::read(uint8_t cmd, uint8_t address) {
|
||||
uint8_t result = 0;
|
||||
spi_transaction_ext_t t = {
|
||||
.base = {
|
||||
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||
.cmd = cmd,
|
||||
.addr = address,
|
||||
.length = 8,
|
||||
.rxlength = 8,
|
||||
.tx_buffer = null_buffer,
|
||||
.rx_buffer = &result
|
||||
},
|
||||
.command_bits = 8,
|
||||
.address_bits = 8,
|
||||
.dummy_bits = 0,
|
||||
};
|
||||
|
||||
spi_transmit((spi_transaction_t*)(&t));
|
||||
return result;
|
||||
}
|
||||
|
||||
uint8_t MCP2521_Hardware_Handle_ESP::read(uint8_t cmd) {
|
||||
uint8_t result;
|
||||
spi_transaction_ext_t t = {
|
||||
.base = {
|
||||
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||
.cmd = cmd,
|
||||
.addr = 0,
|
||||
.length = 8,
|
||||
.rxlength = 8,
|
||||
.tx_buffer = null_buffer,
|
||||
.rx_buffer = &result
|
||||
},
|
||||
.command_bits = 8,
|
||||
.address_bits = 0,
|
||||
.dummy_bits = 0,
|
||||
};
|
||||
|
||||
spi_transmit((spi_transaction_t*)(&t));
|
||||
return result;
|
||||
}
|
||||
|
||||
void MCP2521_Hardware_Handle_ESP::write(uint8_t cmd, uint8_t *data, size_t length, uint8_t address) {
|
||||
uint8_t result;
|
||||
spi_transaction_ext_t t = {
|
||||
.base = {
|
||||
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||
.cmd = cmd,
|
||||
.addr = address,
|
||||
.length = 8*length,
|
||||
.rxlength = 0,
|
||||
.tx_buffer = data,
|
||||
.rx_buffer = NULL
|
||||
},
|
||||
.command_bits = 8,
|
||||
.address_bits = 8,
|
||||
.dummy_bits = 0,
|
||||
};
|
||||
|
||||
spi_transmit((spi_transaction_t*)(&t));
|
||||
}
|
||||
|
||||
void MCP2521_Hardware_Handle_ESP::write(uint8_t cmd, uint8_t *data, size_t length) {
|
||||
spi_transaction_ext_t t = {
|
||||
.base = {
|
||||
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||
.cmd = cmd,
|
||||
.addr = 0,
|
||||
.length = 8*length,
|
||||
.rxlength = 0,
|
||||
.tx_buffer = data,
|
||||
.rx_buffer = NULL
|
||||
},
|
||||
.command_bits = 8,
|
||||
.address_bits = 0,
|
||||
.dummy_bits = 0,
|
||||
};
|
||||
|
||||
spi_transmit((spi_transaction_t*)(&t));
|
||||
}
|
||||
|
||||
void MCP2521_Hardware_Handle_ESP::write(uint8_t cmd, uint8_t data, uint8_t address) {
|
||||
spi_transaction_ext_t t = {
|
||||
.base = {
|
||||
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||
.cmd = cmd,
|
||||
.addr = address,
|
||||
.length = 8,
|
||||
.rxlength = 0,
|
||||
.tx_buffer = &data,
|
||||
.rx_buffer = NULL
|
||||
},
|
||||
.command_bits = 8,
|
||||
.address_bits = 8,
|
||||
.dummy_bits = 0,
|
||||
};
|
||||
|
||||
spi_transmit((spi_transaction_t*)(&t));
|
||||
}
|
||||
|
||||
void MCP2521_Hardware_Handle_ESP::write(uint8_t cmd, uint8_t data) {
|
||||
spi_transaction_ext_t t = {
|
||||
.base = {
|
||||
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||
.cmd = cmd,
|
||||
.addr = 0,
|
||||
.length = 8,
|
||||
.rxlength = 0,
|
||||
.tx_buffer = &data,
|
||||
.rx_buffer = NULL
|
||||
},
|
||||
.command_bits = 8,
|
||||
.address_bits = 0,
|
||||
.dummy_bits = 0,
|
||||
};
|
||||
|
||||
spi_transmit((spi_transaction_t*)(&t));
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user