From c43df38009f3d1a828edc1ae0ba2a9a08a9b01d4 Mon Sep 17 00:00:00 2001 From: fterretf <58686161+fterretf@users.noreply.github.com> Date: Wed, 7 Jun 2023 18:17:30 +0200 Subject: [PATCH] #34 #31 cont --- src/ACAN2517FD.cpp | 4 ++-- src/ACAN2517FD.h | 20 ++++---------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/ACAN2517FD.cpp b/src/ACAN2517FD.cpp index 0ded4da..a326965 100644 --- a/src/ACAN2517FD.cpp +++ b/src/ACAN2517FD.cpp @@ -171,7 +171,7 @@ static uint16_t u16FromBufferAtIndex (uint8_t ioBuffer [], const uint8_t inIndex //---------------------------------------------------------------------------------------------------------------------- -ACAN2517FD::ACAN2517FD (const CanCmn::eCanBusId busId, +ACAN2517FD::ACAN2517FD (const CanCmn::eCanBusFdId busId, const uint8_t inCS, // CS input of MCP2517FD SPIClass & inSPI, // Hardware SPI object const uint8_t inINT) : // INT output of MCP2517FD @@ -351,7 +351,7 @@ uint32_t ACAN2517FD::begin (const ACAN2517FDSettings & inSettings, } } //----------------------------------- Set full speed clock - mSPISettings = SPISettings (inSettings.sysClock () / 2, MSBFIRST, SPI_MODE0) ; + mSPISettings = SPISettings (8000UL*1000, MSBFIRST, SPI_MODE0) ; //----------------------------------- Checking SPI connection is on (with a full speed clock) // We write and read back 2517 RAM at address 0x400 for (uint32_t i=1 ; (i != 0) && (errorCode == 0) ; i <<= 1) { diff --git a/src/ACAN2517FD.h b/src/ACAN2517FD.h index 2cff178..968500e 100644 --- a/src/ACAN2517FD.h +++ b/src/ACAN2517FD.h @@ -27,7 +27,7 @@ class ACAN2517FD { // CONSTRUCTOR //······················································································································ - public: ACAN2517FD (const CanCmn::eCanBusId busId, + public: ACAN2517FD (const CanCmn::eCanBusFdId busId, const uint8_t inCS, // CS input of MCP2517FD SPIClass & inSPI, // Hardware SPI object const uint8_t inINT) ; // INT output of MCP2517FD @@ -137,7 +137,7 @@ class ACAN2517FD { #endif private: SPISettings mSPISettings ; private: SPIClass & mSPI ; - private: CanCmn::eCanBusId mBusId; + private: CanCmn::eCanBusFdId mBusId; private: const uint8_t mCS ; private: const uint8_t mINT ; private: bool mUsesTXQ ; @@ -308,13 +308,7 @@ class ACAN2517FD { } private: inline void assertCS() { switch (mBusId) { - case CanCmn::eCanBusId::eCan0: - digitalWrite(mCS, LOW); - break; - case CanCmn::eCanBusId::eCan1: - _Mux.can1Cs(); - break; - case CanCmn::eCanBusId::eCan2: + case CanCmn::eCanBusFdId::eCanFd2: _Mux.can2Cs(); break; @@ -324,13 +318,7 @@ class ACAN2517FD { } private: inline void deassertCS() { switch (mBusId) { - case CanCmn::eCanBusId::eCan0: - digitalWrite(mCS, HIGH); - break; - case CanCmn::eCanBusId::eCan1: - _Mux.can1UnCs(); - break; - case CanCmn::eCanBusId::eCan2: + case CanCmn::eCanBusFdId::eCanFd2: _Mux.can2UnCs(); break; default: