diff --git a/Protocol/CAN.cpp b/Protocol/CAN.cpp index 5918203..25c4f12 100644 --- a/Protocol/CAN.cpp +++ b/Protocol/CAN.cpp @@ -120,7 +120,7 @@ void CAN::updateTXMessage(Uint16 boxNumber, const CANMessage& message){ // TODO } -void CAN::updateTXMessage(Uint16 boxNumber, const Uint32& message){ // TODO check trs bit and set it at the end if it was here. Once the TRS bit is set for a mailbox and then data is changed in the mailbox using the CDR +void CAN::updateTXMessage(Uint16 boxNumber, const Uint64& message){ // TODO check trs bit and set it at the end if it was here. Once the TRS bit is set for a mailbox and then data is changed in the mailbox using the CDR // bit, the CAN module fails to transmit the new data and transmits the old data instead. To avoid this, // reset transmission in that mailbox using the TRRn bit and set the TRSn bit again. The new data is // then transmitted. @@ -134,7 +134,7 @@ void CAN::updateTXMessage(Uint16 boxNumber, const Uint32& message){ // TODO chec // TODO Add lenght changing? p_MailBox->MDL.all = message; - p_MailBox->MDH.all = message >> 16; + p_MailBox->MDH.all = message >> 32; CanShadow_.CANMC.all = p_CanRegs_->CANMC.all; CanShadow_.CANMC.bit.CDR = 0; @@ -202,7 +202,7 @@ int16 CAN::receiveMsg(Uint16 boxNumber, CANMessage& rxMessage){ // TODO faults j } -int16 CAN::receiveMsg(Uint16 boxNumber, Uint32& rxMessage){ // TODO faults just return -1 +int16 CAN::receiveMsg(Uint16 boxNumber, Uint64& rxMessage){ // TODO faults just return -1 if (boxNumber > 31) { return -1; } Uint32 mboxControl(0); @@ -216,8 +216,9 @@ int16 CAN::receiveMsg(Uint16 boxNumber, Uint32& rxMessage){ // TODO faults just p_CanRegs_->CANRMP.all &= mboxControl; + rxMessage = p_MailBox->MDH.all; + rxMessage = rxMessage << 32; rxMessage = p_MailBox->MDL.all; - rxMessage = (p_MailBox->MDH.all) << 16; bool newMessage; bool lostMessage; diff --git a/Protocol/CAN.h b/Protocol/CAN.h index 8625a44..80cc810 100644 --- a/Protocol/CAN.h +++ b/Protocol/CAN.h @@ -117,10 +117,10 @@ public: void transmitMsg(Uint16 boxNumber, const Uint64& message); void transmitMsg(Uint16 boxNumber, const Uint64& message, const Uint16 dlc); void updateTXMessage(Uint16 boxNumber, const CANMessage& message); - void updateTXMessage(Uint16 boxNumber, const Uint32& message); + void updateTXMessage(Uint16 boxNumber, const Uint64& message); void sendRemoteRequest(Uint16 boxNumber); int16 receiveMsg(Uint16 boxNumber, CANMessage& rxMessage); - int16 receiveMsg(Uint16 boxNumber, Uint32& rxMessage); + int16 receiveMsg(Uint16 boxNumber, Uint64& rxMessage); private: CAN_VARIANT canPort; diff --git a/Protocol/CANConfig.cpp b/Protocol/CANConfig.cpp index f5ca931..0e2a659 100644 --- a/Protocol/CANConfig.cpp +++ b/Protocol/CANConfig.cpp @@ -107,13 +107,13 @@ void CAN::config(Uint16 baudrate, Uint16 flags){ do { CanShadow_.CANES.all = p_CanRegs_->CANES.all; } while(CanShadow_.CANES.bit.CCE != 1 ); - // LSB - 0; MSB - 1 + // MSB - 0; LSB - 1 CanShadow_.CANMC.all = p_CanRegs_->CANMC.all; if (flags & MSB_ENABLE){ - CanShadow_.CANMC.bit.DBO = 1; + CanShadow_.CANMC.bit.DBO = 0; } else - { CanShadow_.CANMC.bit.DBO = 0; } + { CanShadow_.CANMC.bit.DBO = 1; } p_CanRegs_->CANMC.all = CanShadow_.CANMC.all; CanShadow_.CANBTC.all = 0;