Compare commits
9 Commits
rpi-fan-co
...
9c0c676be8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c0c676be8 | ||
|
|
b150a905a3 | ||
|
|
7eebf619ae | ||
|
|
93c40e1805 | ||
|
|
91c2125458 | ||
|
|
096a6c18d6 | ||
|
|
48fded7981 | ||
|
|
ec5e5cbf13 | ||
|
|
58d31964b2 |
BIN
.gitignore
(Stored with Git LFS)
vendored
BIN
.gitignore
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
3d-print/models/BoardPositionMarker/Vison Marker Clip - Marker.stl
(Stored with Git LFS)
Normal file
BIN
3d-print/models/BoardPositionMarker/Vison Marker Clip - Marker.stl
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
3d-print/models/BoardPositionMarker/Vison Marker Clip - WhiteRing1.stl
(Stored with Git LFS)
Normal file
BIN
3d-print/models/BoardPositionMarker/Vison Marker Clip - WhiteRing1.stl
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
3d-print/models/BoardPositionMarker/Vison Marker Clip - WhiteRing2.stl
(Stored with Git LFS)
Normal file
BIN
3d-print/models/BoardPositionMarker/Vison Marker Clip - WhiteRing2.stl
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
3d-print/models/HeadPipeMount/HeadPipeMount - DownPart.stl
Normal file
BIN
3d-print/models/HeadPipeMount/HeadPipeMount - DownPart.stl
Normal file
Binary file not shown.
BIN
3d-print/models/HeadPipeMount/HeadPipeMount - HoseAdapter.stl
Normal file
BIN
3d-print/models/HeadPipeMount/HeadPipeMount - HoseAdapter.stl
Normal file
Binary file not shown.
BIN
3d-print/models/HeadPipeMount/HeadPipeMount - RightPart.stl
Normal file
BIN
3d-print/models/HeadPipeMount/HeadPipeMount - RightPart.stl
Normal file
Binary file not shown.
BIN
3d-print/models/YGantryMount/GantryMount - GantryPlate (1).stl
Normal file
BIN
3d-print/models/YGantryMount/GantryMount - GantryPlate (1).stl
Normal file
Binary file not shown.
BIN
3d-print/models/YGantryMount/GantryMount - GantryPlate.stl
Normal file
BIN
3d-print/models/YGantryMount/GantryMount - GantryPlate.stl
Normal file
Binary file not shown.
BIN
3d-print/models/YGantryMount/GantryMount - Mount (1).stl
Normal file
BIN
3d-print/models/YGantryMount/GantryMount - Mount (1).stl
Normal file
Binary file not shown.
BIN
3d-print/models/YGantryMount/GantryMount - Mount.stl
Normal file
BIN
3d-print/models/YGantryMount/GantryMount - Mount.stl
Normal file
Binary file not shown.
BIN
3d-print/slicers/BoardPositionMarker.3mf
(Stored with Git LFS)
Normal file
BIN
3d-print/slicers/BoardPositionMarker.3mf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
3d-print/slicers/YGantryMount.3mf
Normal file
BIN
3d-print/slicers/YGantryMount.3mf
Normal file
Binary file not shown.
47
can-interface/.devcontainer/Dockerfile
Normal file
47
can-interface/.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
FROM espressif/idf
|
||||||
|
|
||||||
|
ARG DEBIAN_FRONTEND=nointeractive
|
||||||
|
ARG CONTAINER_USER=esp
|
||||||
|
ARG USER_UID=1050
|
||||||
|
ARG USER_GID=$USER_UID
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt install -y -q \
|
||||||
|
cmake \
|
||||||
|
git \
|
||||||
|
libglib2.0-0 \
|
||||||
|
libnuma1 \
|
||||||
|
libpixman-1-0 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# QEMU
|
||||||
|
ENV QEMU_REL=esp_develop_8.2.0_20240122
|
||||||
|
ENV QEMU_SHA256=e7c72ef5705ad1444d391711088c8717fc89f42e9bf6d1487f9c2a326b8cfa83
|
||||||
|
ENV QEMU_DIST=qemu-xtensa-softmmu-${QEMU_REL}-x86_64-linux-gnu.tar.xz
|
||||||
|
ENV QEMU_URL=https://github.com/espressif/qemu/releases/download/esp-develop-8.2.0-20240122/${QEMU_DIST}
|
||||||
|
|
||||||
|
ENV LC_ALL=C.UTF-8
|
||||||
|
ENV LANG=C.UTF-8
|
||||||
|
|
||||||
|
RUN wget --no-verbose ${QEMU_URL} \
|
||||||
|
&& echo "${QEMU_SHA256} *${QEMU_DIST}" | sha256sum --check --strict - \
|
||||||
|
&& tar -xf $QEMU_DIST -C /opt \
|
||||||
|
&& rm ${QEMU_DIST}
|
||||||
|
|
||||||
|
ENV PATH=/opt/qemu/bin:${PATH}
|
||||||
|
|
||||||
|
RUN groupadd --gid $USER_GID $CONTAINER_USER \
|
||||||
|
&& adduser --uid $USER_UID --gid $USER_GID --disabled-password --gecos "" ${CONTAINER_USER} \
|
||||||
|
&& usermod -a -G root $CONTAINER_USER && usermod -a -G dialout $CONTAINER_USER
|
||||||
|
|
||||||
|
RUN chmod -R 775 /opt/esp/python_env/
|
||||||
|
|
||||||
|
USER ${CONTAINER_USER}
|
||||||
|
ENV USER=${CONTAINER_USER}
|
||||||
|
WORKDIR /home/${CONTAINER_USER}
|
||||||
|
|
||||||
|
RUN echo "source /opt/esp/idf/export.sh > /dev/null 2>&1" >> ~/.bashrc
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/opt/esp/entrypoint.sh" ]
|
||||||
|
|
||||||
|
CMD ["/bin/bash", "-c"]
|
||||||
36
can-interface/.devcontainer/devcontainer.json
Normal file
36
can-interface/.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "ESP-IDF QEMU",
|
||||||
|
"build": {
|
||||||
|
"dockerfile": "Dockerfile"
|
||||||
|
},
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"settings": {
|
||||||
|
"terminal.integrated.defaultProfile.linux": "bash",
|
||||||
|
"idf.espIdfPath": "/opt/esp/idf",
|
||||||
|
"idf.customExtraPaths": "",
|
||||||
|
"idf.pythonBinPath": "/opt/esp/python_env/idf5.4_py3.12_env/bin/python",
|
||||||
|
"idf.toolsPath": "/opt/esp",
|
||||||
|
"idf.gitPath": "/usr/bin/git"
|
||||||
|
},
|
||||||
|
"extensions": [
|
||||||
|
"espressif.esp-idf-extension"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"codespaces": {
|
||||||
|
"settings": {
|
||||||
|
"terminal.integrated.defaultProfile.linux": "bash",
|
||||||
|
"idf.espIdfPath": "/opt/esp/idf",
|
||||||
|
"idf.customExtraPaths": "",
|
||||||
|
"idf.pythonBinPath": "/opt/esp/python_env/idf5.4_py3.12_env/bin/python",
|
||||||
|
"idf.toolsPath": "/opt/esp",
|
||||||
|
"idf.gitPath": "/usr/bin/git"
|
||||||
|
},
|
||||||
|
"extensions": [
|
||||||
|
"espressif.esp-idf-extension",
|
||||||
|
"espressif.esp-idf-web"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"runArgs": ["--privileged"]
|
||||||
|
}
|
||||||
BIN
can-interface/.gitignore
(Stored with Git LFS)
vendored
Normal file
BIN
can-interface/.gitignore
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
23
can-interface/.vscode/c_cpp_properties.json
vendored
Normal file
23
can-interface/.vscode/c_cpp_properties.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "ESP-IDF",
|
||||||
|
"compilerPath": "${config:idf.toolsPath}/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc",
|
||||||
|
"compileCommands": "${config:idf.buildPath}/compile_commands.json",
|
||||||
|
"includePath": [
|
||||||
|
"${config:idf.espIdfPath}/components/**",
|
||||||
|
"${config:idf.espIdfPathWin}/components/**",
|
||||||
|
"${workspaceFolder}/**"
|
||||||
|
],
|
||||||
|
"browse": {
|
||||||
|
"path": [
|
||||||
|
"${config:idf.espIdfPath}/components",
|
||||||
|
"${config:idf.espIdfPathWin}/components",
|
||||||
|
"${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"limitSymbolsToIncludedHeaders": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
15
can-interface/.vscode/launch.json
vendored
Normal file
15
can-interface/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "gdbtarget",
|
||||||
|
"request": "attach",
|
||||||
|
"name": "Eclipse CDT GDB Adapter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "espidf",
|
||||||
|
"name": "Launch",
|
||||||
|
"request": "launch"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
17
can-interface/.vscode/settings.json
vendored
Normal file
17
can-interface/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"C_Cpp.intelliSenseEngine": "default",
|
||||||
|
"idf.adapterTargetName": "esp32",
|
||||||
|
"idf.customExtraPaths": "/home/alexander/.espressif/tools/xtensa-esp-elf-gdb/14.2_20240403/xtensa-esp-elf-gdb/bin:/home/alexander/.espressif/tools/riscv32-esp-elf-gdb/14.2_20240403/riscv32-esp-elf-gdb/bin:/home/alexander/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin:/home/alexander/.espressif/tools/riscv32-esp-elf/esp-13.2.0_20240530/riscv32-esp-elf/bin:/home/alexander/.espressif/tools/esp32ulp-elf/2.38_20240113/esp32ulp-elf/bin:/home/alexander/.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/bin:/home/alexander/.espressif/tools/ninja/1.11.1:/home/alexander/.espressif/tools/esp-rom-elfs/20240305",
|
||||||
|
"idf.customExtraVars": {
|
||||||
|
"OPENOCD_SCRIPTS": "/home/alexander/.espressif/tools/openocd-esp32/v0.12.0-esp32-20240318/openocd-esp32/share/openocd/scripts",
|
||||||
|
"ESP_ROM_ELF_DIR": "/home/alexander/.espressif/tools/esp-rom-elfs/20240305/"
|
||||||
|
},
|
||||||
|
"idf.espIdfPath": "/opt/esp/v5.3.1/esp-idf",
|
||||||
|
"idf.openOcdConfigs": [
|
||||||
|
"board/esp32-wrover-kit-3.3v.cfg"
|
||||||
|
],
|
||||||
|
"idf.port": "/dev/ttyUSB0",
|
||||||
|
"idf.pythonBinPath": "/home/alexander/.espressif/python_env/idf5.3_py3.12_env/bin/python",
|
||||||
|
"idf.toolsPath": "/home/alexander/.espressif",
|
||||||
|
"idf.flashType": "UART"
|
||||||
|
}
|
||||||
259
can-interface/.vscode/tasks.json
vendored
Normal file
259
can-interface/.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Build - Build project",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py build",
|
||||||
|
"windows": {
|
||||||
|
"command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py build",
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "cpp",
|
||||||
|
"fileLocation": [
|
||||||
|
"autoDetect",
|
||||||
|
"${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"pattern": {
|
||||||
|
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Set ESP-IDF Target",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "${command:espIdf.setTarget}",
|
||||||
|
"problemMatcher": {
|
||||||
|
"owner": "cpp",
|
||||||
|
"fileLocation": [
|
||||||
|
"autoDetect",
|
||||||
|
"${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"pattern": {
|
||||||
|
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Clean - Clean the project",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py fullclean",
|
||||||
|
"windows": {
|
||||||
|
"command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py fullclean",
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "cpp",
|
||||||
|
"fileLocation": [
|
||||||
|
"autoDetect",
|
||||||
|
"${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"pattern": {
|
||||||
|
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Flash - Flash the device",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py -p ${config:idf.port} -b ${config:idf.flashBaudRate} flash",
|
||||||
|
"windows": {
|
||||||
|
"command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py flash -p ${config:idf.portWin} -b ${config:idf.flashBaudRate}",
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "cpp",
|
||||||
|
"fileLocation": [
|
||||||
|
"autoDetect",
|
||||||
|
"${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"pattern": {
|
||||||
|
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Monitor: Start the monitor",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py -p ${config:idf.port} monitor",
|
||||||
|
"windows": {
|
||||||
|
"command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py -p ${config:idf.portWin} monitor",
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "cpp",
|
||||||
|
"fileLocation": [
|
||||||
|
"autoDetect",
|
||||||
|
"${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"pattern": {
|
||||||
|
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependsOn": "Flash - Flash the device"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "OpenOCD: Start openOCD",
|
||||||
|
"type": "shell",
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "never",
|
||||||
|
"focus": false,
|
||||||
|
"panel": "new"
|
||||||
|
},
|
||||||
|
"command": "openocd -s ${command:espIdf.getOpenOcdScriptValue} ${command:espIdf.getOpenOcdConfigs}",
|
||||||
|
"windows": {
|
||||||
|
"command": "openocd.exe -s ${command:espIdf.getOpenOcdScriptValue} ${command:espIdf.getOpenOcdConfigs}",
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"problemMatcher": {
|
||||||
|
"owner": "cpp",
|
||||||
|
"fileLocation": [
|
||||||
|
"autoDetect",
|
||||||
|
"${workspaceFolder}"
|
||||||
|
],
|
||||||
|
"pattern": {
|
||||||
|
"regexp": "^(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$",
|
||||||
|
"file": 1,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"message": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "adapter",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "${config:idf.pythonBinPath}",
|
||||||
|
"isBackground": true,
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH}:${config:idf.customExtraPaths}",
|
||||||
|
"PYTHONPATH": "${command:espIdf.getExtensionPath}/esp_debug_adapter/debug_adapter"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"problemMatcher": {
|
||||||
|
"background": {
|
||||||
|
"beginsPattern": "\bDEBUG_ADAPTER_STARTED\b",
|
||||||
|
"endsPattern": "DEBUG_ADAPTER_READY2CONNECT",
|
||||||
|
"activeOnStart": true
|
||||||
|
},
|
||||||
|
"pattern": {
|
||||||
|
"regexp": "(\\d+)-(\\d+)-(\\d+)\\s(\\d+):(\\d+):(\\d+),(\\d+)\\s-(.+)\\s(ERROR)",
|
||||||
|
"file": 8,
|
||||||
|
"line": 2,
|
||||||
|
"column": 3,
|
||||||
|
"severity": 4,
|
||||||
|
"message": 9
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"args": [
|
||||||
|
"${command:espIdf.getExtensionPath}/esp_debug_adapter/debug_adapter_main.py",
|
||||||
|
"-e",
|
||||||
|
"${workspaceFolder}/build/${command:espIdf.getProjectName}.elf",
|
||||||
|
"-s",
|
||||||
|
"$OPENOCD_SCRIPTS",
|
||||||
|
"-dn",
|
||||||
|
"esp32",
|
||||||
|
"-om",
|
||||||
|
"connect_to_instance",
|
||||||
|
"-t",
|
||||||
|
"xtensa-esp32-elf-"
|
||||||
|
|
||||||
|
],
|
||||||
|
"windows": {
|
||||||
|
"command": "${config:idf.pythonBinPathWin}",
|
||||||
|
"options": {
|
||||||
|
"env": {
|
||||||
|
"PATH": "${env:PATH};${config:idf.customExtraPaths}",
|
||||||
|
"PYTHONPATH": "${command:espIdf.getExtensionPath}/esp_debug_adapter/debug_adapter"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
6
can-interface/CMakeLists.txt
Executable file
6
can-interface/CMakeLists.txt
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
# The following lines of boilerplate have to be in your project's
|
||||||
|
# CMakeLists in this exact order for cmake to work correctly
|
||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
project(can-interface)
|
||||||
1
can-interface/ESP-IDF.code-profile
Normal file
1
can-interface/ESP-IDF.code-profile
Normal file
File diff suppressed because one or more lines are too long
BIN
can-interface/README.md
(Stored with Git LFS)
Executable file
BIN
can-interface/README.md
(Stored with Git LFS)
Executable file
Binary file not shown.
26
can-interface/a
Normal file
26
can-interface/a
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
txBuffer[0] = 0b00000011; // Read Instruction
|
||||||
|
txBuffer[1] = 0x0f; // CANCTRL Register Address
|
||||||
|
|
||||||
|
spi_transaction_t transaction0 = { // RESET
|
||||||
|
.cmd = 0b11000000,
|
||||||
|
.length = 3 * 8,
|
||||||
|
.rxlength = 3 * 8,
|
||||||
|
.tx_buffer = txBuffer,
|
||||||
|
.rx_buffer = rxBuffer
|
||||||
|
};
|
||||||
|
|
||||||
|
spi_transaction_t transaction1 = { // READ STAT/S
|
||||||
|
.cmd = 0b10110000,
|
||||||
|
.length = 2 * 8,
|
||||||
|
.rxlength = 2 * 8,
|
||||||
|
.tx_buffer = txBuffer,
|
||||||
|
.rx_buffer = rxBuffer
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
|
gpio_set_level(EXTERNAL_TRIGGER, false);
|
||||||
|
spi_device_transmit(mp2125_handle, &transaction0);
|
||||||
6
can-interface/components/mcp2521/CMakeLists.txt
Normal file
6
can-interface/components/mcp2521/CMakeLists.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
idf_component_register(SRCS "operations.cpp"
|
||||||
|
"spi_interface_init.cpp"
|
||||||
|
"spi_interface_commands.cpp"
|
||||||
|
"register_interface.cpp"
|
||||||
|
INCLUDE_DIRS "include"
|
||||||
|
REQUIRES driver)
|
||||||
177
can-interface/components/mcp2521/include/bitfields.hpp
Normal file
177
can-interface/components/mcp2521/include/bitfields.hpp
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief RXnBF PIN CONTROL AND STATUS REGISTER (ADDRESS: 0Ch)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct BFPCTRL {
|
||||||
|
uint8_t B0BFM : 1;
|
||||||
|
uint8_t B1BFM : 1;
|
||||||
|
uint8_t B0BFE : 1;
|
||||||
|
uint8_t B1BFE : 1;
|
||||||
|
uint8_t B0BFS : 1;
|
||||||
|
uint8_t B1BFS : 1;
|
||||||
|
uint8_t : 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TXnRTS PIN CONTROL AND STATUS REGISTER
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct TXRTSCTRL {
|
||||||
|
uint8_t B0RTSM : 1;
|
||||||
|
uint8_t B1RTSM : 1;
|
||||||
|
uint8_t B2RTSM : 1;
|
||||||
|
uint8_t B0RTS : 1;
|
||||||
|
uint8_t B1RTS : 1;
|
||||||
|
uint8_t B2RTS : 1;
|
||||||
|
uint8_t : 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CANSTAT {
|
||||||
|
uint8_t ICOD0 : ;
|
||||||
|
uint8_t : 1;
|
||||||
|
uint8_t OPMOD0 : 1;
|
||||||
|
uint8_t OPMOD1 : 1;
|
||||||
|
uint8_t OPMOD2 : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CANCTRL {
|
||||||
|
uint8_t CLKPRE0 : 1;
|
||||||
|
uint8_t CLKPRE1 : 1;
|
||||||
|
uint8_t CLKEN : 1;
|
||||||
|
uint8_t OSM : 1;
|
||||||
|
uint8_t ABAT : 1;
|
||||||
|
uint8_t REQOP0 : 1;
|
||||||
|
uint8_t REQOP1 : 1;
|
||||||
|
uint8_t REQOP2 : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TEC {
|
||||||
|
uint8_t TEC;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct REC {
|
||||||
|
uint8_t REC;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CNF3 {
|
||||||
|
uint8_t PHSEG20 : 1;
|
||||||
|
uint8_t PHSEG21 : 1;
|
||||||
|
uint8_t PHSEG22 : 1;
|
||||||
|
uint8_t : 3;
|
||||||
|
uint8_t WAKFIL : 1;
|
||||||
|
uint8_t SOF : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CNF2 {
|
||||||
|
uint8_t PRSEG0 : 1;
|
||||||
|
uint8_t PRSEG1 : 1;
|
||||||
|
uint8_t PRSEG2 : 1;
|
||||||
|
uint8_t PHSEG10 : 1;
|
||||||
|
uint8_t PHSEG11 : 1;
|
||||||
|
uint8_t PHSEG12 : 1;
|
||||||
|
uint8_t SAM : 1;
|
||||||
|
uint8_t BTLMODE : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CNF1 {
|
||||||
|
uint8_t BRP0 : 1;
|
||||||
|
uint8_t BRP1 : 1;
|
||||||
|
uint8_t BRP2 : 1;
|
||||||
|
uint8_t BRP3 : 1;
|
||||||
|
uint8_t BRP4 : 1;
|
||||||
|
uint8_t BRP5 : 1;
|
||||||
|
uint8_t SJW0 : 1;
|
||||||
|
uint8_t SJW1 : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CANINTE {
|
||||||
|
uint8_t RX0IE : 1;
|
||||||
|
uint8_t RX1IE : 1;
|
||||||
|
uint8_t TX0IE : 1;
|
||||||
|
uint8_t TX1IE : 1;
|
||||||
|
uint8_t TX2IE : 1;
|
||||||
|
uint8_t ERRIE : 1;
|
||||||
|
uint8_t WAKIE : 1;
|
||||||
|
uint8_t MERRE : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CANINTF {
|
||||||
|
uint8_t RX0IF : 1;
|
||||||
|
uint8_t RX1IF : 1;
|
||||||
|
uint8_t TX0IF : 1;
|
||||||
|
uint8_t TX1IF : 1;
|
||||||
|
uint8_t TX2IF : 1;
|
||||||
|
uint8_t ERRIF : 1;
|
||||||
|
uint8_t WAKIF : 1;
|
||||||
|
uint8_t MERRF : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EFLG {
|
||||||
|
uint8_t EWARN : 1;
|
||||||
|
uint8_t RXWAR : 1;
|
||||||
|
uint8_t TXWAR : 1;
|
||||||
|
uint8_t RXEP : 1;
|
||||||
|
uint8_t TXEP : 1;
|
||||||
|
uint8_t TXBO : 1;
|
||||||
|
uint8_t RX0OVR : 1;
|
||||||
|
uint8_t RX1OVR : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TXB0CTRL {
|
||||||
|
uint8_t TXP0 : 1;
|
||||||
|
uint8_t TXP1 : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
uint8_t TXREQ : 1;
|
||||||
|
uint8_t TXERR : 1;
|
||||||
|
uint8_t MLOA : 1;
|
||||||
|
uint8_t ABTF : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TXB1CTRL {
|
||||||
|
uint8_t TXP0 : 1;
|
||||||
|
uint8_t TXP1 : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
uint8_t TXREQ : 1;
|
||||||
|
uint8_t TXERR : 1;
|
||||||
|
uint8_t MLOA : 1;
|
||||||
|
uint8_t ABTF : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TXB2CTRL {
|
||||||
|
uint8_t TXP0 : 1;
|
||||||
|
uint8_t TXP1 : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
uint8_t TXREQ : 1;
|
||||||
|
uint8_t TXERR : 1;
|
||||||
|
uint8_t MLOA : 1;
|
||||||
|
uint8_t ABTF : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RXB0CTRL {
|
||||||
|
uint8_t FILHIT0 : 1;
|
||||||
|
uint8_t BUKT1 : 1;
|
||||||
|
uint8_t BUKT : 1;
|
||||||
|
uint8_t RXRTR : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
uint8_t RXM0 : 1;
|
||||||
|
uint8_t RXM1 : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RXB1CTRL {
|
||||||
|
uint8_t FILHIT0 : 1;
|
||||||
|
uint8_t FILHIT1 : 1;
|
||||||
|
uint8_t FILHIT2 : 1;
|
||||||
|
uint8_t RXRTR : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
uint8_t RXM0 : 1;
|
||||||
|
uint8_t RXM1 : 1;
|
||||||
|
uint8_t : 1;
|
||||||
|
};
|
||||||
98
can-interface/components/mcp2521/include/mcp2521.hpp
Normal file
98
can-interface/components/mcp2521/include/mcp2521.hpp
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "reg.hpp"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "driver/spi_master.h"
|
||||||
|
|
||||||
|
bool dummy_function(bool flag);
|
||||||
|
|
||||||
|
|
||||||
|
enum MCP2521_RX_BUFFER {
|
||||||
|
RXB0 = 0,
|
||||||
|
RXB1 = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
enum MCP2521_TX_BUFFER {
|
||||||
|
TXB0 = 0,
|
||||||
|
TXB1 = 1,
|
||||||
|
TXB2 = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
enum MCP2521_BUFFER_TYPE {
|
||||||
|
ID = 0,
|
||||||
|
DATA = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
class MCP2521_SPI_Interface {
|
||||||
|
private:
|
||||||
|
char spi_rx_buffer[32];
|
||||||
|
char spi_tx_buffer[32];
|
||||||
|
|
||||||
|
spi_bus_config_t * spi_bus_config;
|
||||||
|
spi_device_interface_config_t spi_device_config;
|
||||||
|
spi_device_handle_t spi_device_handle;
|
||||||
|
|
||||||
|
public:
|
||||||
|
spi_bus_config_t * getSPI_bus_config();
|
||||||
|
|
||||||
|
MCP2521_SPI_Interface(
|
||||||
|
spi_host_device_t spi_host,
|
||||||
|
spi_bus_config_t *bus_config,
|
||||||
|
gpio_num_t mosi,
|
||||||
|
gpio_num_t miso,
|
||||||
|
gpio_num_t sclk,
|
||||||
|
gpio_num_t cs,
|
||||||
|
gpio_num_t int_pin
|
||||||
|
);
|
||||||
|
MCP2521_SPI_Interface(
|
||||||
|
spi_host_device_t spi_host,
|
||||||
|
spi_bus_config_t *bus_config,
|
||||||
|
gpio_num_t cs,
|
||||||
|
gpio_num_t int_pin
|
||||||
|
);
|
||||||
|
|
||||||
|
~MCP2521_SPI_Interface();
|
||||||
|
|
||||||
|
static void initSPIBus(
|
||||||
|
spi_host_device_t spi_host,
|
||||||
|
gpio_num_t mosi,
|
||||||
|
gpio_num_t miso,
|
||||||
|
gpio_num_t sclk,
|
||||||
|
spi_bus_config_t *bus_config
|
||||||
|
);
|
||||||
|
|
||||||
|
void initSPIDevice(
|
||||||
|
spi_host_device_t spi_host,
|
||||||
|
gpio_num_t cs
|
||||||
|
);
|
||||||
|
|
||||||
|
void deinitSPI();
|
||||||
|
|
||||||
|
void initPins(
|
||||||
|
gpio_num_t int_pin
|
||||||
|
);
|
||||||
|
void deinitPins();
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
void read_reg(uint8_t address, uint8_t *data, size_t length);
|
||||||
|
uint8_t read_reg(uint8_t address);
|
||||||
|
|
||||||
|
void read_rx_buf(MCP2521_RX_BUFFER buffer, MCP2521_BUFFER_TYPE type, uint8_t *data, size_t length);
|
||||||
|
|
||||||
|
void write_reg(uint8_t address, uint8_t *data, size_t length);
|
||||||
|
void write_reg(uint8_t address, uint8_t data);
|
||||||
|
|
||||||
|
void write_tx_buf(MCP2521_TX_BUFFER buffer, MCP2521_BUFFER_TYPE type, uint8_t *data, size_t length);
|
||||||
|
|
||||||
|
void request_to_send(bool txb2, bool txb1, bool txb0);
|
||||||
|
void request_to_send(MCP2521_TX_BUFFER buffer);
|
||||||
|
|
||||||
|
uint8_t read_status();
|
||||||
|
uint8_t read_rx_status();
|
||||||
|
|
||||||
|
void bit_modify(uint8_t address, uint8_t mask, uint8_t data);
|
||||||
|
};
|
||||||
|
|
||||||
146
can-interface/components/mcp2521/include/reg.hpp
Normal file
146
can-interface/components/mcp2521/include/reg.hpp
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define MCP2521_BFPCTRL 0x0C
|
||||||
|
#define MCP2521_BFPCTRL_B1BFS (1 << 5)
|
||||||
|
#define MCP2521_BFPCTRL_B0BFS (1 << 4)
|
||||||
|
#define MCP2521_BFPCTRL_B1BFE (1 << 3)
|
||||||
|
#define MCP2521_BFPCTRL_B0BFE (1 << 2)
|
||||||
|
#define MCP2521_BFPCTRL_B1BFM (1 << 1)
|
||||||
|
#define MCP2521_BFPCTRL_B0BFM (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_TXRTSCTRL 0x0D
|
||||||
|
#define MCP2521_TXRTSCTRL_B2RTS (1 << 5)
|
||||||
|
#define MCP2521_TXRTSCTRL_B1RTS (1 << 4)
|
||||||
|
#define MCP2521_TXRTSCTRL_B0RTS (1 << 3)
|
||||||
|
#define MCP2521_TXRTSCTRL_B2RTSM (1 << 2)
|
||||||
|
#define MCP2521_TXRTSCTRL_B1RTSM (1 << 1)
|
||||||
|
#define MCP2521_TXRTSCTRL_B0RTSM (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_CANSTAT 0x0E
|
||||||
|
#define MCP2521_CANSTAT_OPMOD2 (1 << 7)
|
||||||
|
#define MCP2521_CANSTAT_OPMOD1 (1 << 6)
|
||||||
|
#define MCP2521_CANSTAT_OPMOD0 (1 << 5)
|
||||||
|
#define MCP2521_CANSTAT_ICOD2 (1 << 3)
|
||||||
|
#define MCP2521_CANSTAT_ICOD1 (1 << 2)
|
||||||
|
#define MCP2521_CANSTAT_ICOD0 (1 << 1)
|
||||||
|
|
||||||
|
#define MCP2521_CANCTRL 0x0F
|
||||||
|
#define MCP2521_CANCTRL_REQOP2 (1 << 7)
|
||||||
|
#define MCP2521_CANCTRL_REQOP1 (1 << 6)
|
||||||
|
#define MCP2521_CANCTRL_REQOP0 (1 << 5)
|
||||||
|
#define MCP2521_CANCTRL_ABAT (1 << 4)
|
||||||
|
#define MCP2521_CANCTRL_OSM (1 << 3)
|
||||||
|
#define MCP2521_CANCTRL_CLKEN (1 << 2)
|
||||||
|
#define MCP2521_CANCTRL_CLKPRE1 (1 << 1)
|
||||||
|
#define MCP2521_CANCTRL_CLKPRE0 (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_TEC 0x1C
|
||||||
|
|
||||||
|
#define MCP2521_REC 0x1D
|
||||||
|
|
||||||
|
#define MCP2521_CNF3 0x28
|
||||||
|
#define MCP2521_CNF3_SOF (1 << 7)
|
||||||
|
#define MCP2521_CNF3_WAKFIL (1 << 6)
|
||||||
|
#define MCP2521_CNF3_PHSEG22 (1 << 2)
|
||||||
|
#define MCP2521_CNF3_PHSEG21 (1 << 1)
|
||||||
|
#define MCP2521_CNF3_PHSEG20 (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_CNF2 0x29
|
||||||
|
#define MCP2521_CNF2_BTLMODE (1 << 7)
|
||||||
|
#define MCP2521_CNF2_SAM (1 << 6)
|
||||||
|
#define MCP2521_CNF2_PHSEG12 (1 << 5)
|
||||||
|
#define MCP2521_CNF2_PHSEG11 (1 << 4)
|
||||||
|
#define MCP2521_CNF2_PHSEG10 (1 << 3)
|
||||||
|
#define MCP2521_CNF2_PRSEG2 (1 << 2)
|
||||||
|
#define MCP2521_CNF2_PRSEG1 (1 << 1)
|
||||||
|
#define MCP2521_CNF2_PRSEG0 (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_CNF1 0x2A
|
||||||
|
#define MCP2521_CNF1_SJW1 (1 << 7)
|
||||||
|
#define MCP2521_CNF1_SJW0 (1 << 6)
|
||||||
|
#define MCP2521_CNF1_BRP5 (1 << 5)
|
||||||
|
#define MCP2521_CNF1_BRP4 (1 << 4)
|
||||||
|
#define MCP2521_CNF1_BRP3 (1 << 3)
|
||||||
|
#define MCP2521_CNF1_BRP2 (1 << 2)
|
||||||
|
#define MCP2521_CNF1_BRP1 (1 << 1)
|
||||||
|
#define MCP2521_CNF1_BRP0 (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_CANINTE 0x2B
|
||||||
|
#define MCP2521_CANINTE_MERRE (1 << 7)
|
||||||
|
#define MCP2521_CANINTE_WAKIE (1 << 6)
|
||||||
|
#define MCP2521_CANINTE_ERRIE (1 << 5)
|
||||||
|
#define MCP2521_CANINTE_TX2IE (1 << 4)
|
||||||
|
#define MCP2521_CANINTE_TX1IE (1 << 3)
|
||||||
|
#define MCP2521_CANINTE_TX0IE (1 << 2)
|
||||||
|
#define MCP2521_CANINTE_RX1IE (1 << 1)
|
||||||
|
#define MCP2521_CANINTE_RX0IE (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_CANINTF 0x2C
|
||||||
|
#define MCP2521_CANINTF_MERRF (1 << 7)
|
||||||
|
#define MCP2521_CANINTF_WAKIF (1 << 6)
|
||||||
|
#define MCP2521_CANINTF_ERRIF (1 << 5)
|
||||||
|
#define MCP2521_CANINTF_TX2IF (1 << 4)
|
||||||
|
#define MCP2521_CANINTF_TX1IF (1 << 3)
|
||||||
|
#define MCP2521_CANINTF_TX0IF (1 << 2)
|
||||||
|
#define MCP2521_CANINTF_RX1IF (1 << 1)
|
||||||
|
#define MCP2521_CANINTF_RX0IF (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_EFLG 0x2D
|
||||||
|
#define MCP2521_EFLG_RX1OVR (1 << 7)
|
||||||
|
#define MCP2521_EFLG_RX0OVR (1 << 6)
|
||||||
|
#define MCP2521_EFLG_TXBO (1 << 5)
|
||||||
|
#define MCP2521_EFLG_TXEP (1 << 4)
|
||||||
|
#define MCP2521_EFLG_RXEP (1 << 3)
|
||||||
|
#define MCP2521_EFLG_TXWAR (1 << 2)
|
||||||
|
#define MCP2521_EFLG_RXWAR (1 << 1)
|
||||||
|
#define MCP2521_EFLG_EWARN (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_TXB0CTRL 0x30
|
||||||
|
#define MCP2521_TXB0CTRL_ABTF (1 << 6)
|
||||||
|
#define MCP2521_TXB0CTRL_MLOA (1 << 5)
|
||||||
|
#define MCP2521_TXB0CTRL_TXERR (1 << 4)
|
||||||
|
#define MCP2521_TXB0CTRL_TXREQ (1 << 3)
|
||||||
|
#define MCP2521_TXB0CTRL_TXP1 (1 << 1)
|
||||||
|
#define MCP2521_TXB0CTRL_TXP0 (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_TXB1CTRL 0x40
|
||||||
|
#define MCP2521_TXB1CTRL_ABTF (1 << 6)
|
||||||
|
#define MCP2521_TXB1CTRL_MLOA (1 << 5)
|
||||||
|
#define MCP2521_TXB1CTRL_TXERR (1 << 4)
|
||||||
|
#define MCP2521_TXB1CTRL_TXREQ (1 << 3)
|
||||||
|
#define MCP2521_TXB1CTRL_TXP1 (1 << 1)
|
||||||
|
#define MCP2521_TXB1CTRL_TXP0 (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_TXB2CTRL 0x50
|
||||||
|
#define MCP2521_TXB2CTRL_ABTF (1 << 6)
|
||||||
|
#define MCP2521_TXB2CTRL_MLOA (1 << 5)
|
||||||
|
#define MCP2521_TXB2CTRL_TXERR (1 << 4)
|
||||||
|
#define MCP2521_TXB2CTRL_TXREQ (1 << 3)
|
||||||
|
#define MCP2521_TXB2CTRL_TXP1 (1 << 1)
|
||||||
|
#define MCP2521_TXB2CTRL_TXP0 (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_RXB0CTRL 0x60
|
||||||
|
#define MCP2521_RXB0CTRL_RXM1 (1 << 6)
|
||||||
|
#define MCP2521_RXB0CTRL_RXM0 (1 << 5)
|
||||||
|
#define MCP2521_RXB0CTRL_RXRTR (1 << 3)
|
||||||
|
#define MCP2521_RXB0CTRL_BUKT (1 << 2)
|
||||||
|
#define MCP2521_RXB0CTRL_BUKT1 (1 << 1)
|
||||||
|
#define MCP2521_RXB0CTRL_FILHIT0 (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_RXB1CTRL 0x70
|
||||||
|
#define MCP2521_RXB1CTRL_RXM1 (1 << 6)
|
||||||
|
#define MCP2521_RXB1CTRL_RXM0 (1 << 5)
|
||||||
|
#define MCP2521_RXB1CTRL_RXRTR (1 << 3)
|
||||||
|
#define MCP2521_RXB1CTRL_FILHIT2 (1 << 2)
|
||||||
|
#define MCP2521_RXB1CTRL_FILHIT1 (1 << 1)
|
||||||
|
#define MCP2521_RXB1CTRL_FILHIT0 (1 << 0)
|
||||||
|
|
||||||
|
#define MCP2521_OP_RESET 0b11000000
|
||||||
|
#define MCP2521_OP_READ 0b00000011
|
||||||
|
#define MCP2521_OP_READ_RX_BUFFER 0b10010000
|
||||||
|
#define MCP2521_OP_WRITE 0b00000010
|
||||||
|
#define MCP2521_OP_LOAD_TX_BUFFER 0b01000000
|
||||||
|
#define MCP2521_OP_RTS 0b10000000
|
||||||
|
#define MCP2521_OP_READ_STATUS 0b10100000
|
||||||
|
#define MCP2521_OP_RX_STATUS 0b10110000
|
||||||
|
#define MCP2521_OP_BIT_MODIFY 0b00000101
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
class MCP2515 {
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
uint8_t get_TransmitErrorCounter();
|
||||||
|
uint8_t get_ReceiveErrorCounter();
|
||||||
|
};
|
||||||
4
can-interface/components/mcp2521/operations.cpp
Normal file
4
can-interface/components/mcp2521/operations.cpp
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
bool dummy_function(bool flag) {
|
||||||
|
return !flag;
|
||||||
|
}
|
||||||
2
can-interface/components/mcp2521/register_interface.cpp
Normal file
2
can-interface/components/mcp2521/register_interface.cpp
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#include "mcp2515.hpp"
|
||||||
|
#include "register_interface.hpp"
|
||||||
49
can-interface/components/mcp2521/spi_interface_commands.cpp
Normal file
49
can-interface/components/mcp2521/spi_interface_commands.cpp
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "mcp2521.hpp"
|
||||||
|
#include "reg.hpp"
|
||||||
|
|
||||||
|
void MCP2521_SPI_Interface::reset() {
|
||||||
|
spi_transaction_ext_t t = {
|
||||||
|
.base = {
|
||||||
|
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||||
|
.cmd = MCP2521_OP_RESET,
|
||||||
|
.addr = 8,
|
||||||
|
.length = 0,
|
||||||
|
.rxlength = 0,
|
||||||
|
.tx_buffer = NULL,
|
||||||
|
.rx_buffer = NULL
|
||||||
|
},
|
||||||
|
.command_bits = 8,
|
||||||
|
.address_bits = 0,
|
||||||
|
.dummy_bits = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
spi_device_transmit(this->spi_device_handle, (spi_transaction_t*)(&t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCP2521_SPI_Interface::read_reg(uint8_t address, uint8_t *data, size_t length) {
|
||||||
|
spi_transaction_ext_t t = {
|
||||||
|
.base = {
|
||||||
|
.flags = SPI_TRANS_VARIABLE_CMD | SPI_TRANS_VARIABLE_ADDR,
|
||||||
|
.cmd = MCP2521_OP_READ,
|
||||||
|
.addr = address,
|
||||||
|
.length = 8 * length,
|
||||||
|
.rxlength = 8 * length,
|
||||||
|
.tx_buffer = &this->spi_tx_buffer,
|
||||||
|
.rx_buffer = &this->spi_rx_buffer,
|
||||||
|
},
|
||||||
|
.command_bits = 8,
|
||||||
|
.address_bits = 8,
|
||||||
|
.dummy_bits = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
spi_device_transmit(this->spi_device_handle, (spi_transaction_t*)(&t));
|
||||||
|
memcpy(data, this->spi_rx_buffer, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t MCP2521_SPI_Interface::read_reg(uint8_t address) {
|
||||||
|
uint8_t data;
|
||||||
|
read_reg(address, &data, 1);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
99
can-interface/components/mcp2521/spi_interface_init.cpp
Normal file
99
can-interface/components/mcp2521/spi_interface_init.cpp
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
#include "mcp2521.hpp"
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "driver/spi_master.h"
|
||||||
|
|
||||||
|
MCP2521_SPI_Interface::MCP2521_SPI_Interface(
|
||||||
|
spi_host_device_t spi_host,
|
||||||
|
spi_bus_config_t *bus_config,
|
||||||
|
gpio_num_t mosi,
|
||||||
|
gpio_num_t miso,
|
||||||
|
gpio_num_t sclk,
|
||||||
|
gpio_num_t cs,
|
||||||
|
gpio_num_t int_pin
|
||||||
|
) {
|
||||||
|
initPins(int_pin);
|
||||||
|
initSPIBus(spi_host, mosi, miso, sclk, bus_config);
|
||||||
|
this->spi_bus_config = bus_config;
|
||||||
|
initSPIDevice(spi_host, cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
MCP2521_SPI_Interface::MCP2521_SPI_Interface(
|
||||||
|
spi_host_device_t spi_host,
|
||||||
|
spi_bus_config_t *bus_config,
|
||||||
|
gpio_num_t cs,
|
||||||
|
gpio_num_t int_pin
|
||||||
|
) {
|
||||||
|
initPins(int_pin);
|
||||||
|
this->spi_bus_config = bus_config;
|
||||||
|
initSPIDevice(spi_host, cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCP2521_SPI_Interface::initSPIBus(
|
||||||
|
spi_host_device_t spi_host,
|
||||||
|
gpio_num_t mosi,
|
||||||
|
gpio_num_t miso,
|
||||||
|
gpio_num_t sclk,
|
||||||
|
spi_bus_config_t *bus_config
|
||||||
|
) {
|
||||||
|
memset(bus_config, 0, sizeof(spi_bus_config_t));
|
||||||
|
bus_config->mosi_io_num = mosi;
|
||||||
|
bus_config->miso_io_num = miso;
|
||||||
|
bus_config->sclk_io_num = sclk;
|
||||||
|
|
||||||
|
bus_config->quadwp_io_num = -1;
|
||||||
|
bus_config->quadhd_io_num = -1;
|
||||||
|
|
||||||
|
bus_config->flags = SPICOMMON_BUSFLAG_MASTER;
|
||||||
|
spi_bus_initialize(spi_host, bus_config, SPI_DMA_CH_AUTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCP2521_SPI_Interface::initSPIDevice(
|
||||||
|
spi_host_device_t spi_host,
|
||||||
|
gpio_num_t cs
|
||||||
|
) {
|
||||||
|
memset(&this->spi_device_config, 0, sizeof(spi_device_interface_config_t));
|
||||||
|
this->spi_device_config = {
|
||||||
|
.command_bits = 8,
|
||||||
|
.address_bits = 0,
|
||||||
|
.dummy_bits = 0,
|
||||||
|
|
||||||
|
.mode = 0,
|
||||||
|
.duty_cycle_pos = 128,
|
||||||
|
// cs_ena_pretrans = 0 and cs_ena_posttrans = 0 need to be set to zero, if not its not compatible with full-duplex mode
|
||||||
|
// Learned this the hard way
|
||||||
|
.cs_ena_pretrans = 0,
|
||||||
|
.cs_ena_posttrans = 0,
|
||||||
|
.clock_speed_hz = 10000,
|
||||||
|
|
||||||
|
.spics_io_num = cs,
|
||||||
|
.flags = SPI_DEVICE_NO_DUMMY,
|
||||||
|
.queue_size = 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
spi_bus_add_device(spi_host, &this->spi_device_config, &this->spi_device_handle);
|
||||||
|
|
||||||
|
memset(&this->spi_tx_buffer, 0, sizeof(this->spi_tx_buffer));
|
||||||
|
memset(&this->spi_rx_buffer, 0, sizeof(this->spi_rx_buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
spi_bus_config_t * MCP2521_SPI_Interface::getSPI_bus_config() {
|
||||||
|
return this->spi_bus_config;
|
||||||
|
}
|
||||||
|
|
||||||
|
MCP2521_SPI_Interface::~MCP2521_SPI_Interface() {
|
||||||
|
deinitSPI();
|
||||||
|
deinitPins();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCP2521_SPI_Interface::initPins(gpio_num_t int_pin) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MCP2521_SPI_Interface::deinitPins() {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
5
can-interface/main/CMakeLists.txt
Executable file
5
can-interface/main/CMakeLists.txt
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
idf_component_register(SRCS "hello_world_main.cpp"
|
||||||
|
REQUIRES driver
|
||||||
|
REQUIRES mcp2521
|
||||||
|
REQUIRES spi_flash
|
||||||
|
INCLUDE_DIRS "")
|
||||||
7
can-interface/main/can-interface.code-workspace
Normal file
7
can-interface/main/can-interface.code-workspace
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": ".."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
90
can-interface/main/hello_world_main.cpp
Executable file
90
can-interface/main/hello_world_main.cpp
Executable file
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/semphr.h"
|
||||||
|
#include "freertos/queue.h"
|
||||||
|
|
||||||
|
#include "esp_chip_info.h"
|
||||||
|
#include "esp_flash.h"
|
||||||
|
#include "esp_system.h"
|
||||||
|
|
||||||
|
#include "driver/gpio.h"
|
||||||
|
#include "driver/spi_master.h"
|
||||||
|
|
||||||
|
#include "mcp2521.hpp"
|
||||||
|
#include "reg.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
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void app_main() {
|
||||||
|
printf("Hello world!\n");
|
||||||
|
|
||||||
|
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);
|
||||||
|
gpio_set_level(EXTERNAL_TRIGGER, false);
|
||||||
|
|
||||||
|
spi_bus_config_t spi_bus;
|
||||||
|
|
||||||
|
MCP2521_SPI_Interface mcp2521_spi(
|
||||||
|
VSPI_HOST,
|
||||||
|
&spi_bus,
|
||||||
|
SPI_PIN_MOSI,
|
||||||
|
SPI_PIN_MISO,
|
||||||
|
SPI_PIN_SCLK,
|
||||||
|
SPI_PIN_CS0,
|
||||||
|
CAN_INT_PIN
|
||||||
|
);
|
||||||
|
|
||||||
|
mcp2521_spi.reset();
|
||||||
|
printf("%x\n", mcp2521_spi.read_reg(MCP2521_CANCTRL));
|
||||||
|
|
||||||
|
uint8_t data[16];
|
||||||
|
mcp2521_spi.read_reg(MCP2521_CANSTAT, data, 16);
|
||||||
|
|
||||||
|
for(int i=0; i<0x10; i++) {
|
||||||
|
printf("%x ", i);
|
||||||
|
for(int j=0; j<8; j++) {
|
||||||
|
printf("%u", (data[i] >> (7-j)) & 1);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
gpio_set_level(EXTERNAL_TRIGGER, true);
|
||||||
|
|
||||||
|
bool flag = true;
|
||||||
|
while (true) {
|
||||||
|
gpio_set_level(LED_PIN, flag);
|
||||||
|
flag = dummy_function(flag);
|
||||||
|
|
||||||
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
BIN
can-interface/pulseview-session
Normal file
BIN
can-interface/pulseview-session
Normal file
Binary file not shown.
BIN
can-interface/pytest_hello_world.py
(Stored with Git LFS)
Executable file
BIN
can-interface/pytest_hello_world.py
(Stored with Git LFS)
Executable file
Binary file not shown.
2008
can-interface/sdkconfig
Normal file
2008
can-interface/sdkconfig
Normal file
File diff suppressed because it is too large
Load Diff
0
can-interface/sdkconfig.ci
Executable file
0
can-interface/sdkconfig.ci
Executable file
BIN
motor-control/.gitignore
(Stored with Git LFS)
vendored
Normal file
BIN
motor-control/.gitignore
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
13
motor-control/firmware/cmake/tmc2209.cmake
Normal file
13
motor-control/firmware/cmake/tmc2209.cmake
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
add_library(tmc2209_driver STATIC
|
||||||
|
src/tmc2209/uart_interface.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(tmc2209_driver PRIVATE
|
||||||
|
include/tmc2209/
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(tmc2209_driver
|
||||||
|
pico_stdlib
|
||||||
|
hardware_uart
|
||||||
|
)
|
||||||
|
|
||||||
Reference in New Issue
Block a user