Skip to content

Commit dee8456

Browse files
committed
SAME5x bugfixes
* fix residual uses of hard-coded CAN1 * fix missing return that prevented bad pins from being detected * disable MCP2515 when on SAME5x
1 parent cc0122c commit dee8456

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/CANSAME5x.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ EPioType find_pin(const can_function *table, size_t n, int arduino_pin, int &ins
140140
}
141141
}
142142
}
143+
return (EPioType)-1;
143144
}
144145

145146
} // namespace
@@ -196,7 +197,7 @@ int CANSAME5x::begin(long baudrate) {
196197
{
197198
CAN_TXESC_Type esc = {};
198199
esc.bit.TBDS = CAN_TXESC_TBDS_DATA8_Val;
199-
CAN1->TXESC.reg = esc.reg;
200+
hw->TXESC.reg = esc.reg;
200201
}
201202

202203
// Set up TX buffer
@@ -205,7 +206,7 @@ int CANSAME5x::begin(long baudrate) {
205206
bc.bit.TBSA = (uint32_t)state->tx_buffer;
206207
bc.bit.NDTB = ADAFRUIT_ZEROCAN_TX_BUFFER_SIZE;
207208
bc.bit.TFQM = 0; // Messages are transmitted in the order submitted
208-
CAN1->TXBC.reg = bc.reg;
209+
hw->TXBC.reg = bc.reg;
209210
}
210211

211212
// All RX data has an 8 byte payload (max)
@@ -274,9 +275,9 @@ int CANSAME5x::begin(long baudrate) {
274275
hw->NBTP.reg = nbtp.reg;
275276

276277
// hardware is ready for use
277-
CAN1->CCCR.bit.CCE = 0;
278-
CAN1->CCCR.bit.INIT = 0;
279-
while (CAN1->CCCR.bit.INIT) {
278+
hw->CCCR.bit.CCE = 0;
279+
hw->CCCR.bit.INIT = 0;
280+
while (hw->CCCR.bit.INIT) {
280281
}
281282

282283
instances[_idx] = this;

src/MCP2515.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Sandeep Mistry. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4-
#ifndef ARDUINO_ARCH_ESP32
4+
#if !defined(ARDUINO_ARCH_ESP32) && !defined(ARDUINO_FEATHER_M4_CAN)
55

66
#include "MCP2515.h"
77

0 commit comments

Comments
 (0)