Emandhal / MCP251XFD

MCP2517FD, MCP2518FD and MCP251863 driver
MIT License
28 stars 6 forks source link

Issue with my implementation attempt to my project #17

Closed stanislavZemek closed 3 weeks ago

stanislavZemek commented 1 month ago

Hi Emandhal,

I have a problem with implementation your library. (btw, documentation is very nice) It's probably caused by some my noob mistake which I did.. :D Here is Error when I tried to compile my code:

/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `Init_MCP251XFD':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:93: undefined reference to `MCP251XFD_WriteRAM32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:95: undefined reference to `MCP251XFD_ReadRAM32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:110: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:118: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:140: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:144: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:155: undefined reference to `MCP251XFD_WriteRAM32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:157: undefined reference to `MCP251XFD_ReadRAM32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:191: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_InitRAM':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:214: undefined reference to `MCP251XFD_WriteRAM32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ConfigureCRC':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:823: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ConfigurePins':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:908: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:915: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_SetGPIOPinsOutputLevel':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:964: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_GetActualOperationMode':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1261: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_RequestOperationMode':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1282: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1287: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_WaitOperationModeChange':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1318: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ConfigureCANController':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1337: undefined reference to `MCP251XFD_ReadSFR32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1353: undefined reference to `MCP251XFD_WriteSFR32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1357: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1366: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ConfigureTimeStamp':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1542: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1546: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ConfigureTEF':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1583: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1588: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ConfigureTXQ':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1633: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1638: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ResetFIFO':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1854: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1862: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ConfigureDeviceNetFilter':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:1996: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2000: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ConfigureFilter':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2019: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2024: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2053: undefined reference to `MCP251XFD_WriteSFR32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2063: undefined reference to `MCP251XFD_WriteSFR32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2069: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_DisableFilter':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2129: undefined reference to `MCP251XFD_ReadSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2134: undefined reference to `MCP251XFD_WriteSFR8'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ConfigureInterrupt':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2153: undefined reference to `MCP251XFD_WriteSFR16'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `MCP251XFD_ClearInterruptEvents':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2185: undefined reference to `MCP251XFD_ReadSFR16'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2188: undefined reference to `MCP251XFD_WriteSFR16'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: ./Core/Src/MCP251XFD_Driver/MCP251XFD.o: in function `__MCP251XFD_TestRAM':
/home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2450: undefined reference to `MCP251XFD_WriteRAM32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2452: undefined reference to `MCP251XFD_ReadRAM32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2456: undefined reference to `MCP251XFD_WriteRAM32'
/opt/st/stm32cubeide_1.14.0/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.11.3.rel1.linux64_1.1.100.202309141235/tools/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld: /home/standa/STM32CubeIDE/workspace_1.14.0/MCP2518FD_AlternativeCommunication/Debug/../Core/Src/MCP251XFD_Driver/MCP251XFD.c:2458: undefined reference to `MCP251XFD_ReadRAM32

I already tried to check if your header file is included in .c library file and it is..

Here is my code which I try to get working. SpiInit and SpiTransfer are not written well, they I will edit after attempt to handle with this library.

eERRORRESULT spiInitCan1(void *pIntDev, uint8_t chipSelectconst, uint32_t sckFreq) {
    //eERRORRESULT ErrorExt1 = ERR__NO_DEVICE_DETECTED;
    hspi1.Instance = SPI1;

    /* Set up Master mode and CS configuration*/
    hspi1.Init.Mode = SPI_MODE_MASTER;
    hspi1.Init.NSS = SPI_NSS_SOFT;

    /* Set up if the SPI is allowed to run while the rest of the CPU is in idle mode*/
    //PLIB_SPI_StopInIdleDisable(SPI_ID_1);

    /* Set up clock Polarity and output data phase + Direction */
    hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
    hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
    hspi1.Init.Direction = SPI_DIRECTION_2LINES;

    /* Communication Width Selection and MSB/LSB select + CRC Setting up */
    hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
    hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
    hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_ENABLE;
    hspi1.Init.CRCPolynomial = 10;

    /* Baud rate selection */
    hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;

    /* Protocol selection */
    hspi1.Init.TIMode = SPI_TIMODE_DISABLE;

    /* Enable the Module */
    if (HAL_SPI_Init(&hspi1) != HAL_OK)
    {
        Error_Handler();
    }

    return ERR_OK;
}

eERRORRESULT spiTransferCan1(void *pIntDev, uint8_t chipSelect, uint8_t *txData, uint8_t *rxData, size_t size) {
    //initialise_monitor_handles();
    if (pIntDev == NULL)
        return ERR__SPI_PARAMETER_ERROR;
    if (txData == NULL)
        return ERR__SPI_PARAMETER_ERROR;

    HAL_StatusTypeDef SPI_Status;
    GPIO_TypeDef* CS_GPIO_Port;
    SPI_HandleTypeDef hspi;
    uint16_t CS_Pin;
    switch (chipSelect)
    {
        case SPI_CS_CAN1:
            // mkBUS1 : BUS SPI2
            hspi = hspi1;
            CS_GPIO_Port = GPIOA;
            CS_Pin = GPIO_PIN_4;
            break;
//      case CS_mkBUS2:
//          // mkBUS2 : BUS SPI2
//          hspi = hspi2;
//          CS_GPIO_Port = mkBUS2_CS_GPIO_Port;
//          CS_Pin = mkBUS2_CS_Pin;
//          break;
//      case CS_mkBUS3:
//          // mkBUS3 : BUS SPI1
//          hspi = hspi1;
//          CS_GPIO_Port = mkBUS3_CS_GPIO_Port;
//          CS_Pin = mkBUS3_CS_Pin;
//          break;
//      case CS_mkBUS4:
//          // mkBUS4 : BUS SPI1
//          hspi = hspi1;
//          CS_GPIO_Port = mkBUS4_CS_GPIO_Port;
//          CS_Pin = mkBUS4_CS_Pin;
//          break;
    }

    __disable_irq();

    HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET);

    SPI_Status = HAL_SPI_TransmitReceive(&hspi, txData, rxData, size, 10000);

    //--- Check for errors ---
    if (SPI_Status == HAL_ERROR)
    return ERR__SPI_COMM_ERROR;
    else if (SPI_Status == HAL_TIMEOUT)
    return ERR__SPI_TIMEOUT;

    HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET);

    __enable_irq();
    return ERR_OK;
}

/*
 * Configuration of the MCP variables
 */

MCP251XFD_BitTimeStats MCP2517FDcan1_bitTimeStats;
uint32_t SYSCLK_Ext1;
MCP251XFD_RAMInfos Ext1_TEF_RAMInfos;
MCP251XFD_RAMInfos Ext1_TXQ_RAMInfos;
MCP251XFD_RAMInfos Ext1_FIFOs_RAMInfos[MCP2517FD_EXT1_FIFO_COUNT - 2];

MCP251XFD MCP2518can1_ctrlDefinition =
{
    .UserDriverData = NULL,
    //--- Driver configuration ---
    .DriverConfig = MCP251XFD_DRIVER_USE_READ_WRITE_CRC
    | MCP251XFD_DRIVER_USE_SAFE_WRITE
    | MCP251XFD_DRIVER_ENABLE_ECC
    | MCP251XFD_DRIVER_INIT_SET_RAM_AT_0
    | MCP251XFD_DRIVER_CLEAR_BUFFER_BEFORE_READ,
    //--- IO configuration ---
    //.GPIOsOutState = MCP251XFD_GPIO0_LOW | MCP251XFD_GPIO1_HIGH,
    //--- Interface driver call functions ---
    .SPI_ChipSelect = SPI_CS_CAN1, // Here the chip select of the EXT1 interface is 1
    .InterfaceDevice = &hspi1, // Here this point to the address memory of the peripheral SPI0
    .fnSPI_Init = spiInitCan1,
    .fnSPI_Transfer = spiTransferCan1,
    //--- Time call function ---
    .fnGetCurrentms = HAL_GetTick,
    //--- CRC16-CMS call function ---
    .fnComputeCRC16 = NULL,
    //--- Interface clocks ---
    .SPIClockSpeed = 4000000, // 4MHz
};

MCP251XFD_Config MCP2517FDcan1_Config =
{
    //--- Controller clocks ---
    .XtalFreq = 0, // CLKIN is not a crystal
    .OscFreq = 40000000, // CLKIN is a 40MHz oscillator
    .SysclkConfig = MCP251XFD_SYSCLK_IS_CLKIN,  // szemek: this parameter is for clk divider (keep or /2 or /10)
    .ClkoPinConfig = MCP251XFD_CLKO_SOF,
    .SYSCLK_Result = &SYSCLK_Ext1,  // szemek: important note -> is necessary to check if the clk properly set or not
    //--- CAN configuration ---
    .NominalBitrate = 250000, // Nominal Bitrate to 1Mbps
    .DataBitrate = MCP251XFD_NO_CANFD, // Data Bitrate to 2Mbps - szemek: no bitrate, because canfd is not used
    .BitTimeStats = &MCP2517FDcan1_bitTimeStats,
    .Bandwidth = MCP251XFD_DELAY_8BIT_TIMES, // szemek: could be set to zero if it's ok
    .ControlFlags = MCP251XFD_CAN_RESTRICTED_MODE_ON_ERROR
    | MCP251XFD_CAN_ESI_REFLECTS_ERROR_STATUS
    | MCP251XFD_CAN_RESTRICTED_RETRANS_ATTEMPTS
    //| MCP251XFD_CANFD_BITRATE_SWITCHING_ENABLE
    | MCP251XFD_CAN_PROTOCOL_EXCEPT_AS_FORM_ERROR
    | MCP251XFD_CANFD_USE_ISO_CRC
    | MCP251XFD_CANFD_DONT_USE_RRS_BIT_AS_SID11,
    //--- GPIOs and Interrupts pins ---
    .GPIO0PinMode = MCP251XFD_PIN_AS_GPIO0_OUT,
    .GPIO1PinMode = MCP251XFD_PIN_AS_INT1_RX,
    .INTsOutMode = MCP251XFD_PINS_PUSHPULL_OUT,
    .TXCANOutMode = MCP251XFD_PINS_PUSHPULL_OUT,
    //--- Interrupts ---
    .SysInterruptFlags = MCP251XFD_INT_ENABLE_ALL_EVENTS,
};

MCP251XFD_FIFO MCP2517FD_Ext1_FIFOlist[MCP2517FD_EXT1_FIFO_COUNT] =
{
    { .Name = MCP251XFD_TEF, .Size = MCP251XFD_FIFO_10_MESSAGE_DEEP, .ControlFlags = MCP251XFD_FIFO_ADD_TIMESTAMP_ON_OBJ,
    .InterruptFlags = MCP251XFD_FIFO_OVERFLOW_INT + MCP251XFD_FIFO_EVENT_FIFO_NOT_EMPTY_INT,
    .RAMInfos = &Ext1_TEF_RAMInfos, },

    { .Name = MCP251XFD_TXQ, .Size = MCP251XFD_FIFO_4_MESSAGE_DEEP, .Payload = MCP251XFD_PAYLOAD_8BYTE,
    .Attempts = MCP251XFD_THREE_ATTEMPTS, .Priority = MCP251XFD_MESSAGE_TX_PRIORITY16,
    .ControlFlags = MCP251XFD_FIFO_NO_RTR_RESPONSE,
    .InterruptFlags = MCP251XFD_FIFO_TX_ATTEMPTS_EXHAUSTED_INT + MCP251XFD_FIFO_TRANSMIT_FIFO_NOT_FULL_INT,
    .RAMInfos = &Ext1_TXQ_RAMInfos, },

    { .Name = MCP251XFD_FIFO1, .Size = MCP251XFD_FIFO_4_MESSAGE_DEEP, .Payload = MCP251XFD_PAYLOAD_8BYTE,
    .Direction = MCP251XFD_RECEIVE_FIFO, .ControlFlags = MCP251XFD_FIFO_ADD_TIMESTAMP_ON_RX,
    .InterruptFlags = MCP251XFD_FIFO_OVERFLOW_INT + MCP251XFD_FIFO_RECEIVE_FIFO_NOT_EMPTY_INT,
    .RAMInfos = &Ext1_FIFOs_RAMInfos[0], }, // SID: 0x000..0x1FF ; No EID

    { .Name = MCP251XFD_FIFO2, .Size = MCP251XFD_FIFO_2_MESSAGE_DEEP, .Payload = MCP251XFD_PAYLOAD_8BYTE,
    .Direction = MCP251XFD_RECEIVE_FIFO, .ControlFlags = MCP251XFD_FIFO_ADD_TIMESTAMP_ON_RX,
    .InterruptFlags = MCP251XFD_FIFO_OVERFLOW_INT + MCP251XFD_FIFO_RECEIVE_FIFO_NOT_EMPTY_INT,
    .RAMInfos = &Ext1_FIFOs_RAMInfos[1], }, // SID: 0x200..0x3FF ; No EID

    { .Name = MCP251XFD_FIFO3, .Size = MCP251XFD_FIFO_4_MESSAGE_DEEP, .Payload = MCP251XFD_PAYLOAD_8BYTE,
    .Direction = MCP251XFD_RECEIVE_FIFO, .ControlFlags = MCP251XFD_FIFO_ADD_TIMESTAMP_ON_RX,
    .InterruptFlags = MCP251XFD_FIFO_OVERFLOW_INT + MCP251XFD_FIFO_RECEIVE_FIFO_NOT_EMPTY_INT,
    .RAMInfos = &Ext1_FIFOs_RAMInfos[2], }, // SID: 0x400..0x5FF ; No EID

    { .Name = MCP251XFD_FIFO4, .Size = MCP251XFD_FIFO_2_MESSAGE_DEEP, .Payload = MCP251XFD_PAYLOAD_8BYTE,
    .Direction = MCP251XFD_RECEIVE_FIFO, .ControlFlags = MCP251XFD_FIFO_ADD_TIMESTAMP_ON_RX,
    .InterruptFlags = MCP251XFD_FIFO_OVERFLOW_INT + MCP251XFD_FIFO_RECEIVE_FIFO_NOT_EMPTY_INT,
    .RAMInfos = &Ext1_FIFOs_RAMInfos[3], }, // SID: 0x600..0x7FF ; No EID

    { .Name = MCP251XFD_FIFO5, .Size = MCP251XFD_FIFO_4_MESSAGE_DEEP, .Payload = MCP251XFD_PAYLOAD_8BYTE,
    .Direction = MCP251XFD_TRANSMIT_FIFO, .Attempts = MCP251XFD_THREE_ATTEMPTS,
    .Priority = MCP251XFD_MESSAGE_TX_PRIORITY16, .ControlFlags = MCP251XFD_FIFO_NO_RTR_RESPONSE,
    .InterruptFlags = MCP251XFD_FIFO_TX_ATTEMPTS_EXHAUSTED_INT + MCP251XFD_FIFO_TRANSMIT_FIFO_NOT_FULL_INT,
    .RAMInfos = &Ext1_FIFOs_RAMInfos[4], },

    { .Name = MCP251XFD_FIFO6, .Size = MCP251XFD_FIFO_2_MESSAGE_DEEP, .Payload = MCP251XFD_PAYLOAD_8BYTE,
    .Direction = MCP251XFD_TRANSMIT_FIFO, .Attempts = MCP251XFD_THREE_ATTEMPTS,
    .Priority = MCP251XFD_MESSAGE_TX_PRIORITY16, .ControlFlags = MCP251XFD_FIFO_NO_RTR_RESPONSE,
    .InterruptFlags = MCP251XFD_FIFO_TX_ATTEMPTS_EXHAUSTED_INT + MCP251XFD_FIFO_TRANSMIT_FIFO_NOT_FULL_INT,
    .RAMInfos = &Ext1_FIFOs_RAMInfos[5], },

    { .Name = MCP251XFD_FIFO7, .Size = MCP251XFD_FIFO_2_MESSAGE_DEEP, .Payload = MCP251XFD_PAYLOAD_8BYTE,
    .Direction = MCP251XFD_TRANSMIT_FIFO, .Attempts = MCP251XFD_THREE_ATTEMPTS,
    .Priority = MCP251XFD_MESSAGE_TX_PRIORITY16, .ControlFlags = MCP251XFD_FIFO_NO_RTR_RESPONSE,
    .InterruptFlags = MCP251XFD_FIFO_TX_ATTEMPTS_EXHAUSTED_INT + MCP251XFD_FIFO_TRANSMIT_FIFO_NOT_FULL_INT,
    .RAMInfos = &Ext1_FIFOs_RAMInfos[6], },

    { .Name = MCP251XFD_FIFO8, .Size = MCP251XFD_FIFO_2_MESSAGE_DEEP, .Payload = MCP251XFD_PAYLOAD_8BYTE,
    .Direction = MCP251XFD_TRANSMIT_FIFO, .Attempts = MCP251XFD_THREE_ATTEMPTS,
    .Priority = MCP251XFD_MESSAGE_TX_PRIORITY16, .ControlFlags = MCP251XFD_FIFO_NO_RTR_RESPONSE,
    .InterruptFlags = MCP251XFD_FIFO_TX_ATTEMPTS_EXHAUSTED_INT + MCP251XFD_FIFO_TRANSMIT_FIFO_NOT_FULL_INT,
    .RAMInfos = &Ext1_FIFOs_RAMInfos[7], },

};

MCP251XFD_Filter MCP2517FD_Ext1_FilterList[MCP2517FD_EXT1_FILTER_COUNT] =
{
    { .Filter = MCP251XFD_FILTER0, .EnableFilter = true, .Match = MCP251XFD_MATCH_ONLY_SID,
    .AcceptanceID = 0x000, .AcceptanceMask = 0x600, .PointTo = MCP251XFD_FIFO1, }, // 0x000..0x1FF

    { .Filter = MCP251XFD_FILTER1, .EnableFilter = true, .Match = MCP251XFD_MATCH_ONLY_SID,
    .AcceptanceID = 0x200, .AcceptanceMask = 0x600, .PointTo = MCP251XFD_FIFO2, }, // 0x200..0x3FF

    { .Filter = MCP251XFD_FILTER2, .EnableFilter = true, .Match = MCP251XFD_MATCH_ONLY_SID,
    .AcceptanceID = 0x400, .AcceptanceMask = 0x600, .PointTo = MCP251XFD_FIFO3, }, // 0x400..0x5FF

    { .Filter = MCP251XFD_FILTER3, .EnableFilter = true, .Match = MCP251XFD_MATCH_ONLY_SID,
    .AcceptanceID = 0x600, .AcceptanceMask = 0x600, .PointTo = MCP251XFD_FIFO4, }, // 0x600..0x7FF
};

eERRORRESULT ConfigureMCP251XFDDeviceOnEXT1(void)
{
    //--- Initialize Int pins or GPIOs ---
//  MCP251XFD_Ext1_IntPinInit_V71(CANEXT1); // Hardware dependent, not used by driver
//  MCP251XFD_Ext1_Int0Gpio0PinInit_V71(CANEXT1); // Hardware dependent, not used by driver
//  MCP251XFD_Ext1_Int1Gpio1PinInit_V71(CANEXT1); // Hardware dependent, not used by driver
    //--- Configure module on Ext1 ---
    eERRORRESULT ErrorExt1 = ERR__NO_DEVICE_DETECTED;
    ErrorExt1 = Init_MCP251XFD(MCP_CAN1, &MCP2517FDcan1_Config);
    if (ErrorExt1 != ERR_OK) return ErrorExt1;
    ErrorExt1 = MCP251XFD_ConfigureTimeStamp(MCP_CAN1, true, MCP251XFD_TS_CAN20_SOF_CANFD_SOF, TIMESTAMP_TICK(SYSCLK_Ext1), true);
    if (ErrorExt1 != ERR_OK) return ErrorExt1;
    ErrorExt1 = MCP251XFD_ConfigureFIFOList(MCP_CAN1, &MCP2517FD_Ext1_FIFOlist[0], MCP2517FD_EXT1_FIFO_COUNT);
    if (ErrorExt1 != ERR_OK) return ErrorExt1;
    ErrorExt1 = MCP251XFD_ConfigureFilterList(MCP_CAN1, MCP251XFD_D_NET_FILTER_DISABLE, &MCP2517FD_Ext1_FilterList[0], MCP2517FD_EXT1_FILTER_COUNT);
    if (ErrorExt1 != ERR_OK) return ErrorExt1;
    //ErrorExt1 = MCP251XFD_StartCANFD(MCP_CAN1);
    return ErrorExt1;
}

void canDriverInit() {
    ConfigureMCP251XFDDeviceOnEXT1();
}

Thank you very much.

stanislavZemek commented 1 month ago

Hello again. I added these functions as extern for the linker to the library .c file and it seems the problem is "solved". What do you think about this cheap solution? :-D Thank you.

extern eERRORRESULT MCP251XFD_WriteRAM32(MCP251XFD pComp, uint16_t address, uint32_t data); extern eERRORRESULT MCP251XFD_ReadRAM32(MCP251XFD pComp, uint16_t address, uint32_t data); extern eERRORRESULT MCP251XFD_WriteSFR8(MCP251XFD pComp, uint16_t address, const uint8_t data); extern eERRORRESULT MCP251XFD_ReadSFR8(MCP251XFD pComp, uint16_t address, uint8_t data); extern eERRORRESULT MCP251XFD_ReadSFR32(MCP251XFD pComp, uint16_t address, uint32_t data); extern eERRORRESULT MCP251XFD_WriteSFR32(MCP251XFD pComp, uint16_t address, const uint32_t data); extern eERRORRESULT MCP251XFD_WriteSFR16(MCP251XFD pComp, uint16_t address, const uint16_t data); extern eERRORRESULT MCP251XFD_ReadSFR16(MCP251XFD pComp, uint16_t address, uint16_t data);

Emandhal commented 1 month ago

