From 96132bf34f3d82b856c547d29a55e564a04e42d3 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Fri, 29 Jul 2022 17:48:27 +0200 Subject: [PATCH 1/2] fixed compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit warning: function declaration isn’t a prototype [-Wstrict-prototypes] --- can.c | 6 ++---- can.h | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/can.c b/can.c index 71edeb7..93ae774 100644 --- a/can.c +++ b/can.c @@ -1,7 +1,5 @@ #include "can.h" #include "avr/interrupt.h" -#include "../dash/lightControl.h" -#include "../daq/heartbeat.h" #include #include @@ -22,7 +20,7 @@ uint8_t lastError = 0; * Reset and configure the AT90 to use CAN. * */ -void initCAN() +void initCAN(void) { // Issue a software reset of the CAN Controller CANGCON |= ( 1 << SWRES ); @@ -57,7 +55,7 @@ void initCAN() * @return free MOB index, otherwise 0xFF * */ -uint8_t getFreeMob() +uint8_t getFreeMob(void) { // This commented out code is to prevent context switching when using this function. // When it's not commented, it caused both CAN RX and TX to fail. The reasons for this are being investigated. diff --git a/can.h b/can.h index 1cdb5d1..53a72ae 100644 --- a/can.h +++ b/can.h @@ -58,9 +58,9 @@ typedef struct uint8_t acknowledgement : 1; } CANErrorStatus; -void initCAN(); +void initCAN(void); -CANErrorStatus getLastCANError(); +CANErrorStatus getLastCANError(void); uint8_t listenForMessage( uint16_t id, uint8_t expectedLength ); @@ -68,4 +68,4 @@ uint8_t getMessage( CANMessage * message ); uint8_t sendCAN( CANMessage* message ); -#endif // CAN_H \ No newline at end of file +#endif // CAN_H From 1301701859282b9a6478e88b10b62e2a1be705d4 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Mon, 8 Aug 2022 13:31:51 +0200 Subject: [PATCH 2/2] sendCAN(): fixed handling of IDs > 0xFF --- can.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/can.c b/can.c index 93ae774..3ef6ecf 100644 --- a/can.c +++ b/can.c @@ -122,8 +122,8 @@ uint8_t sendCAN( CANMessage* message ) // This library currently only supports standard CAN IDs CANIDT4 = 0; CANIDT3 = 0; - CANIDT2 = (uint8_t) message->id << 5; - CANIDT1 = (uint8_t) message->id >> 3; + CANIDT2 = (uint8_t) (message->id << 5); + CANIDT1 = (uint8_t) (message->id >> 3); // Ensure nothing bigger than 8 is written to the CANCDMOB register if( message->length > 8 )