Implement Multi-Bus CAN Interfaces
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/24.7.17 Chrome/128.0.6613.36 Electron/32.0.1 Safari/537.36" version="24.7.17">
|
||||
<diagram name="Page-1" id="FmQN2vLuPXQQGOlHbBG4">
|
||||
<mxGraphModel dx="1195" dy="698" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-21" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.75;entryY=0;entryDx=0;entryDy=0;endArrow=diamondThin;endFill=0;" edge="1" parent="1" source="xzzxaMGRirp7Gwq30BhV-1" target="xzzxaMGRirp7Gwq30BhV-18">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-1" value="«interface»<br><font face="Courier New"><b>I_MCP2521_</b><b>HardwareHandle</b></font>" style="html=1;whiteSpace=wrap;" vertex="1" parent="1">
|
||||
<mxGeometry x="520" y="120" width="200" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-9" value="<b><font face="Courier New">MCP2521_HardwareHandle_ESP</font></b>" style="html=1;whiteSpace=wrap;" vertex="1" parent="1">
|
||||
<mxGeometry x="230" y="260" width="250" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-11" value="<b><font face="Courier New">HardwareHandle_ESPBus</font></b>" style="html=1;whiteSpace=wrap;" vertex="1" parent="1">
|
||||
<mxGeometry x="230" y="200" width="250" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-12" value="" style="endArrow=none;dashed=1;html=1;rounded=0;exitX=1;exitY=1;exitDx=0;exitDy=0;strokeWidth=1;dashPattern=1 1;" edge="1" parent="1" source="xzzxaMGRirp7Gwq30BhV-14">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="1060" y="320" as="sourcePoint" />
|
||||
<mxPoint x="120" y="320" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-14" value="SPI - Hardware Level" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="760" y="280" width="160" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-15" value="" style="endArrow=block;html=1;rounded=0;dashed=1;endFill=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.25;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="xzzxaMGRirp7Gwq30BhV-11" target="xzzxaMGRirp7Gwq30BhV-1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="590" y="290" as="sourcePoint" />
|
||||
<mxPoint x="640" y="240" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="570" y="220" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-16" value="" style="endArrow=block;html=1;rounded=0;dashed=1;endFill=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="xzzxaMGRirp7Gwq30BhV-9" target="xzzxaMGRirp7Gwq30BhV-1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="520" y="280" as="sourcePoint" />
|
||||
<mxPoint x="580" y="250" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="620" y="280" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-17" value="MCP2521 - Device Level" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="760" y="388" width="160" height="32" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-18" value="<b><font face="Courier New">MCP2521_CommandInterface</font></b>" style="html=1;whiteSpace=wrap;" vertex="1" parent="1">
|
||||
<mxGeometry x="520" y="340" width="200" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-19" value="<b>MCP2521</b>" style="html=1;whiteSpace=wrap;" vertex="1" parent="1">
|
||||
<mxGeometry x="520" y="420" width="200" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-20" value="" style="endArrow=block;html=1;rounded=0;endFill=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="xzzxaMGRirp7Gwq30BhV-19" target="xzzxaMGRirp7Gwq30BhV-18">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="670" y="544" as="sourcePoint" />
|
||||
<mxPoint x="720" y="494" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-23" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.746;entryY=0.064;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="xzzxaMGRirp7Gwq30BhV-22" target="xzzxaMGRirp7Gwq30BhV-11">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-24" value="creates" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="xzzxaMGRirp7Gwq30BhV-23">
|
||||
<mxGeometry x="-0.3135" y="1" relative="1" as="geometry">
|
||||
<mxPoint x="16" y="1" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-22" value="<b><font face="Courier New">MCP2421_HardwareHandleFactory_ESPBus</font></b>" style="html=1;whiteSpace=wrap;" vertex="1" parent="1">
|
||||
<mxGeometry x="180" y="120" width="300" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-25" value="" style="endArrow=none;dashed=1;html=1;rounded=0;exitX=1;exitY=1;exitDx=0;exitDy=0;strokeWidth=1;dashPattern=1 1;" edge="1" parent="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="920" y="480" as="sourcePoint" />
|
||||
<mxPoint x="120" y="480" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-26" value="Network Stack" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
|
||||
<mxGeometry x="760" y="480" width="160" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-27" value="<b>Socket_CANTP</b>" style="html=1;whiteSpace=wrap;" vertex="1" parent="1">
|
||||
<mxGeometry x="520" y="500" width="200" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-28" value="<b>Socket_GoBotRPC</b>" style="html=1;whiteSpace=wrap;" vertex="1" parent="1">
|
||||
<mxGeometry x="520" y="580" width="200" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-29" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;endArrow=diamondThin;endFill=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" target="xzzxaMGRirp7Gwq30BhV-27">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="619.76" y="460" as="sourcePoint" />
|
||||
<mxPoint x="640" y="520" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-30" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;endArrow=diamondThin;endFill=0;" edge="1" parent="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="619.5799999999999" y="540" as="sourcePoint" />
|
||||
<mxPoint x="619.9699999999999" y="580" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
102
common-libaries/mcp2521/docs/MCP2521_Libary_ClassDiagram.drawio
Normal file
102
common-libaries/mcp2521/docs/MCP2521_Libary_ClassDiagram.drawio
Normal file
@@ -0,0 +1,102 @@
|
||||
<mxfile host="Electron" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/24.7.17 Chrome/128.0.6613.36 Electron/32.0.1 Safari/537.36" version="24.7.17">
|
||||
<diagram name="Page-1" id="FmQN2vLuPXQQGOlHbBG4">
|
||||
<mxGraphModel dx="1434" dy="838" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-21" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.75;entryY=0;entryDx=0;entryDy=0;endArrow=diamondThin;endFill=0;" parent="1" source="xzzxaMGRirp7Gwq30BhV-1" target="xzzxaMGRirp7Gwq30BhV-18" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-1" value="«interface»<br><font face="Courier New"><b>I_MCP2521_</b><b>HardwareHandle</b></font>" style="html=1;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="520" y="120" width="200" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-9" value="<b><font face="Courier New">MCP2521_HardwareHandle_ESP</font></b>" style="html=1;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="230" y="260" width="250" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-11" value="<b><font face="Courier New">MCP2521_</font></b><b><font face="Courier New">HardwareHandle_ESPBus</font></b>" style="html=1;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="230" y="200" width="250" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-12" value="" style="endArrow=none;dashed=1;html=1;rounded=0;exitX=1;exitY=1;exitDx=0;exitDy=0;strokeWidth=1;dashPattern=1 1;" parent="1" source="xzzxaMGRirp7Gwq30BhV-14" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="1060" y="320" as="sourcePoint" />
|
||||
<mxPoint x="120" y="320" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-14" value="SPI - Hardware Level" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="760" y="280" width="160" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-15" value="" style="endArrow=block;html=1;rounded=0;dashed=1;endFill=0;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0.25;entryY=1;entryDx=0;entryDy=0;" parent="1" source="xzzxaMGRirp7Gwq30BhV-11" target="xzzxaMGRirp7Gwq30BhV-1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="590" y="290" as="sourcePoint" />
|
||||
<mxPoint x="640" y="240" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="570" y="220" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-16" value="" style="endArrow=block;html=1;rounded=0;dashed=1;endFill=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="xzzxaMGRirp7Gwq30BhV-9" target="xzzxaMGRirp7Gwq30BhV-1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="520" y="280" as="sourcePoint" />
|
||||
<mxPoint x="580" y="250" as="targetPoint" />
|
||||
<Array as="points">
|
||||
<mxPoint x="620" y="280" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-17" value="MCP2521 - Device Level" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="760" y="388" width="160" height="32" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-18" value="<b><font face="Courier New">MCP2521_CommandInterface</font></b>" style="html=1;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="520" y="340" width="200" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-19" value="<b>MCP2521</b>" style="html=1;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="520" y="420" width="200" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-20" value="" style="endArrow=block;html=1;rounded=0;endFill=0;exitX=0.5;exitY=0;exitDx=0;exitDy=0;entryX=0.5;entryY=1;entryDx=0;entryDy=0;" parent="1" source="xzzxaMGRirp7Gwq30BhV-19" target="xzzxaMGRirp7Gwq30BhV-18" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="670" y="544" as="sourcePoint" />
|
||||
<mxPoint x="720" y="494" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-23" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.746;entryY=0.064;entryDx=0;entryDy=0;entryPerimeter=0;" parent="1" source="xzzxaMGRirp7Gwq30BhV-22" target="xzzxaMGRirp7Gwq30BhV-11" edge="1">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-24" value="creates" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" parent="xzzxaMGRirp7Gwq30BhV-23" vertex="1" connectable="0">
|
||||
<mxGeometry x="-0.3135" y="1" relative="1" as="geometry">
|
||||
<mxPoint x="16" y="1" as="offset" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-22" value="<b><font face="Courier New">MCP2521_HardwareHandleFactory_ESPBus</font></b>" style="html=1;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="180" y="120" width="300" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-25" value="" style="endArrow=none;dashed=1;html=1;rounded=0;exitX=1;exitY=1;exitDx=0;exitDy=0;strokeWidth=1;dashPattern=1 1;" parent="1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="920" y="480" as="sourcePoint" />
|
||||
<mxPoint x="120" y="480" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-26" value="Network Stack" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" parent="1" vertex="1">
|
||||
<mxGeometry x="760" y="480" width="160" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-27" value="<b>Socket_CANTP</b>" style="html=1;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="520" y="500" width="200" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-28" value="<b>Socket_GoBotRPC</b>" style="html=1;whiteSpace=wrap;" parent="1" vertex="1">
|
||||
<mxGeometry x="520" y="580" width="200" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-29" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;endArrow=diamondThin;endFill=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" target="xzzxaMGRirp7Gwq30BhV-27" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="619.76" y="460" as="sourcePoint" />
|
||||
<mxPoint x="640" y="520" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="xzzxaMGRirp7Gwq30BhV-30" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.75;exitY=1;exitDx=0;exitDy=0;endArrow=diamondThin;endFill=0;" parent="1" edge="1">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="619.5799999999999" y="540" as="sourcePoint" />
|
||||
<mxPoint x="619.9699999999999" y="580" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
@@ -3,4 +3,5 @@
|
||||
#include "mcp2521_toplevel.hpp"
|
||||
#include "mcp2521_command.hpp"
|
||||
#include "mcp2521_hardware_esp.hpp"
|
||||
#include "mcp2521_hardware_esp_bus_factory.hpp"
|
||||
#include "mcp2521_addresses.hpp"
|
||||
@@ -40,9 +40,9 @@ struct rx_info {
|
||||
uint8_t length;
|
||||
};
|
||||
|
||||
class MCP2521_Command_Interface {
|
||||
class MCP2521_CommandInterface {
|
||||
private:
|
||||
MCP2521_Hardware_Handle * hardware_handle;
|
||||
I_MCP2521_HardwareHandle * hardware_handle;
|
||||
|
||||
intHandlerFunction_t rx0_handler;
|
||||
intHandlerFunction_t rx1_handler;
|
||||
@@ -63,8 +63,8 @@ private:
|
||||
void * message_error_handler_arg;
|
||||
public:
|
||||
|
||||
MCP2521_Command_Interface(
|
||||
MCP2521_Hardware_Handle * hardware_handle
|
||||
MCP2521_CommandInterface(
|
||||
I_MCP2521_HardwareHandle * hardware_handle
|
||||
);
|
||||
|
||||
void handleInterrupt();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "mcp2521_command.hpp"
|
||||
#include "mcp2521_addresses.hpp"
|
||||
|
||||
class MCP2521 : public MCP2521_Command_Interface {
|
||||
class MCP2521 : public MCP2521_CommandInterface {
|
||||
private:
|
||||
public:
|
||||
void set_tx_id(MCP2521_TX_BUFFER buffer, uint16_t id, bool extended);
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
#include "mcp2521_addresses.hpp"
|
||||
|
||||
void runIntHandler(void *arg) {
|
||||
MCP2521_Command_Interface *command_interface = (MCP2521_Command_Interface *)arg;
|
||||
MCP2521_CommandInterface *command_interface = (MCP2521_CommandInterface *)arg;
|
||||
command_interface->handleInterrupt();
|
||||
}
|
||||
|
||||
MCP2521_Command_Interface::MCP2521_Command_Interface(
|
||||
MCP2521_Hardware_Handle * hardware_handle
|
||||
MCP2521_CommandInterface::MCP2521_CommandInterface(
|
||||
I_MCP2521_HardwareHandle * hardware_handle
|
||||
) {
|
||||
this->hardware_handle = hardware_handle;
|
||||
this->hardware_handle->registerIntHandler(runIntHandler, (void *)this);
|
||||
@@ -33,42 +33,42 @@ MCP2521_Command_Interface::MCP2521_Command_Interface(
|
||||
message_error_handler_arg = NULL;
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::reset() {
|
||||
void MCP2521_CommandInterface::reset() {
|
||||
hardware_handle->execute(MCP2521_OP_RESET);
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::read_reg(uint8_t address, uint8_t *data, size_t length) {
|
||||
void MCP2521_CommandInterface::read_reg(uint8_t address, uint8_t *data, size_t length) {
|
||||
hardware_handle->read(MCP2521_OP_READ, data, length, address);
|
||||
}
|
||||
|
||||
uint8_t MCP2521_Command_Interface::read_reg(uint8_t address) {
|
||||
uint8_t MCP2521_CommandInterface::read_reg(uint8_t address) {
|
||||
return hardware_handle->read(MCP2521_OP_READ, address);
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::read_rx_buf(MCP2521_RX_BUFFER buffer, MCP2521_BUFFER_TYPE type, uint8_t *data, size_t length) {
|
||||
void MCP2521_CommandInterface::read_rx_buf(MCP2521_RX_BUFFER buffer, MCP2521_BUFFER_TYPE type, uint8_t *data, size_t length) {
|
||||
uint8_t address = (buffer << 1) | (type << 2);
|
||||
hardware_handle->read(MCP2521_OP_READ_RX_BUFFER | address, data, length);
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::write_reg(uint8_t address, uint8_t *data, size_t length) {
|
||||
void MCP2521_CommandInterface::write_reg(uint8_t address, uint8_t *data, size_t length) {
|
||||
hardware_handle->write(MCP2521_OP_WRITE, data, length, address);
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::write_reg(uint8_t address, uint8_t data) {
|
||||
void MCP2521_CommandInterface::write_reg(uint8_t address, uint8_t data) {
|
||||
hardware_handle->write(MCP2521_OP_WRITE, data, address);
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::write_tx_buf(MCP2521_TX_BUFFER buffer, MCP2521_BUFFER_TYPE type, uint8_t *data, size_t length) {
|
||||
void MCP2521_CommandInterface::write_tx_buf(MCP2521_TX_BUFFER buffer, MCP2521_BUFFER_TYPE type, uint8_t *data, size_t length) {
|
||||
uint8_t address = (buffer << 1) | (type);
|
||||
hardware_handle->write(MCP2521_OP_LOAD_TX_BUFFER | address, data, length);
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::request_to_send(bool txb2, bool txb1, bool txb0) {
|
||||
void MCP2521_CommandInterface::request_to_send(bool txb2, bool txb1, bool txb0) {
|
||||
uint8_t data = (txb2 << 2) | (txb1 << 1) | txb0;
|
||||
hardware_handle->execute(MCP2521_OP_RTS | data);
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::request_to_send(MCP2521_TX_BUFFER buffer) {
|
||||
void MCP2521_CommandInterface::request_to_send(MCP2521_TX_BUFFER buffer) {
|
||||
uint8_t mask = 0;
|
||||
|
||||
switch (buffer) {
|
||||
@@ -86,15 +86,15 @@ void MCP2521_Command_Interface::request_to_send(MCP2521_TX_BUFFER buffer) {
|
||||
hardware_handle->execute(MCP2521_OP_RTS | mask);
|
||||
}
|
||||
|
||||
uint8_t MCP2521_Command_Interface::read_status() {
|
||||
uint8_t MCP2521_CommandInterface::read_status() {
|
||||
return hardware_handle->read(MCP2521_OP_READ_STATUS);
|
||||
}
|
||||
|
||||
uint8_t MCP2521_Command_Interface::read_rx_status() {
|
||||
uint8_t MCP2521_CommandInterface::read_rx_status() {
|
||||
return hardware_handle->read(MCP2521_OP_RX_STATUS);
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::bit_modify(uint8_t address, uint8_t mask, uint8_t data) {
|
||||
void MCP2521_CommandInterface::bit_modify(uint8_t address, uint8_t mask, uint8_t data) {
|
||||
uint8_t data_array[3] = {address, mask, data};
|
||||
hardware_handle->write(MCP2521_OP_BIT_MODIFY, data_array, 3);
|
||||
}
|
||||
@@ -1,47 +1,47 @@
|
||||
#include "mcp2521.hpp"
|
||||
#include "mcp2521_addresses.hpp"
|
||||
|
||||
void MCP2521_Command_Interface::register_rx0_handler(intHandlerFunction_t handler, void* args) {
|
||||
void MCP2521_CommandInterface::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) {
|
||||
void MCP2521_CommandInterface::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) {
|
||||
void MCP2521_CommandInterface::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) {
|
||||
void MCP2521_CommandInterface::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) {
|
||||
void MCP2521_CommandInterface::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) {
|
||||
void MCP2521_CommandInterface::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) {
|
||||
void MCP2521_CommandInterface::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) {
|
||||
void MCP2521_CommandInterface::register_message_error_handler(intHandlerFunction_t handler, void* args) {
|
||||
message_error_handler = handler;
|
||||
message_error_handler_arg = args;
|
||||
}
|
||||
|
||||
void MCP2521_Command_Interface::handleInterrupt() {
|
||||
void MCP2521_CommandInterface::handleInterrupt() {
|
||||
uint8_t flags = read_reg(MCP2521_CANINTF);
|
||||
uint8_t clearBits = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user