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:
113
common-libaries/mcp2521/interface_interrupts.cpp
Normal file
113
common-libaries/mcp2521/interface_interrupts.cpp
Normal file
@@ -0,0 +1,113 @@
|
||||
#include "mcp2521.hpp"
|
||||
#include "mcp2521_addresses.hpp"
|
||||
|
||||
void MCP2521_Command_Interface::register_rx0_handler(intHandlerFunction_t handler, void* args) {
|
||||
rx0_handler = handler;
|
||||
rx0_handler_arg = args;
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::register_rx1_handler(intHandlerFunction_t handler, void* args) {
|
||||
rx1_handler = handler;
|
||||
rx1_handler_arg = args;
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::register_tx0_handler(intHandlerFunction_t handler, void* args) {
|
||||
tx0_handler = handler;
|
||||
tx0_handler_arg = args;
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::register_tx1_handler(intHandlerFunction_t handler, void* args) {
|
||||
tx1_handler = handler;
|
||||
tx1_handler_arg = args;
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::register_tx2_handler(intHandlerFunction_t handler, void* args) {
|
||||
tx2_handler = handler;
|
||||
tx2_handler_arg = args;
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::register_error_handler(intHandlerFunction_t handler, void* args) {
|
||||
error_handler = handler;
|
||||
error_handler_arg = args;
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::register_wakeup_handler(intHandlerFunction_t handler, void* args) {
|
||||
wakeup_handler = handler;
|
||||
wakeup_handler_arg = args;
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::register_message_error_handler(intHandlerFunction_t handler, void* args) {
|
||||
message_error_handler = handler;
|
||||
message_error_handler_arg = args;
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::handleInterrupt() {
|
||||
uint8_t flags = read_reg(MCP2521_CANINTF);
|
||||
uint8_t clearBits = 0;
|
||||
|
||||
if (flags & MCP2521_CANINTF_RX0IF) {
|
||||
if (rx0_handler) {
|
||||
rx0_handler(rx0_handler_arg);
|
||||
}
|
||||
flags &= ~MCP2521_CANINTF_RX0IF;
|
||||
clearBits |= MCP2521_CANINTF_RX0IF;
|
||||
}
|
||||
|
||||
if (flags & MCP2521_CANINTF_RX1IF) {
|
||||
if (rx1_handler) {
|
||||
rx1_handler(rx1_handler_arg);
|
||||
}
|
||||
flags &= ~MCP2521_CANINTF_RX1IF;
|
||||
clearBits |= MCP2521_CANINTF_RX1IF;
|
||||
}
|
||||
|
||||
if (flags & MCP2521_CANINTF_TX0IF) {
|
||||
if (tx0_handler) {
|
||||
tx0_handler(tx0_handler_arg);
|
||||
}
|
||||
flags &= ~MCP2521_CANINTF_TX0IF;
|
||||
clearBits |= MCP2521_CANINTF_TX0IF;
|
||||
}
|
||||
|
||||
if (flags & MCP2521_CANINTF_TX1IF) {
|
||||
if (tx1_handler) {
|
||||
tx1_handler(tx1_handler_arg);
|
||||
}
|
||||
flags &= ~MCP2521_CANINTF_TX1IF;
|
||||
clearBits |= MCP2521_CANINTF_TX1IF;
|
||||
}
|
||||
|
||||
if (flags & MCP2521_CANINTF_TX2IF) {
|
||||
if (tx2_handler) {
|
||||
tx2_handler(tx2_handler_arg);
|
||||
}
|
||||
flags &= ~MCP2521_CANINTF_TX2IF;
|
||||
clearBits |= MCP2521_CANINTF_TX2IF;
|
||||
}
|
||||
|
||||
if (flags & MCP2521_CANINTF_ERRIF) {
|
||||
if (error_handler) {
|
||||
error_handler(error_handler_arg);
|
||||
}
|
||||
flags &= ~MCP2521_CANINTF_ERRIF;
|
||||
clearBits |= MCP2521_CANINTF_ERRIF;
|
||||
}
|
||||
|
||||
if (flags & MCP2521_CANINTF_WAKIF) {
|
||||
if (wakeup_handler) {
|
||||
wakeup_handler(wakeup_handler_arg);
|
||||
}
|
||||
flags &= ~MCP2521_CANINTF_WAKIF;
|
||||
clearBits |= MCP2521_CANINTF_WAKIF;
|
||||
}
|
||||
|
||||
if (flags & MCP2521_CANINTF_MERRF) {
|
||||
if (message_error_handler) {
|
||||
message_error_handler(message_error_handler_arg);
|
||||
}
|
||||
flags &= ~MCP2521_CANINTF_MERRF;
|
||||
clearBits |= MCP2521_CANINTF_MERRF;
|
||||
}
|
||||
|
||||
bit_modify(MCP2521_CANINTF, clearBits, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user