Squashed commit of the following:

commit c6fd825e39
Author: AlexanderHD27 <alexander@hal>
Date:   Wed Nov 6 23:14:14 2024 +0100

    Moved CAN Interface code to comment libary folder with symlink

commit e7a0035041
Author: AlexanderHD27 <alexander@hal>
Date:   Wed Nov 6 22:01:28 2024 +0100

    Got MCP2521 to work

commit 4bfb1f533e
Author: AlexanderHD27 <alexander@hal>
Date:   Wed Oct 16 21:29:35 2024 +0200

    Did something to YGantryMount. It works. trust me

commit 5683168a47
Author: AlexanderHD27 <alexander@hal>
Date:   Wed Oct 16 21:28:36 2024 +0200

    Implemented Command-Level Interaction with CAN Interface

commit 9c0c676be8
Author: AlexanderHD27 <alexander@hal>
Date:   Mon Oct 14 09:20:37 2024 +0200

    Added Vscode Profile file

commit b150a905a3
Author: AlexanderHD27 <alexander@hal>
Date:   Mon Oct 14 09:19:00 2024 +0200

    Implemented Low Level Compunications

commit 7eebf619ae
Author: AlexanderHD27 <alexander@hal>
Date:   Mon Oct 7 14:46:15 2024 +0200

    Created Head Pipe Mount

commit 93c40e1805
Author: AlexanderHD27 <alexander@hal>
Date:   Mon Oct 7 14:44:11 2024 +0200

    First Revision of YGantryMount

commit 91c2125458
Author: AlexanderHD27 <alexander@hal>
Date:   Thu Oct 3 19:52:37 2024 +0200

    Added Kicad Backups 2 gitignore

commit 096a6c18d6
Author: AlexanderHD27 <alexander@hal>
Date:   Thu Oct 3 19:49:21 2024 +0200

    Created ESP-IDF for can-interface

commit 48fded7981
Author: AlexanderHD27 <alexander@hal>
Date:   Sat Sep 28 19:54:29 2024 +0200

    Added files from Pico sdk to gitignore

commit ec5e5cbf13
Author: AlexanderHD27 <alexander@hal>
Date:   Sat Sep 14 21:09:50 2024 +0200

    Create Marker for position Calibration

commit 58d31964b2
Author: AlexanderHD27 <alexander@hal>
Date:   Wed Sep 11 23:32:55 2024 +0200

    Upgrade to pico SDK 2.0.0
This commit is contained in:
AlexanderHD27
2024-11-06 23:18:12 +01:00
parent f002a01308
commit e091d4df18
49 changed files with 3905 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
#include "mcp2521_hardware_handle.hpp"
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "mcp2521_hardware_esp.hpp"
static void IRAM_ATTR gpio_isr_can_handler(void* arg) {
MCP2521_Hardware_Handle_ESP * handle = (MCP2521_Hardware_Handle_ESP *)arg;
handle->isr_can_interrupt();
}
static void handleInteruptTaskCallerFn(void *arg) {
MCP2521_Hardware_Handle_ESP * handle = (MCP2521_Hardware_Handle_ESP *)arg;
handle->handleIntteruptTaskFn();
}
void MCP2521_Hardware_Handle_ESP::initPins(
gpio_num_t int_pin
) {
canInterruptSemaphore = xSemaphoreCreateBinary();
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_NEGEDGE;
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);
gpio_install_isr_service(0);
gpio_isr_handler_add(int_pin, gpio_isr_can_handler, this);
xTaskCreate(
(TaskFunction_t)&handleInteruptTaskCallerFn,
"canInterruptTask",
2048,
this,
5,
&canInterruptTaskHandle
);
}
void MCP2521_Hardware_Handle_ESP::handleIntteruptTaskFn() {
while(true) {
xSemaphoreTake(canInterruptSemaphore, portMAX_DELAY);
intHandler(intHandlerArg);
}
}
void MCP2521_Hardware_Handle_ESP::isr_can_interrupt() {
BaseType_t wokenTask = pdFALSE;
xSemaphoreGiveFromISR(canInterruptSemaphore, &wokenTask);
if(wokenTask) {
portYIELD_FROM_ISR();
}
}
void MCP2521_Hardware_Handle_ESP::registerIntHandler(intHandlerFunction_t handler, void * arg) {
intHandlerArg = arg;
intHandler = handler;
}
#endif