Hello, I think it is a recursive include of files. Can you details me the files and the includes of theses files please?

For your cheap solution, it can work but normally, you do not need to do this.

Thanks

stanislavZemek commented 1 month ago

Hi Emandhal,

thank you for your quick reply. Here is files tree: Screenshot from 2024-05-30 09-12-10

Here are Includes: Screenshot from 2024-05-30 09-14-06

Currently I am trying to get working the SPI communication. I have some issue with "ERR__PARAMTER_ERROR". But I don't think it's caused by my "cheap solution". It's probably caused by wrong implementation in my code.

Thank you for your help.

Emandhal commented 1 month ago

Hello,

Where do you put the "spiInitCan1" and "spiTransferCan1" functions? The ERR__PARAMETER_ERROR is more related to a wrong function's argument or a wrong configuration

Thanks

stanislavZemek commented 1 month ago

Hello, spiInitCan1 and spiTransferCan1 is in main.c where is initialization code. Now it seems that I successfully switched MCP to CAN2.0 mode - so I will try now to TX some messages through the can bus. In debugger I found out that I had "NULL" as CRC call function.. Thank you for your help.

Emandhal commented 1 month ago

Yes, you put SPI communications with CRC (.DriverConfig = MCP251XFD_DRIVER_USE_READ_WRITE_CRC | MCP251XFD_DRIVER_USE_SAFE_WRITE) but you put .fnComputeCRC16 = NULL so the driver can't compute CRC. Use this instead: .fnComputeCRC16 = ComputeCRC16CMS. This function is in the CRC_16_CMS.c/.h

For the extern fix, let me think about it. Currently I have no computer to do some tests with your architecture

stanislavZemek commented 1 month ago

Yes, I did that as you mentioned now. There is probably some problem with linker settings in MX Cube IDE, because I notice this error with my own libraries as well. Thank you for your willingness to help. :+1:

stanislavZemek commented 1 month ago

Hi Emandhal,

unfortunately I probably have a problem with the understanding of MCP2518FD chip.. Previously I tried to use original microchip driver which I edited for STM32. I had a problem that when I periodically transmitted some message (each 100 ms) then after few transmitions (10-150 transmissions randomly) MCP stops transmitting without understandable reason. Internal can controllers inside the STM32 and the PIC32 are working properly with the same wire connection setup (I tested them before MCP2518FD testing). I'm receiving messages via candump which is linked to can0 device (Peak Systems cable). With your different driver I have exactly the same problem, so the problem is not probably inside the driver, but my implementation or chip controlling is a problem. Chip state description: when sending is normally working then eMCP251XFD_TXRXErrorStatus is "TX_NO_ERROR" and InterruptCode is "TRANSMIT_EVENT_FIFO". When the sending is stop working then eMCP251XFD_TXRXErrorStatus is "TX_BUS_OFF_STATE", Interrupt Code is "NO_INTERRUPT" state, InterruptOnFIFO is equal to 0x0 and tec, rec is equal to 0. When I try to transmit something in this state then FIFOStatus is in "TX_FIFO_FULL". When I used original Microchip driver, the problem was "fixed" when I reinitialized FIFOs in TX_BUS_OFF_STATE, but it's not properly solution.. :D Somewhere is probably some big fault on my side and I already spended around two weeks to handle with this error without success, because previous used driver from Microchip had exactly the same stat as your driver. In attachment is code which I tried to get working. Parts of code is copied from your examples only for test. For now I am trying to get working transmitting on CAN 2.0B.

Used board with MCP2518FD: https://www.waveshare.com/2-ch-can-fd-hat.htm

Thank you very much. main.zip

Emandhal commented 1 month ago

Ok, how did you configure your board, I mean the jumpers? How do you connect your board (from the CANbus perspective)?

The bus off state is when there are too many errors on the bus (See the §11.0 of the MCP25XXFD Family Reference Manual (DS20005678D)). Can you execute the MCP251XFD_GetTransmitReceiveErrorCountAndStatus and MCP251XFD_GetBusDiagnostic functions at start of CANbus and when you get the bus OFF please?

stanislavZemek commented 1 month ago

both jumpers are on 3.3V. Resistors for configuring board are in default state, jumper for 120 Ohm resistor is "ON" and can be measured between CAN_L and CAN_H. It's connected by D-SUB connector to the peak adapter directly. And the cable is tested with internal- microcontroller's CAN bus controller. I tried to find solution in the reference manual. It's strange that before error is tec and rec on 0 and after error is tec and rec on 0 as well. GetBusDiagnostic got me zeroes in all bits EFMSGCNT included in diagRegister1. On the diagRegister0 was the same.. zeroes.. Unfortunately currently I can't recheck ReceiveErrorCountAndStatus, because I am not at home currently. Will be back on Sunday. I can't remember what was in status, but receiver errors was 0 and transmittion errors was 0 as well. Thank you.

Emandhal commented 1 month ago

I found a F1 board, I will try to find the extern problem maybe on saturday. Is your PEAK in listen only?

stanislavZemek commented 1 month ago

Oh, nice. Thank you. Honestly, I have never switch the PEAK to listen mode in past. For receiving I use candump from cantools package for linux.

stanislavZemek commented 1 month ago

Hello Emandhal,

I checked statement of MCP when PEAK was in listen-only mode and when PEAK was in normal mode and here is the result:

1) Listen only mode on the PEAK cable:

2) Normal mode on the PEAK cable:

The behavior of the MCP is very strange, but I believe that there is some parameter which I did not properly set. For now I did not find where could be a problem. Thank you.

Emandhal commented 1 month ago

Hi, Sorry, I didn't have time to test with my F1 board. Anyway, your problem can be a bitrate configuration, but not sure. Can you give me your register CiNBTCFG, CiDBTCFG and CiTDC please, and/or the MCP251XFD_BitTimeConfig if you have one? Thanks

stanislavZemek commented 1 month ago

Hi Emandhal, thank you for your reply. Don't worry, I am happy that you're trying to help me. With can bus timing I tried a lot of changes, but without success. Here is my timing config, but without CiDBTCFG and CiTDC, because they are not set for 2.0 Mode.

Bit Time Config: Screenshot from 2024-06-03 19-26-05

Bit Time Config (readable): Screenshot from 2024-06-03 19-26-20

NBTCFG: Screenshot from 2024-06-03 19-27-36

