Implement Multi-Bus CAN Interfaces
This commit is contained in:
BIN
can-interface/.gitignore
(Stored with Git LFS)
vendored
BIN
can-interface/.gitignore
(Stored with Git LFS)
vendored
Binary file not shown.
5
can-interface/.vscode/settings.json
vendored
5
can-interface/.vscode/settings.json
vendored
@@ -10,10 +10,11 @@
|
||||
"idf.openOcdConfigs": [
|
||||
"board/esp32-wrover-kit-3.3v.cfg"
|
||||
],
|
||||
"idf.port": "/dev/ttyUSB0",
|
||||
"idf.port": "/dev/ttyUSB1",
|
||||
"idf.pythonBinPath": "/home/alexander/.espressif/python_env/idf5.3_py3.12_env/bin/python",
|
||||
"idf.toolsPath": "/home/alexander/.espressif",
|
||||
"idf.flashType": "UART",
|
||||
"idf.flashType": "JTAG",
|
||||
"idf.openOcdLaunchArgs": ["-c", "adapter_khz 10000"],
|
||||
"files.associations": {
|
||||
"*.tcc": "cpp",
|
||||
"cstdint": "cpp",
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
/home/alexander/Projects/gobot/can-interface/circuit/gobot-can-interface/_autosave-gobot-can-interface.kicad_sch
|
||||
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-12_010429.zip
(Stored with Git LFS)
Normal file
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-12_010429.zip
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-12_011347.zip
(Stored with Git LFS)
Normal file
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-12_011347.zip
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-14_202426.zip
(Stored with Git LFS)
Normal file
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-14_202426.zip
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-15_170909.zip
(Stored with Git LFS)
Normal file
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-15_170909.zip
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-15_204011.zip
(Stored with Git LFS)
Normal file
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-15_204011.zip
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-21_223757.zip
(Stored with Git LFS)
Normal file
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface-backups/gobot-can-interface-2024-11-21_223757.zip
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface.kicad_sch
(Stored with Git LFS)
BIN
can-interface/circuit/gobot-can-interface/gobot-can-interface.kicad_sch
(Stored with Git LFS)
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
idf_component_register(SRCS
|
||||
"canTP.cpp"
|
||||
"gobotRPC.cpp"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES driver
|
||||
REQUIRES mcp2521
|
||||
REQUIRES mcp2521_hardware_interface
|
||||
)
|
||||
2866
can-interface/docs/Doxyfile
Normal file
2866
can-interface/docs/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
1
can-interface/docs/doxygen-awesome-css
Submodule
1
can-interface/docs/doxygen-awesome-css
Submodule
Submodule can-interface/docs/doxygen-awesome-css added at 568f56cde6
@@ -2,5 +2,6 @@ idf_component_register(SRCS "hello_world_main.cpp"
|
||||
REQUIRES driver
|
||||
REQUIRES mcp2521
|
||||
REQUIRES mcp2521_hardware_interface
|
||||
REQUIRES CAN-Protocol-Stack
|
||||
REQUIRES spi_flash
|
||||
INCLUDE_DIRS "")
|
||||
|
||||
@@ -23,23 +23,40 @@
|
||||
|
||||
#include "mcp2521.hpp"
|
||||
|
||||
#define SPI_PIN_CS0 GPIO_NUM_5
|
||||
#define SPI_PIN_SCLK GPIO_NUM_18
|
||||
#define SPI_PIN_MISO GPIO_NUM_19
|
||||
#define SPI_PIN_MOSI GPIO_NUM_23
|
||||
#define CAN_INT_PIN GPIO_NUM_21
|
||||
|
||||
#define EXTERNAL_TRIGGER GPIO_NUM_26
|
||||
#define SPI_PIN_CS0 GPIO_NUM_25
|
||||
#define SPI_PIN_CS1 GPIO_NUM_27
|
||||
|
||||
void onRX(void *arg) {
|
||||
MCP2521 *mcp2521 = (MCP2521 *)arg;
|
||||
#define CAN_INT0_PIN GPIO_NUM_5
|
||||
#define CAN_INT1_PIN GPIO_NUM_26
|
||||
|
||||
rx_info info = mcp2521->get_rx_id(MCP2521_RX_BUFFER::RXB0);
|
||||
void onRX0(void *arg) {
|
||||
MCP2521 *mcp2521_0 = (MCP2521 *)arg;
|
||||
|
||||
rx_info info = mcp2521_0->get_rx_id(MCP2521_RX_BUFFER::RXB0);
|
||||
uint8_t data[8];
|
||||
|
||||
mcp2521->read_rx_buf(MCP2521_RX_BUFFER::RXB0, MCP2521_BUFFER_TYPE::DATA, data, info.length);
|
||||
mcp2521_0->read_rx_buf(MCP2521_RX_BUFFER::RXB0, MCP2521_BUFFER_TYPE::DATA, data, info.length);
|
||||
|
||||
printf("RX: (%x) ", info.id);
|
||||
printf("RX0: (%x) ", info.id);
|
||||
for (int i = 0; i < info.length; i++) {
|
||||
printf("%x ", data[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void onRX1(void *arg) {
|
||||
MCP2521 *mcp2521_0 = (MCP2521 *)arg;
|
||||
|
||||
rx_info info = mcp2521_0->get_rx_id(MCP2521_RX_BUFFER::RXB0);
|
||||
uint8_t data[8];
|
||||
|
||||
mcp2521_0->read_rx_buf(MCP2521_RX_BUFFER::RXB0, MCP2521_BUFFER_TYPE::DATA, data, info.length);
|
||||
|
||||
printf("RX1: (%x) ", info.id);
|
||||
for (int i = 0; i < info.length; i++) {
|
||||
printf("%x ", data[i]);
|
||||
}
|
||||
@@ -52,46 +69,53 @@ extern "C" void app_main() {
|
||||
const gpio_num_t LED_PIN = GPIO_NUM_2;
|
||||
gpio_set_direction(LED_PIN, GPIO_MODE_OUTPUT);
|
||||
|
||||
gpio_set_direction(EXTERNAL_TRIGGER, GPIO_MODE_OUTPUT);
|
||||
gpio_set_level(EXTERNAL_TRIGGER, true);
|
||||
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
|
||||
|
||||
spi_bus_config_t spi_bus;
|
||||
|
||||
MCP2521_Hardware_Handle_ESP hardware_mcp2521(
|
||||
MCP2521_HardwareHandleFactory_ESPBus mcp2521_hardware_factory(
|
||||
VSPI_HOST,
|
||||
&spi_bus,
|
||||
SPI_PIN_MOSI,
|
||||
SPI_PIN_MISO,
|
||||
SPI_PIN_SCLK,
|
||||
SPI_PIN_CS0,
|
||||
CAN_INT_PIN
|
||||
SPI_PIN_SCLK
|
||||
);
|
||||
|
||||
MCP2521 mcp2521(&hardware_mcp2521);
|
||||
MCP2521_HardwareHandle_ESPBus hardware_mcp2521_0 = mcp2521_hardware_factory.create(CAN_INT0_PIN, SPI_PIN_CS0);
|
||||
MCP2521_HardwareHandle_ESPBus hardware_mcp2521_1 = mcp2521_hardware_factory.create(CAN_INT1_PIN, SPI_PIN_CS1);
|
||||
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
|
||||
MCP2521 mcp2521_0(&hardware_mcp2521_0);
|
||||
MCP2521 mcp2521_1(&hardware_mcp2521_1);
|
||||
|
||||
uint8_t data[4] = {0xf0, 0x42, 0x13, 0x37};
|
||||
|
||||
gpio_set_level(EXTERNAL_TRIGGER, false);
|
||||
mcp2521.reset();
|
||||
mcp2521.enable_interrupts(true, true, true, true, true, true, true, true);
|
||||
mcp2521_0.reset();
|
||||
mcp2521_1.reset();
|
||||
mcp2521_0.enable_interrupts(true, true, true, true, true, true, true, true);
|
||||
mcp2521_1.enable_interrupts(true, true, true, true, true, true, true, true);
|
||||
|
||||
mcp2521.register_rx0_handler(onRX, &mcp2521);
|
||||
mcp2521.register_rx1_handler(onRX, &mcp2521);
|
||||
mcp2521.set_mode_of_operation(MCP2521_OPERATION_MODE::LOOPBACK, true);
|
||||
mcp2521_0.register_rx0_handler(onRX0, &mcp2521_0);
|
||||
mcp2521_1.register_rx0_handler(onRX1, &mcp2521_1);
|
||||
mcp2521_0.register_rx1_handler(onRX0, &mcp2521_0);
|
||||
mcp2521_1.register_rx1_handler(onRX1, &mcp2521_1);
|
||||
|
||||
mcp2521_0.set_mode_of_operation(MCP2521_OPERATION_MODE::NORMAL, true);
|
||||
mcp2521_1.set_mode_of_operation(MCP2521_OPERATION_MODE::NORMAL, true);
|
||||
|
||||
printf("CANSTAT0: %x\n", mcp2521_0.read_reg(MCP2521_CANSTAT));
|
||||
printf("CANSTAT1: %x\n", mcp2521_1.read_reg(MCP2521_CANSTAT));
|
||||
|
||||
vTaskDelay(3 / portTICK_PERIOD_MS);
|
||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||
|
||||
mcp2521.prepare_tx(
|
||||
mcp2521_0.prepare_tx(
|
||||
MCP2521_TX_BUFFER::TXB0, 0x042, data, 4, false, false);
|
||||
|
||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||
mcp2521_0.request_to_send(MCP2521_TX_BUFFER::TXB0);
|
||||
//vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
//mcp2521_1.request_to_send(MCP2521_TX_BUFFER::TXB0);
|
||||
|
||||
mcp2521.request_to_send(MCP2521_TX_BUFFER::TXB0);
|
||||
|
||||
mcp2521.set_tx_id(MCP2521_TX_BUFFER::TXB0, 0x041, false);
|
||||
mcp2521.request_to_send(MCP2521_TX_BUFFER::TXB0);
|
||||
|
||||
//mcp2521_0.set_tx_id(MCP2521_TX_BUFFER::TXB0, 0x041, false);
|
||||
//mcp2521_0.request_to_send(MCP2521_TX_BUFFER::TXB0);
|
||||
|
||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||
|
||||
@@ -100,6 +124,6 @@ extern "C" void app_main() {
|
||||
gpio_set_level(LED_PIN, flag);
|
||||
flag = !flag;
|
||||
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
|
||||
2008
can-interface/sdkconfig.old
Normal file
2008
can-interface/sdkconfig.old
Normal file
File diff suppressed because it is too large
Load Diff
152
can-interface/session-setup
Normal file
152
can-interface/session-setup
Normal file
@@ -0,0 +1,152 @@
|
||||
[General]
|
||||
decode_signals=2
|
||||
meta_objs=0
|
||||
views=1
|
||||
|
||||
[D0]
|
||||
color=4291714048
|
||||
conv_options=0
|
||||
conversion_type=0
|
||||
enabled=true
|
||||
name=INT0
|
||||
|
||||
[D1]
|
||||
color=4281623972
|
||||
conv_options=0
|
||||
conversion_type=0
|
||||
enabled=true
|
||||
name=CLK
|
||||
|
||||
[D2]
|
||||
color=4281623972
|
||||
conv_options=0
|
||||
conversion_type=0
|
||||
enabled=true
|
||||
name=MOSI
|
||||
|
||||
[D3]
|
||||
color=4281623972
|
||||
conv_options=0
|
||||
conversion_type=0
|
||||
enabled=true
|
||||
name=MISO
|
||||
|
||||
[D4]
|
||||
color=4294277376
|
||||
conv_options=0
|
||||
conversion_type=0
|
||||
enabled=true
|
||||
name=CE0
|
||||
|
||||
[D5]
|
||||
color=4279638298
|
||||
conv_options=0
|
||||
conversion_type=0
|
||||
enabled=true
|
||||
name=INT1
|
||||
|
||||
[D6]
|
||||
color=4279638298
|
||||
conv_options=0
|
||||
conversion_type=0
|
||||
enabled=true
|
||||
name=CE1
|
||||
|
||||
[D7]
|
||||
color=4285878395
|
||||
conv_options=0
|
||||
conversion_type=0
|
||||
enabled=true
|
||||
name=D7
|
||||
|
||||
[decode_signal0]
|
||||
channel0\assigned_signal_name=CLK
|
||||
channel0\initial_pin_state=2
|
||||
channel0\name=CLK
|
||||
channel1\assigned_signal_name=MISO
|
||||
channel1\initial_pin_state=2
|
||||
channel1\name=MISO
|
||||
channel2\assigned_signal_name=MOSI
|
||||
channel2\initial_pin_state=2
|
||||
channel2\name=MOSI
|
||||
channel3\assigned_signal_name=CE0
|
||||
channel3\initial_pin_state=2
|
||||
channel3\name=CS#
|
||||
channels=4
|
||||
color=4294277376
|
||||
conv_options=0
|
||||
conversion_type=0
|
||||
decoder0\ann_class0\visible=true
|
||||
decoder0\ann_class1\visible=true
|
||||
decoder0\ann_class2\visible=true
|
||||
decoder0\ann_class3\visible=true
|
||||
decoder0\ann_class4\visible=true
|
||||
decoder0\ann_class5\visible=true
|
||||
decoder0\ann_class6\visible=true
|
||||
decoder0\id=spi
|
||||
decoder0\options=0
|
||||
decoder0\row0\visible=true
|
||||
decoder0\row1\visible=true
|
||||
decoder0\row2\visible=true
|
||||
decoder0\row3\visible=true
|
||||
decoder0\row4\visible=true
|
||||
decoder0\row5\visible=true
|
||||
decoder0\row6\visible=true
|
||||
decoder0\visible=true
|
||||
decoders=1
|
||||
enabled=true
|
||||
name=SPI0
|
||||
|
||||
[decode_signal1]
|
||||
channel0\assigned_signal_name=CLK
|
||||
channel0\initial_pin_state=2
|
||||
channel0\name=CLK
|
||||
channel1\assigned_signal_name=MISO
|
||||
channel1\initial_pin_state=2
|
||||
channel1\name=MISO
|
||||
channel2\assigned_signal_name=MOSI
|
||||
channel2\initial_pin_state=2
|
||||
channel2\name=MOSI
|
||||
channel3\assigned_signal_name=CE1
|
||||
channel3\initial_pin_state=2
|
||||
channel3\name=CS#
|
||||
channels=4
|
||||
color=4279638298
|
||||
conv_options=0
|
||||
conversion_type=0
|
||||
decoder0\ann_class0\visible=true
|
||||
decoder0\ann_class1\visible=true
|
||||
decoder0\ann_class2\visible=true
|
||||
decoder0\ann_class3\visible=true
|
||||
decoder0\ann_class4\visible=true
|
||||
decoder0\ann_class5\visible=true
|
||||
decoder0\ann_class6\visible=true
|
||||
decoder0\id=spi
|
||||
decoder0\options=0
|
||||
decoder0\row0\visible=true
|
||||
decoder0\row1\visible=true
|
||||
decoder0\row2\visible=true
|
||||
decoder0\row3\visible=true
|
||||
decoder0\row4\visible=true
|
||||
decoder0\row5\visible=true
|
||||
decoder0\row6\visible=true
|
||||
decoder0\visible=true
|
||||
decoders=1
|
||||
enabled=true
|
||||
name=SPI1
|
||||
|
||||
[view0]
|
||||
D0\trace_height=38
|
||||
D1\trace_height=38
|
||||
D2\trace_height=38
|
||||
D3\trace_height=38
|
||||
D4\trace_height=38
|
||||
D5\trace_height=38
|
||||
D6\trace_height=38
|
||||
D7\trace_height=38
|
||||
offset=22 serialization::archive 19 0 0 0 0 52315583 48568089 25582163 47181659 91047901 0 -8 1 0 6
|
||||
scale=0.0021854614351496547
|
||||
segment_display_mode=1
|
||||
splitter_state=@ByteArray(\0\0\0\xff\0\0\0\x1\0\0\0\x2\0\0\0Z\0\0\x5\xa2\x1\0\0\0\x1\x1\0\0\0\x1\0)
|
||||
v_offset=-10
|
||||
zero_offset=22 serialization::archive 19 0 0 0 0 0 0 0 0 0 0 0 0 0 6
|
||||
Reference in New Issue
Block a user