Config code: MCP251XFD_Config MCP2517FDcan1_Config = { //--- Controller clocks --- .XtalFreq = 0, // CLKIN is not a crystal .OscFreq = 40000000, // CLKIN is a 40MHz oscillator .SysclkConfig = MCP251XFD_SYSCLK_IS_CLKIN, // szemek: this parameter is for clk divider (keep or /2 or /10) .ClkoPinConfig = MCP251XFD_CLKO_SOF, .SYSCLK_Result = &SYSCLK_Ext1, // szemek: important note -> is necessary to check if the clk properly set or not //--- CAN configuration --- .NominalBitrate = 250000, // Nominal Bitrate to 1Mbps .DataBitrate = MCP251XFD_NO_CANFD, // Data Bitrate to 2Mbps - szemek: no bitrate, because canfd is not used .BitTimeStats = &MCP2517FDcan1_bitTimeStats, .Bandwidth = MCP251XFD_DELAY_8BIT_TIMES, //MCP251XFD_DELAY_8BIT_TIMES, // szemek: could be set to zero if it's ok .ControlFlags = MCP251XFD_CAN_RESTRICTED_MODE_ON_ERROR | MCP251XFD_CAN_ESI_REFLECTS_ERROR_STATUS | MCP251XFD_CAN_RESTRICTED_RETRANS_ATTEMPTS | MCP251XFD_CANFD_BITRATE_SWITCHING_DISABLE //| MCP251XFD_CAN_PROTOCOL_EXCEPT_AS_FORM_ERROR //| MCP251XFD_CANFD_USE_ISO_CRC | MCP251XFD_CANFD_USE_RRS_BIT_AS_SID11, //--- GPIOs and Interrupts pins --- .GPIO0PinMode = MCP251XFD_PIN_AS_GPIO0_OUT, .GPIO1PinMode = MCP251XFD_PIN_AS_GPIO1_OUT, .INTsOutMode = MCP251XFD_PINS_PUSHPULL_OUT, .TXCANOutMode = MCP251XFD_PINS_PUSHPULL_OUT, //--- Interrupts --- .SysInterruptFlags = MCP251XFD_INT_ENABLE_ALL_EVENTS, //MCP251XFD_INT_ENABLE_ALL_EVENTS };

I removed from raspberry hat galvanic insulation to make sure that there is no problem caused by power of transceiver or TX/RX via isolator. Without success.. Thank you for your help again.

Emandhal commented 1 month ago

Hi,

Sorry for the delay, all seems good on the bitrate side. I see no problem on the configuration side either. We need a digital analyzer to see what happens when a bad frame is sent.

key commented 1 month ago

I had same issue on esp-idf platform. I'll try to add extern to .c file.

stanislavZemek commented 1 month ago

Hi key,

I am happy that there is some solution. It's necessary to add extern for each used function and its subfunctions.

Standa.

stanislavZemek commented 1 month ago

Hi Emandhal,

Don't worry, and thank you for your time. It seems that I have probably solved the problem!

The whole issue was with the SPI timing. I didn't set the correct clock source for the STM32 and had it set to use the internal clock, which lacks proper accuracy. As a result, the clock of the 40MHz crystal of the MCP2518FD and the internal clock of the STM32, with its low accuracy, were sometimes out of phase, causing the CAN bus to malfunction. When I started using an external resonator, the problem disappeared.

In the official datasheet, I found that the SPI clock must be equal to or less than the SYSCLOCK of the MCP2518FD divided by 2. Based on this fact, I realized the importance of clock accuracy because it directly affects whole chip..

Thank you for your help :+1: By the way: during whole night communication was working with no error. Tested only with 2% bus load on 250k..

Emandhal commented 1 month ago

Hi stanislav and Key,

Good new from your side. I was almost correct to see a bus timing problem. For the SPI, be careful, Microchip add an erratum for the SPI clock and it is more 85% of SYSCLOCK divided by 2 for optimal work (following MCP2517FD: DS80000792C (§5), MCP2518FD: DS80000789C (§4), MCP251863: DS80000984A (§4)).

For the external, I have to find some time to test on these platform (I have no ESP) because on others platform I have no problem at all.

stanislavZemek commented 1 month ago

Yeah you was right with the timing. Thank you for the information about SYSCLK in errata. It's interesting that I can't reach more than 20% load of canbus with your library. But I think it's not a problem in most cases. Thank you for your nice job around the library. :+1:

Emandhal commented 1 month ago

I think this is because you use the safe write.

    .DriverConfig = MCP251XFD_DRIVER_USE_READ_WRITE_CRC
    | MCP251XFD_DRIVER_USE_SAFE_WRITE
    | MCP251XFD_DRIVER_ENABLE_ECC
    | MCP251XFD_DRIVER_INIT_SET_RAM_AT_0
    | MCP251XFD_DRIVER_CLEAR_BUFFER_BEFORE_READ,

If the safe SPI is not mandatory, remove the MCP251XFD_DRIVER_USE_READ_WRITE_CRC and MCP251XFD_DRIVER_USE_SAFE_WRITE configurations The SPI safe write use a lot of encapsulation bytes and writes only 4 bytes in RAM at a time

Emandhal commented 1 month ago

stanislav and Key, I have a question: Do you compile in C++? If so, it's better to add static inline to pursue C++ behavior. I mean add static before each inline of the MCP251XFD.h file.

Let me know if it works

key commented 1 month ago

Hi Emandhal,

Thanks for your comment.

I added extern to the .c file and it compiles OK. My development environment is ESP-IDF v5.1.4 using pure C (not C++).

Well, I tried compiling with static before inline. My environment is not C++, but compiled succeeded!

The difference from the original code is as follows.

Only in ../MCP251XFD_orig: .git
diff -ubr ../MCP251XFD_orig/MCP251XFD.c ./components/esp_mcp251xfd/MCP251XFD/MCP251XFD.c
--- ../MCP251XFD_orig/MCP251XFD.c   2024-05-31 12:41:42
+++ ./components/esp_mcp251xfd/MCP251XFD/MCP251XFD.c    2024-06-07 15:44:53
@@ -23,6 +23,14 @@
 //-----------------------------------------------------------------------------

+// extern eERRORRESULT MCP251XFD_WriteRAM32(MCP251XFD *pComp, uint16_t address, uint32_t data);
+// extern eERRORRESULT MCP251XFD_ReadRAM32(MCP251XFD *pComp, uint16_t address, uint32_t *data);
+// extern eERRORRESULT MCP251XFD_WriteSFR8(MCP251XFD *pComp, uint16_t address, const uint8_t data);
+// extern eERRORRESULT MCP251XFD_ReadSFR8(MCP251XFD *pComp, uint16_t address, uint8_t *data);
+// extern eERRORRESULT MCP251XFD_ReadSFR32(MCP251XFD *pComp, uint16_t address, uint32_t *data);
+// extern eERRORRESULT MCP251XFD_WriteSFR32(MCP251XFD *pComp, uint16_t address, const uint32_t data);
+// extern eERRORRESULT MCP251XFD_WriteSFR16(MCP251XFD *pComp, uint16_t address, const uint16_t data);
+// extern eERRORRESULT MCP251XFD_ReadSFR16(MCP251XFD *pComp, uint16_t address, uint16_t *data);

diff -ubr ../MCP251XFD_orig/MCP251XFD.h ./components/esp_mcp251xfd/MCP251XFD/MCP251XFD.h
--- ../MCP251XFD_orig/MCP251XFD.h   2024-05-31 12:41:42
+++ ./components/esp_mcp251xfd/MCP251XFD/MCP251XFD.h    2024-06-07 15:44:40
@@ -3630,7 +3630,7 @@
  * @param[out] *data Is where the data will be stored
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ReadSFR8(MCP251XFD *pComp, uint16_t address, uint8_t* data)
+static inline eERRORRESULT MCP251XFD_ReadSFR8(MCP251XFD *pComp, uint16_t address, uint8_t* data)
 {
   return MCP251XFD_ReadData(pComp, address, data, 1);
 }
@@ -3642,7 +3642,7 @@
  * @param[out] *data Is where the data will be stored
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ReadSFR16(MCP251XFD *pComp, uint16_t address, uint16_t* data)
+static inline eERRORRESULT MCP251XFD_ReadSFR16(MCP251XFD *pComp, uint16_t address, uint16_t* data)
 {
   if (data == NULL) return ERR__PARAMETER_ERROR;
   MCP251XFD_uint16t_Conv Tmp;
@@ -3658,7 +3658,7 @@
  * @param[out] *data Is where the data will be stored
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ReadSFR32(MCP251XFD *pComp, uint16_t address, uint32_t* data)
+static inline eERRORRESULT MCP251XFD_ReadSFR32(MCP251XFD *pComp, uint16_t address, uint32_t* data)
 {
   if (data == NULL) return ERR__PARAMETER_ERROR;
   MCP251XFD_uint32t_Conv Tmp;
@@ -3674,7 +3674,7 @@
  * @param[out] *data Is where the data will be stored
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ReadRAM32(MCP251XFD *pComp, uint16_t address, uint32_t* data)
+static inline eERRORRESULT MCP251XFD_ReadRAM32(MCP251XFD *pComp, uint16_t address, uint32_t* data)
 {
   if (data == NULL) return ERR__PARAMETER_ERROR;
   MCP251XFD_uint32t_Conv Tmp;
@@ -3701,7 +3701,7 @@
  * @param[in] data Is the data to write
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_WriteSFR8(MCP251XFD *pComp, uint16_t address, const uint8_t data)
+static inline eERRORRESULT MCP251XFD_WriteSFR8(MCP251XFD *pComp, uint16_t address, const uint8_t data)
 {
   return MCP251XFD_WriteData(pComp, address, &data, 1);
 }
@@ -3713,7 +3713,7 @@
  * @param[in] data Is the data to write
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_WriteSFR16(MCP251XFD *pComp, uint16_t address, const uint16_t data)
+static inline eERRORRESULT MCP251XFD_WriteSFR16(MCP251XFD *pComp, uint16_t address, const uint16_t data)
 {
   MCP251XFD_uint16t_Conv Tmp;
   Tmp.Uint16 = data;
@@ -3728,7 +3728,7 @@
  * @param[in] data Is the data to write
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_WriteSFR32(MCP251XFD *pComp, uint16_t address, const uint32_t data)
+static inline eERRORRESULT MCP251XFD_WriteSFR32(MCP251XFD *pComp, uint16_t address, const uint32_t data)
 {
   MCP251XFD_uint32t_Conv Tmp;
   Tmp.Uint32 = data;
@@ -3743,7 +3743,7 @@
  * @param[in] data Is the data to write
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_WriteRAM32(MCP251XFD *pComp, uint16_t address, uint32_t data)
+static inline eERRORRESULT MCP251XFD_WriteRAM32(MCP251XFD *pComp, uint16_t address, uint32_t data)
 {
   MCP251XFD_uint32t_Conv Tmp;
   Tmp.Uint32 = data;
@@ -3779,7 +3779,7 @@
  * @param[in] andFlush Indicate if the TXQ will be flush to the CAN bus right after this message
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_TransmitMessageObjectToTXQ(MCP251XFD *pComp, uint8_t* messageObjectToSend, uint8_t objectSize, bool andFlush)
+static inline eERRORRESULT MCP251XFD_TransmitMessageObjectToTXQ(MCP251XFD *pComp, uint8_t* messageObjectToSend, uint8_t objectSize, bool andFlush)
 {
   return MCP251XFD_TransmitMessageObjectToFIFO(pComp, messageObjectToSend, objectSize, MCP251XFD_TXQ, andFlush);
 }
@@ -3807,7 +3807,7 @@
  * @param[in] andFlush Indicate if the TXQ will be flush to the CAN bus right after this message
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_TransmitMessageToTXQ(MCP251XFD *pComp, MCP251XFD_CANMessage* messageToSend, bool andFlush)
+static inline eERRORRESULT MCP251XFD_TransmitMessageToTXQ(MCP251XFD *pComp, MCP251XFD_CANMessage* messageToSend, bool andFlush)
 {
   return MCP251XFD_TransmitMessageToFIFO(pComp, messageToSend, MCP251XFD_TXQ, andFlush);
 }
@@ -3835,7 +3835,7 @@
  * @param[in] objectSize Is the size of the message object (with its data). This value needs to be modulo 4
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ReceiveMessageObjectFromTEF(MCP251XFD *pComp, uint8_t* messageObjectGet, uint8_t objectSize)
+static inline eERRORRESULT MCP251XFD_ReceiveMessageObjectFromTEF(MCP251XFD *pComp, uint8_t* messageObjectGet, uint8_t objectSize)
 {
   return MCP251XFD_ReceiveMessageObjectFromFIFO(pComp, messageObjectGet, objectSize, MCP251XFD_TEF);
 }
@@ -3864,7 +3864,7 @@
  * @param[out] *timeStamp Is the returned TimeStamp of the message (can be set to NULL if the TimeStamp is not set in the TEF)
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ReceiveMessageFromTEF(MCP251XFD *pComp, MCP251XFD_CANMessage* messageGet, uint32_t* timeStamp)
+static inline eERRORRESULT MCP251XFD_ReceiveMessageFromTEF(MCP251XFD *pComp, MCP251XFD_CANMessage* messageGet, uint32_t* timeStamp)
 {
   return MCP251XFD_ReceiveMessageFromFIFO(pComp, messageGet, MCP251XFD_PAYLOAD_8BYTE, timeStamp, MCP251XFD_TEF); // Here the payload will not be used inside the function
 }
@@ -3895,7 +3895,7 @@
  * @param[in] *pComp Is the pointed structure of the device where the CRC status will be cleared
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ClearCRCEvents(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_ClearCRCEvents(MCP251XFD *pComp)
 {
   return MCP251XFD_WriteSFR8(pComp, RegMCP251XFD_CRC_FLAGS, MCP251XFD_CRC_NO_EVENT); // Write cleared status of the CRC register (third byte only)
 }
@@ -3929,7 +3929,7 @@
  * @param[in] *pComp Is the pointed structure of the device where the ECC status will be cleared
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ClearECCEvents(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_ClearECCEvents(MCP251XFD *pComp)
 {
   return MCP251XFD_WriteSFR8(pComp, RegMCP251XFD_ECCSTAT_FLAGS, MCP251XFD_CRC_NO_EVENT); // Write cleared status of the ECC register (first byte only)
 }
@@ -4058,7 +4058,7 @@
  * @param[in] *pComp Is the pointed structure of the device to be used
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_StartCAN20(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_StartCAN20(MCP251XFD *pComp)
 {
   return MCP251XFD_RequestOperationMode(pComp, MCP251XFD_NORMAL_CAN20_MODE, false);
 }
@@ -4069,7 +4069,7 @@
  * @param[in] *pComp Is the pointed structure of the device to be used
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_StartCANFD(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_StartCANFD(MCP251XFD *pComp)
 {
   return MCP251XFD_RequestOperationMode(pComp, MCP251XFD_NORMAL_CANFD_MODE, false);
 }
@@ -4080,7 +4080,7 @@
  * @param[in] *pComp Is the pointed structure of the device to be used
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_StartCANListenOnly(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_StartCANListenOnly(MCP251XFD *pComp)
 {
   return MCP251XFD_RequestOperationMode(pComp, MCP251XFD_LISTEN_ONLY_MODE, false);
 }
@@ -4233,7 +4233,7 @@
  * @param[in] *pComp Is the pointed structure of the device to be used
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ResetTEF(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_ResetTEF(MCP251XFD *pComp)
 {
   return MCP251XFD_ResetFIFO(pComp, MCP251XFD_TEF);
 }
@@ -4244,7 +4244,7 @@
  * @param[in] *pComp Is the pointed structure of the device to be used
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ResetTXQ(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_ResetTXQ(MCP251XFD *pComp)
 {
   return MCP251XFD_ResetFIFO(pComp, MCP251XFD_TXQ);
 }
@@ -4265,7 +4265,7 @@
  * @param[in] *pComp Is the pointed structure of the device to be used
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_UpdateTEF(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_UpdateTEF(MCP251XFD *pComp)
 {
   return MCP251XFD_UpdateFIFO(pComp, MCP251XFD_TEF, false);
 }
@@ -4277,7 +4277,7 @@
  * @param[in] andFlush Indicate if the TXQ must be flush too
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_UpdateTXQ(MCP251XFD *pComp, bool andFlush)
+static inline eERRORRESULT MCP251XFD_UpdateTXQ(MCP251XFD *pComp, bool andFlush)
 {
   return MCP251XFD_UpdateFIFO(pComp, MCP251XFD_TXQ, andFlush);
 }
@@ -4297,7 +4297,7 @@
  * @param[in] *pComp Is the pointed structure of the device to be used
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_FlushTXQ(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_FlushTXQ(MCP251XFD *pComp)
 {
   return MCP251XFD_FlushFIFO(pComp, MCP251XFD_TXQ);
 }
@@ -4308,7 +4308,7 @@
  * @param[in] *pComp Is the pointed structure of the device to be used
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_FlushAllFIFO(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_FlushAllFIFO(MCP251XFD *pComp)
 {
   return MCP251XFD_WriteSFR32(pComp, RegMCP251XFD_CiTXREQ, 0xFFFFFFFF);
 }
@@ -4330,7 +4330,7 @@
  * @param[out] *statusFlags Is the return value of status flags
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetTEFStatus(MCP251XFD *pComp, setMCP251XFD_TEFstatus *statusFlags)
+static inline eERRORRESULT MCP251XFD_GetTEFStatus(MCP251XFD *pComp, setMCP251XFD_TEFstatus *statusFlags)
 {
   eERRORRESULT Error = MCP251XFD_GetFIFOStatus(pComp, MCP251XFD_TEF, (setMCP251XFD_FIFOstatus*)statusFlags);
   *statusFlags = (setMCP251XFD_TEFstatus)((*statusFlags) & MCP251XFD_TEF_FIFO_STATUS_MASK);
@@ -4344,7 +4344,7 @@
  * @param[out] *statusFlags Is the return value of status flags
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetTXQStatus(MCP251XFD *pComp, setMCP251XFD_TXQstatus *statusFlags)
+static inline eERRORRESULT MCP251XFD_GetTXQStatus(MCP251XFD *pComp, setMCP251XFD_TXQstatus *statusFlags)
 {
   eERRORRESULT Error = MCP251XFD_GetFIFOStatus(pComp, MCP251XFD_TXQ, (setMCP251XFD_FIFOstatus*)statusFlags);
   *statusFlags = (setMCP251XFD_TXQstatus)((*statusFlags) & MCP251XFD_TXQ_STATUS_MASK);
@@ -4372,7 +4372,7 @@
  * @param[out] *nextAddress Is the next user address of the TEF. This parameter can be NULL if not needed
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetNextMessageAddressTEF(MCP251XFD *pComp, uint32_t *nextAddress)
+static inline eERRORRESULT MCP251XFD_GetNextMessageAddressTEF(MCP251XFD *pComp, uint32_t *nextAddress)
 {
   return MCP251XFD_GetNextMessageAddressFIFO(pComp, MCP251XFD_TEF, nextAddress, NULL);
 }
@@ -4386,7 +4386,7 @@
  * @param[out] *nextIndex Is the next user index of the TXQ. This parameter can be NULL if not needed
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetNextMessageAddressTXQ(MCP251XFD *pComp, uint32_t *nextAddress, uint8_t *nextIndex)
+static inline eERRORRESULT MCP251XFD_GetNextMessageAddressTXQ(MCP251XFD *pComp, uint32_t *nextAddress, uint8_t *nextIndex)
 {
   return MCP251XFD_GetNextMessageAddressFIFO(pComp, MCP251XFD_TXQ, nextAddress, nextIndex);
 }
@@ -4416,7 +4416,7 @@
  * @param[in] interruptFlags Is the interrupt flags to change (mentionned flags will be set and the others will be cleared)
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_SetTEFinterruptConfiguration(MCP251XFD *pComp, eMCP251XFD_FIFOIntFlags interruptFlags)
+static inline eERRORRESULT MCP251XFD_SetTEFinterruptConfiguration(MCP251XFD *pComp, eMCP251XFD_FIFOIntFlags interruptFlags)
 {
   return MCP251XFD_SetFIFOinterruptConfiguration(pComp, MCP251XFD_TEF, interruptFlags);
 }
@@ -4427,7 +4427,7 @@
  * @param[in] interruptFlags Is the interrupt flags to change (mentionned flags will be set and the others will be cleared)
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_SetTXQinterruptConfiguration(MCP251XFD *pComp, eMCP251XFD_FIFOIntFlags interruptFlags)
+static inline eERRORRESULT MCP251XFD_SetTXQinterruptConfiguration(MCP251XFD *pComp, eMCP251XFD_FIFOIntFlags interruptFlags)
 {
   return MCP251XFD_SetFIFOinterruptConfiguration(pComp, MCP251XFD_TXQ, interruptFlags);
 }
@@ -4488,7 +4488,7 @@
  * @param[out] *name Is the returned name of the FIFO that generate an interrupt
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetCurrentReceiveFIFONameInterrupt(MCP251XFD *pComp, eMCP251XFD_FIFO *name)
+static inline eERRORRESULT MCP251XFD_GetCurrentReceiveFIFONameInterrupt(MCP251XFD *pComp, eMCP251XFD_FIFO *name)
 {
   return MCP251XFD_GetCurrentReceiveFIFONameAndStatusInterrupt(pComp, name, NULL);
 }
@@ -4514,7 +4514,7 @@
  * @param[out] *name Is the returned name of the FIFO that generate an interrupt
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetCurrentTransmitFIFONameInterrupt(MCP251XFD *pComp, eMCP251XFD_FIFO *name)
+static inline eERRORRESULT MCP251XFD_GetCurrentTransmitFIFONameInterrupt(MCP251XFD *pComp, eMCP251XFD_FIFO *name)
 {
   return MCP251XFD_GetCurrentTransmitFIFONameAndStatusInterrupt(pComp, name, NULL);
 }
@@ -4535,7 +4535,7 @@
  * @param[in] *pComp Is the pointed structure of the device to be used
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ClearTEFOverflowEvent(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_ClearTEFOverflowEvent(MCP251XFD *pComp)
 {
   return MCP251XFD_ClearFIFOEvents(pComp, MCP251XFD_TEF, MCP251XFD_TEF_FIFO_OVERFLOW);
 }
@@ -4548,7 +4548,7 @@
  * @param[in] name Is the name of the FIFO where event will be cleared
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ClearFIFOOverflowEvent(MCP251XFD *pComp, eMCP251XFD_FIFO name)
+static inline eERRORRESULT MCP251XFD_ClearFIFOOverflowEvent(MCP251XFD *pComp, eMCP251XFD_FIFO name)
 {
   return MCP251XFD_ClearFIFOEvents(pComp, name, MCP251XFD_RX_FIFO_OVERFLOW);
 }
@@ -4561,7 +4561,7 @@
  * @param[in] name Is the name of the FIFO where event will be cleared
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ClearFIFOAttemptsEvent(MCP251XFD *pComp, eMCP251XFD_FIFO name)
+static inline eERRORRESULT MCP251XFD_ClearFIFOAttemptsEvent(MCP251XFD *pComp, eMCP251XFD_FIFO name)
 {
   return MCP251XFD_ClearFIFOEvents(pComp, name, MCP251XFD_TX_FIFO_ATTEMPTS_EXHAUSTED);
 }
@@ -4572,7 +4572,7 @@
  * @param[in] *pComp Is the pointed structure of the device to be used
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_ClearTXQAttemptsEvent(MCP251XFD *pComp)
+static inline eERRORRESULT MCP251XFD_ClearTXQAttemptsEvent(MCP251XFD *pComp)
 {
   return MCP251XFD_ClearFIFOEvents(pComp, MCP251XFD_TXQ, MCP251XFD_TXQ_ATTEMPTS_EXHAUSTED);
 }
@@ -4594,7 +4594,7 @@
  * @param[out] *interruptPending Is the return of the receive pending interrupt of all FIFOs
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetReceivePendingInterruptStatusOfAllFIFO(MCP251XFD *pComp, setMCP251XFD_InterruptOnFIFO* interruptPending)
+static inline eERRORRESULT MCP251XFD_GetReceivePendingInterruptStatusOfAllFIFO(MCP251XFD *pComp, setMCP251XFD_InterruptOnFIFO* interruptPending)
 {
   if (interruptPending == NULL) return ERR__PARAMETER_ERROR;
   return MCP251XFD_GetReceiveInterruptStatusOfAllFIFO(pComp, interruptPending, NULL);
@@ -4607,7 +4607,7 @@
  * @param[out] *overflowStatus Is the return of the receive overflow pending interrupt of all FIFOs
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetReceiveOverflowInterruptStatusOfAllFIFO(MCP251XFD *pComp, setMCP251XFD_InterruptOnFIFO* overflowStatus)
+static inline eERRORRESULT MCP251XFD_GetReceiveOverflowInterruptStatusOfAllFIFO(MCP251XFD *pComp, setMCP251XFD_InterruptOnFIFO* overflowStatus)
 {
   if (overflowStatus == NULL) return ERR__PARAMETER_ERROR;
   return MCP251XFD_GetReceiveInterruptStatusOfAllFIFO(pComp, NULL, overflowStatus);
@@ -4630,7 +4630,7 @@
  * @param[out] *interruptPending Is the return of the transmit pending interrupt of all FIFOs
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetTransmitPendingInterruptStatusOfAllFIFO(MCP251XFD *pComp, setMCP251XFD_InterruptOnFIFO* interruptPending)
+static inline eERRORRESULT MCP251XFD_GetTransmitPendingInterruptStatusOfAllFIFO(MCP251XFD *pComp, setMCP251XFD_InterruptOnFIFO* interruptPending)
 {
   if (interruptPending == NULL) return ERR__PARAMETER_ERROR;
   return MCP251XFD_GetReceiveInterruptStatusOfAllFIFO(pComp, interruptPending, NULL);
@@ -4643,7 +4643,7 @@
  * @param[out] *attemptStatus Is the return of the transmit attempt exhaust pending interrupt of all FIFOs
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetTransmitAttemptInterruptStatusOfAllFIFO(MCP251XFD *pComp, setMCP251XFD_InterruptOnFIFO* attemptStatus)
+static inline eERRORRESULT MCP251XFD_GetTransmitAttemptInterruptStatusOfAllFIFO(MCP251XFD *pComp, setMCP251XFD_InterruptOnFIFO* attemptStatus)
 {
   if (attemptStatus == NULL) return ERR__PARAMETER_ERROR;
   return MCP251XFD_GetReceiveInterruptStatusOfAllFIFO(pComp, NULL, attemptStatus);
@@ -4708,7 +4708,7 @@
  * @param[out] *transmitErrorCount Is the result of the transmit error count
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetTransmitErrorCount(MCP251XFD *pComp, uint8_t* transmitErrorCount)
+static inline eERRORRESULT MCP251XFD_GetTransmitErrorCount(MCP251XFD *pComp, uint8_t* transmitErrorCount)
 {
   if (transmitErrorCount == NULL) return ERR__PARAMETER_ERROR;
   return MCP251XFD_GetTransmitReceiveErrorCountAndStatus(pComp, transmitErrorCount, NULL, NULL);
@@ -4720,7 +4720,7 @@
  * @param[out] *receiveErrorCount Is the result of the receive error count
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetReceiveErrorCount(MCP251XFD *pComp, uint8_t* receiveErrorCount)
+static inline eERRORRESULT MCP251XFD_GetReceiveErrorCount(MCP251XFD *pComp, uint8_t* receiveErrorCount)
 {
   if (receiveErrorCount == NULL) return ERR__PARAMETER_ERROR;
   return MCP251XFD_GetTransmitReceiveErrorCountAndStatus(pComp, NULL, receiveErrorCount, NULL);
@@ -4732,7 +4732,7 @@
  * @param[out] *status Is the return transmit/receive error status
  * @return Returns an #eERRORRESULT value enum
  */
-inline eERRORRESULT MCP251XFD_GetTransmitReceiveErrorStatus(MCP251XFD *pComp, eMCP251XFD_TXRXErrorStatus* status)
+static inline eERRORRESULT MCP251XFD_GetTransmitReceiveErrorStatus(MCP251XFD *pComp, eMCP251XFD_TXRXErrorStatus* status)
 {
   if (status == NULL) return ERR__PARAMETER_ERROR;
   return MCP251XFD_GetTransmitReceiveErrorCountAndStatus(pComp, NULL, NULL, status);
Emandhal commented 1 month ago

Hi key,

I understand, inline alone is ambiguous for some compilers. I will add static in a new commit soon to correct this. Thanks for your help

stanislavZemek commented 1 month ago

I think this is because you use the safe write.

  .DriverConfig = MCP251XFD_DRIVER_USE_READ_WRITE_CRC
  | MCP251XFD_DRIVER_USE_SAFE_WRITE
  | MCP251XFD_DRIVER_ENABLE_ECC
  | MCP251XFD_DRIVER_INIT_SET_RAM_AT_0
  | MCP251XFD_DRIVER_CLEAR_BUFFER_BEFORE_READ,

If the safe SPI is not mandatory, remove the MCP251XFD_DRIVER_USE_READ_WRITE_CRC and MCP251XFD_DRIVER_USE_SAFE_WRITE configurations The SPI safe write use a lot of encapsulation bytes and writes only 4 bytes in RAM at a time

Hi Emandhal,

thank you. I will test without these parameters. I checked can bus busy, because I need to retransfer a lot of data for UDS protocol from one can bus to another. Yes, the problem was specifically with "inline". Have a nice weeeknd,

Emandhal commented 4 weeks ago

Hi stanislav and Key, I made a commit for the inline. Check and close if it is good for you.

Thanks

key commented 4 weeks ago

Hi Emandhal,

It compiles ok now in my environment. Thank you!

stanislavZemek commented 3 weeks ago

Hello Emandhal,

thank you very much for your quick commit. Now it's working properly on STM32 as well. Based on your information I tried to improve bus load with MCP2518FD and I reached exactly the same speed with your well documented library as with the original not-documented driver from Microchip. I am closing the issue. Thank you.

Standa.