Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManuel Coenen <manuel@duet3d.com>2021-01-15 17:52:02 +0300
committerManuel Coenen <manuel@duet3d.com>2021-01-19 13:22:32 +0300
commite48e001033e373a8c59cf7892d7a4b8a5a7c9283 (patch)
tree478ddabd2e224e73d0b17a822c05d92fe2b0919a /src
parented1f834bc57412ab58f3a9abb647e13f11e4b809 (diff)
Fix all compiler bugs (linker still unhappy)
Diffstat (limited to 'src')
-rw-r--r--src/CAN/CanInterface.cpp18
-rw-r--r--src/Comms/PanelDueUpdater.cpp2
-rw-r--r--src/Duet3_V06/Pins_Duet3_V06.h31
-rw-r--r--src/Endstops/LocalZProbe.cpp6
-rw-r--r--src/Fans/LedStripDriver.cpp5
-rw-r--r--src/Hardware/ExceptionHandlers.cpp5
-rw-r--r--src/Hardware/IoPorts.cpp10
-rw-r--r--src/Hardware/NonVolatileMemory.cpp6
-rw-r--r--src/Hardware/SAME70/Devices.cpp53
-rw-r--r--src/Hardware/SAME70/Devices.h6
-rw-r--r--src/Hardware/SharedSpi/SharedSpiDevice.cpp7
-rw-r--r--src/Heating/Sensors/LinearAnalogSensor.cpp6
-rw-r--r--src/Heating/Sensors/Thermistor.cpp6
-rw-r--r--src/Linux/DataTransfer.cpp8
-rw-r--r--src/Movement/StepTimer.cpp5
-rw-r--r--src/Movement/StepperDrivers/TMC51xx.cpp6
-rw-r--r--src/Platform.cpp17
-rw-r--r--src/RepRap.cpp4
-rw-r--r--src/Tasks.cpp2
-rw-r--r--src/bossa/Device.cpp2
-rw-r--r--src/bossa/Device.h4
-rw-r--r--src/bossa/EefcFlash.cpp2
-rw-r--r--src/bossa/EefcFlash.h2
-rw-r--r--src/bossa/Flash.cpp14
-rw-r--r--src/bossa/Flash.h6
-rw-r--r--src/bossa/Flasher.h2
26 files changed, 171 insertions, 64 deletions
diff --git a/src/CAN/CanInterface.cpp b/src/CAN/CanInterface.cpp
index 3105c730..e2bf7950 100644
--- a/src/CAN/CanInterface.cpp
+++ b/src/CAN/CanInterface.cpp
@@ -27,13 +27,13 @@
#include <memory>
-#if SAME5x
+#if SAME5x || SAME70
# define USE_NEW_CAN_DRIVER 1 // use the new CAN driver in CoreN2G
# define SUPPORT_CAN 1 // needed by CanDevice.h
# include <CanDevice.h>
-#elif SAME70
-# define USE_NEW_CAN_DRIVER 0 // Use the CAN driver in Hardware/SAME70
-# include <CanDriver.h>
+# if SAME70
+# include <pmc/pmc.h>
+# endif
#endif
const unsigned int NumCanBuffers = 2 * MaxCanBoards + 10;
@@ -349,7 +349,7 @@ extern "C" [[noreturn]] void CanSenderLoop(void *) noexcept;
extern "C" [[noreturn]] void CanClockLoop(void *) noexcept;
extern "C" [[noreturn]] void CanReceiverLoop(void *) noexcept;
-#if SAME5x
+#if SAME5x || SAME70
static void InitReceiveFilters() noexcept
{
@@ -410,11 +410,11 @@ void CanInterface::Init() noexcept
#if SAME70
# ifdef USE_CAN0
- ConfigurePin(APIN_CAN0_TX);
- ConfigurePin(APIN_CAN0_RX);
+ SetPinFunction(APIN_CAN0_TX, CAN0PinPeriphMode);
+ SetPinFunction(APIN_CAN0_RX, CAN0PinPeriphMode);
# else
- ConfigurePin(APIN_CAN1_TX);
- ConfigurePin(APIN_CAN1_RX);
+ SetPinFunction(APIN_CAN1_TX, CAN1TXPinPeriphMode);
+ SetPinFunction(APIN_CAN1_RX, CAN1RXPinPeriphMode);
# endif
pmc_enable_upll_clock(); // configure_mcan sets up PCLK5 to be the UPLL divided by something, so make sure the UPLL is running
#elif SAME5x
diff --git a/src/Comms/PanelDueUpdater.cpp b/src/Comms/PanelDueUpdater.cpp
index 0a67ccf1..5789501b 100644
--- a/src/Comms/PanelDueUpdater.cpp
+++ b/src/Comms/PanelDueUpdater.cpp
@@ -234,7 +234,7 @@ void PanelDueUpdater::Spin() noexcept
case FlashState::bossaWriteOptions:
{
reprap.GetPlatform().Message(GenericMessage, "Writing PanelDue flash options\n");
- Flash* flash = device->getFlash();
+ BossaFlash* flash = device->getFlash();
flash->setBootFlash(true);
flash->writeOptions();
state = FlashState::bossaReset;
diff --git a/src/Duet3_V06/Pins_Duet3_V06.h b/src/Duet3_V06/Pins_Duet3_V06.h
index df305682..98a0cc47 100644
--- a/src/Duet3_V06/Pins_Duet3_V06.h
+++ b/src/Duet3_V06/Pins_Duet3_V06.h
@@ -87,6 +87,12 @@ constexpr size_t NumSerialChannels = 3; // The number of serial IO channels n
#define SERIAL_AUX_DEVICE Serial
#define SERIAL_AUX2_DEVICE Serial1
+// Shared SPI (USART 1)
+constexpr Pin APIN_USART_SSPI_SCK = PortBPin(13);
+constexpr Pin APIN_USART_SSPI_MOSI = PortBPin(1);
+constexpr Pin APIN_USART_SSPI_MISO = PortBPin(0);
+constexpr GpioPinFunction USARTSSPIPeriphMode = GpioPinFunction::C;
+
constexpr Pin UsbVBusPin = PortCPin(21); // Pin used to monitor VBUS on USB port
// Drivers
@@ -107,8 +113,11 @@ constexpr IRQn TMC51xx_SPI_IRQn = USART1_IRQn;
#define TMC51xx_DmaRxPerid ((uint32_t)DmaTrigSource::usart1rx)
constexpr Pin TMC51xxMosiPin = PortBPin(4);
+constexpr GpioPinFunction TMC51xxMosiPinPeriphMode = GpioPinFunction::D; // FIXME: Check if this is the correct periph
constexpr Pin TMC51xxMisoPin = PortAPin(21);
+constexpr GpioPinFunction TMC51xxSclkPinPeriphMode = GpioPinFunction::A; // FIXME: Check if this is the correct periph
constexpr Pin TMC51xxSclkPin = PortAPin(23);
+constexpr GpioPinFunction TMC51xxMisoPinPeriphMode = GpioPinFunction::A; // FIXME: Check if this is the correct periph
constexpr uint32_t DefaultStandstillCurrentPercent = 71;
@@ -152,6 +161,7 @@ constexpr IRQn SdhcIRQn = HSMCI_IRQn;
constexpr Pin DotStarMosiPin = PortAPin(13);
constexpr Pin DotStarSclkPin = PortAPin(14);
+constexpr GpioPinFunction DotStarPinMode = GpioPinFunction::A;
constexpr uint32_t DotStarClockId = ID_QSPI;
constexpr IRQn DotStarIRQn = QSPI_IRQn;
@@ -273,10 +283,23 @@ bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted) noe
#define SBC_SPI_IRQn SPI1_IRQn
#define SBC_SPI_HANDLER SPI1_Handler
-constexpr Pin APIN_SPI1_MOSI = PortCPin(27);
-constexpr Pin APIN_SPI1_MISO = PortCPin(26);
-constexpr Pin APIN_SPI1_SCK = PortCPin(24);
-constexpr Pin APIN_SPI1_SS0 = PortCPin(25);
+constexpr Pin APIN_SBC_SPI_MOSI = PortCPin(27);
+constexpr Pin APIN_SBC_SPI_MISO = PortCPin(26);
+constexpr Pin APIN_SBC_SPI_SCK = PortCPin(24);
+constexpr Pin APIN_SBC_SPI_SS0 = PortCPin(25);
+constexpr GpioPinFunction SBCPinPeriphMode = GpioPinFunction::C;
+
+// CAN
+constexpr Pin APIN_CAN0_RX = PortBPin(3);
+constexpr Pin APIN_CAN0_TX = PortBPin(2);
+constexpr GpioPinFunction CAN0PinPeriphMode = GpioPinFunction::A;
+
+constexpr Pin APIN_CAN1_RX = PortCPin(12);
+constexpr GpioPinFunction CAN1RXPinPeriphMode = GpioPinFunction::C;
+constexpr Pin APIN_CAN1_TX = PortDPin(12);
+constexpr GpioPinFunction CAN1TXPinPeriphMode = GpioPinFunction::B;
+
+constexpr unsigned int CanDeviceNumber = 1; // we use CAN1
constexpr Pin SbcTfrReadyPin = PortEPin(2);
// Note, the DMAC peripheral IDs are hard-coded in DataTransfer
diff --git a/src/Endstops/LocalZProbe.cpp b/src/Endstops/LocalZProbe.cpp
index 9b2a593d..2c2b5b29 100644
--- a/src/Endstops/LocalZProbe.cpp
+++ b/src/Endstops/LocalZProbe.cpp
@@ -11,9 +11,13 @@
#include "RepRap.h"
#include "Platform.h"
-#if SAME5x
+#if SAME5x || SAME70 // if using CoreN2G
# include <AnalogIn.h>
+# if SAME5x
using AnalogIn::AdcBits;
+# elif SAME70
+using LegacyAnalogIn::AdcBits;
+# endif
#endif
// Members of class LocalZProbe
diff --git a/src/Fans/LedStripDriver.cpp b/src/Fans/LedStripDriver.cpp
index ed79a2a2..15801436 100644
--- a/src/Fans/LedStripDriver.cpp
+++ b/src/Fans/LedStripDriver.cpp
@@ -24,6 +24,7 @@
# include <hri_mclk_e54.h>
# elif SAME70
# include <sam/drivers/xdmac/xdmac.h>
+# include <pmc/pmc.h>
# endif
#endif
@@ -374,8 +375,8 @@ void LedStripDriver::Init() noexcept
hri_mclk_set_APBCMASK_QSPI_bit(MCLK);
#else
// Set up the USART or QSPI pins for SPI mode. The pins are already set up for SPI in the pins table
- ConfigurePin(DotStarMosiPin);
- ConfigurePin(DotStarSclkPin);
+ SetPinFunction(DotStarMosiPin, DotStarPinMode);
+ SetPinFunction(DotStarSclkPin, DotStarPinMode);
// Enable the clock to the USART or SPI peripheral
pmc_enable_periph_clk(DotStarClockId);
diff --git a/src/Hardware/ExceptionHandlers.cpp b/src/Hardware/ExceptionHandlers.cpp
index ce6d81bc..c1fa5186 100644
--- a/src/Hardware/ExceptionHandlers.cpp
+++ b/src/Hardware/ExceptionHandlers.cpp
@@ -10,6 +10,9 @@
#include <Platform.h>
#include <Hardware/NonVolatileMemory.h>
#include <Cache.h>
+#if SAME70 || SAM4S || SAM4E
+# include <Reset.h>
+#endif
// Perform a software reset. 'stk' points to the exception stack (r0 r1 r2 r3 r12 lr pc xPSR) if the cause is an exception, otherwise it is nullptr.
[[noreturn]] void SoftwareReset(SoftwareResetReason initialReason, const uint32_t *stk) noexcept
@@ -18,7 +21,7 @@
WatchdogReset(); // kick the watchdog
#if SAM4E || SAME70
- rswdt_restart(RSWDT); // kick the secondary watchdog
+ WatchdogResetSecondary(); // kick the secondary watchdog
#endif
Cache::Disable();
diff --git a/src/Hardware/IoPorts.cpp b/src/Hardware/IoPorts.cpp
index 97b9da17..aca4c8b7 100644
--- a/src/Hardware/IoPorts.cpp
+++ b/src/Hardware/IoPorts.cpp
@@ -15,11 +15,15 @@
# include "DuetNG/DueXn.h"
#endif
-#if SAME5x
+#if SAME5x || SAME70 // if using CoreN2G
# include <AnalogIn.h>
-using AnalogIn::AdcBits;
# include <AnalogOut.h>
# include <Interrupts.h>
+# if SAME5x
+using AnalogIn::AdcBits;
+# elif SAME70
+using LegacyAnalogIn::AdcBits;
+# endif
#endif
#if SUPPORT_CAN_EXPANSION
@@ -624,6 +628,8 @@ uint16_t IoPort::ReadAnalog() const noexcept
{
AnalogOut(pin, pwm, freq);
}
+#elif SAME70
+ AnalogOut::Write(pin, pwm, freq);
#else
AnalogOut(pin, pwm, freq);
#endif
diff --git a/src/Hardware/NonVolatileMemory.cpp b/src/Hardware/NonVolatileMemory.cpp
index d36e6dae..45aee49e 100644
--- a/src/Hardware/NonVolatileMemory.cpp
+++ b/src/Hardware/NonVolatileMemory.cpp
@@ -27,7 +27,7 @@ void NonVolatileMemory::EnsureRead() noexcept
# error //TODO
#elif SAM4E || SAM4S || SAME70
const bool cacheEnabled = Cache::Disable();
- flash_read_user_signature(reinterpret_cast<uint32_t*>(&buffer), sizeof(buffer)/sizeof(uint32_t));
+ Flash::ReadUserSignature(reinterpret_cast<uint32_t*>(&buffer), sizeof(buffer)/sizeof(uint32_t));
if (cacheEnabled)
{
Cache::Enable();
@@ -66,7 +66,7 @@ void NonVolatileMemory::EnsureWritten() noexcept
{
// Erase the page
# if SAM4E || SAM4S || SAME70
- flash_erase_user_signature();
+ Flash::EraseUserSignature();
# elif defined(__LPC17xx__)
LPC_EraseSoftwareResetDataSlots(); // erase the last flash sector
# endif
@@ -77,7 +77,7 @@ void NonVolatileMemory::EnsureWritten() noexcept
{
# if SAM4E || SAM4S || SAME70
const bool cacheEnabled = Cache::Disable();
- flash_write_user_signature(reinterpret_cast<const uint32_t*>(&buffer));
+ Flash::WriteUserSignature(reinterpret_cast<const uint32_t*>(&buffer));
if (cacheEnabled)
{
Cache::Enable();
diff --git a/src/Hardware/SAME70/Devices.cpp b/src/Hardware/SAME70/Devices.cpp
index 23a7391e..49316c6a 100644
--- a/src/Hardware/SAME70/Devices.cpp
+++ b/src/Hardware/SAME70/Devices.cpp
@@ -7,28 +7,75 @@
#include "Devices.h"
-AsyncSerial serialUart0(UART2, UART2_IRQn, ID_UART2, 512, 512, [](AsyncSerial*) noexcept { }, [](AsyncSerial*) noexcept { });
+AsyncSerial Serial(UART2, UART2_IRQn, ID_UART2, 512, 512, [](AsyncSerial*) noexcept { }, [](AsyncSerial*) noexcept { });
+USARTClass Serial1(USART2, USART2_IRQn, ID_USART2, 512, 512, [](AsyncSerial*) noexcept { }, [](AsyncSerial*) noexcept { });
+SerialCDC SerialUSB;
constexpr Pin APIN_Serial0_RXD = PortDPin(25);
constexpr Pin APIN_Serial0_TXD = PortDPin(26);
constexpr auto Serial0PinFunction = GpioPinFunction::C;
+constexpr Pin APIN_Serial1_RXD = PortDPin(18);
+constexpr Pin APIN_Serial1_TXD = PortDPin(19);
+constexpr auto Serial1PinFunction = GpioPinFunction::C;
constexpr Pin HcmciMclkPin = PortAPin(25);
constexpr auto HsmciMclkPinFunction = GpioPinFunction::D;
constexpr Pin HsmciOtherPins[] = { PortAPin(26), PortAPin(27), PortAPin(28), PortAPin(30), PortAPin(31) };
constexpr auto HsmciOtherkPinsFunction = GpioPinFunction::C;
-void UART2_Handler(void)
+void UART2_Handler(void) noexcept
{
- serialUart0.IrqHandler();
+ Serial.IrqHandler();
}
+void USART2_Handler(void) noexcept
+{
+ Serial1.IrqHandler();
+}
+
+// Callback glue functions, all called from the USB ISR
+
+// This is called when we are plugged in and connect to a host
+extern "C" bool core_cdc_enable(uint8_t port) noexcept
+{
+ SerialUSB.cdcSetConnected(true);
+ return true;
+}
+
+// This is called when we get disconnected from the host
+extern "C" void core_cdc_disable(uint8_t port) noexcept
+{
+ SerialUSB.cdcSetConnected(false);
+}
+
+// This is called when data has been received
+extern "C" void core_cdc_rx_notify(uint8_t port) noexcept
+{
+ SerialUSB.cdcRxNotify();
+}
+
+// This is called when the transmit buffer has been emptied
+extern "C" void core_cdc_tx_empty_notify(uint8_t port) noexcept
+{
+ SerialUSB.cdcTxEmptyNotify();
+}
+
+// On the SAM4E and SAM4S we use a GPIO pin available to monitor the VBUS state
+void core_vbus_off(CallbackParameter) noexcept
+{
+ SerialUSB.cdcSetConnected(false);
+}
+
void SerialInit() noexcept
{
SetPinFunction(APIN_Serial0_RXD, Serial0PinFunction);
SetPinFunction(APIN_Serial0_TXD, Serial0PinFunction);
SetPullup(APIN_Serial0_RXD, true);
+
+ SetPinFunction(APIN_Serial1_RXD, Serial1PinFunction);
+ SetPinFunction(APIN_Serial1_TXD, Serial1PinFunction);
+ SetPullup(APIN_Serial1_RXD, true);
}
void SdhcInit() noexcept
diff --git a/src/Hardware/SAME70/Devices.h b/src/Hardware/SAME70/Devices.h
index 0e5f3e89..eca9dd54 100644
--- a/src/Hardware/SAME70/Devices.h
+++ b/src/Hardware/SAME70/Devices.h
@@ -10,13 +10,15 @@
#include <AsyncSerial.h>
typedef AsyncSerial UARTClass;
+#include <USARTClass.h>
-extern AsyncSerial serialUart0, serialUart1;
+extern AsyncSerial Serial;
+extern USARTClass Serial1;
#define SUPPORT_USB 1 // needed by SerialCDC.h
#include "SerialCDC.h"
-extern SerialCDC serialUSB;
+extern SerialCDC SerialUSB;
void DeviceInit() noexcept;
diff --git a/src/Hardware/SharedSpi/SharedSpiDevice.cpp b/src/Hardware/SharedSpi/SharedSpiDevice.cpp
index 31b9bebf..c7c9c4d2 100644
--- a/src/Hardware/SharedSpi/SharedSpiDevice.cpp
+++ b/src/Hardware/SharedSpi/SharedSpiDevice.cpp
@@ -15,6 +15,7 @@
# include <peripheral_clk_config.h>
# include <hri_sercom_e54.h>
#elif USART_SPI
+# include <pmc/pmc.h>
# include <usart/usart.h>
#else
# include <spi/spi.h>
@@ -344,9 +345,9 @@ void SharedSpiDevice::Init() noexcept
SetPinFunction(SharedSpiSclkPin, SharedSpiPinFunction);
mainSharedSpiDevice = new SharedSpiDevice(SharedSpiSercomNumber);
#elif USART_SPI
- ConfigurePin(APIN_USART_SSPI_SCK);
- ConfigurePin(APIN_USART_SSPI_MOSI);
- ConfigurePin(APIN_USART_SSPI_MISO);
+ SetPinFunction(APIN_USART_SSPI_SCK, USARTSSPIPeriphMode);
+ SetPinFunction(APIN_USART_SSPI_MOSI, USARTSSPIPeriphMode);
+ SetPinFunction(APIN_USART_SSPI_MISO, USARTSSPIPeriphMode);
mainSharedSpiDevice = new SharedSpiDevice(0);
#else
ConfigurePin(g_APinDescription[APIN_SHARED_SPI_SCK]);
diff --git a/src/Heating/Sensors/LinearAnalogSensor.cpp b/src/Heating/Sensors/LinearAnalogSensor.cpp
index 43d23d9d..ee047188 100644
--- a/src/Heating/Sensors/LinearAnalogSensor.cpp
+++ b/src/Heating/Sensors/LinearAnalogSensor.cpp
@@ -11,9 +11,13 @@
#include "RepRap.h"
#include "Platform.h"
-#if SAME5x // if using CoreN2G
+#if SAME5x || SAME70 // if using CoreN2G
# include <AnalogIn.h>
+# if SAME5x
using AnalogIn::AdcBits;
+# elif SAME70
+using LegacyAnalogIn::AdcBits;
+# endif
#endif
// ADC resolution
diff --git a/src/Heating/Sensors/Thermistor.cpp b/src/Heating/Sensors/Thermistor.cpp
index 709cee0a..4e23458c 100644
--- a/src/Heating/Sensors/Thermistor.cpp
+++ b/src/Heating/Sensors/Thermistor.cpp
@@ -20,9 +20,13 @@
# include <CanMessageGenericParser.h>
#endif
-#if SAME5x // if using CoreN2G
+#if SAME5x || SAME70 // if using CoreN2G
# include <AnalogIn.h>
+# if SAME5x
using AnalogIn::AdcBits;
+# elif SAME70
+using LegacyAnalogIn::AdcBits;
+# endif
#endif
// For the theory behind ADC oversampling, see http://www.atmel.com/Images/doc8003.pdf
diff --git a/src/Linux/DataTransfer.cpp b/src/Linux/DataTransfer.cpp
index b8de289b..72fde11a 100644
--- a/src/Linux/DataTransfer.cpp
+++ b/src/Linux/DataTransfer.cpp
@@ -451,10 +451,10 @@ void DataTransfer::Init() noexcept
# endif
#else
// Initialize SPI
- ConfigurePin(APIN_SBC_SPI_MOSI);
- ConfigurePin(APIN_SBC_SPI_MISO);
- ConfigurePin(APIN_SBC_SPI_SCK);
- ConfigurePin(APIN_SBC_SPI_SS0);
+ SetPinFunction(APIN_SBC_SPI_MOSI, SBCPinPeriphMode);
+ SetPinFunction(APIN_SBC_SPI_MISO, SBCPinPeriphMode);
+ SetPinFunction(APIN_SBC_SPI_SCK, SBCPinPeriphMode);
+ SetPinFunction(APIN_SBC_SPI_SS0, SBCPinPeriphMode);
spi_enable_clock(SBC_SPI);
spi_disable(SBC_SPI);
diff --git a/src/Movement/StepTimer.cpp b/src/Movement/StepTimer.cpp
index a57a8a23..13fc1b85 100644
--- a/src/Movement/StepTimer.cpp
+++ b/src/Movement/StepTimer.cpp
@@ -21,6 +21,9 @@
# include <hri_tc_e54.h>
#elif !defined(__LPC17xx__)
# include <sam/drivers/tc/tc.h>
+# if SAME70
+# include <pmc/pmc.h>
+# endif
#endif
StepTimer * volatile StepTimer::pendingList = nullptr;
@@ -98,7 +101,7 @@ void StepTimer::Init() noexcept
# if SAME70
// Step clock runs at 48MHz/64 for compatibility with the Tool board
- constexpr uint32_t divisor = (64ull * VARIANT_MCK)/(48000000u);
+ constexpr uint32_t divisor = (64ull * (SystemCoreClockFreq/2))/(48000000u);
static_assert(divisor <= 256 && divisor >= 100);
// TC0 can use either PCLK6 or PCLK7 depending on the setting in the bus matrix Peripheral Clock Configuration Register. Default is PCLK6.
diff --git a/src/Movement/StepperDrivers/TMC51xx.cpp b/src/Movement/StepperDrivers/TMC51xx.cpp
index 3ad803ff..ea69f0a6 100644
--- a/src/Movement/StepperDrivers/TMC51xx.cpp
+++ b/src/Movement/StepperDrivers/TMC51xx.cpp
@@ -1239,9 +1239,9 @@ void SmartDrivers::Init() noexcept
Serial::EnableSercomClock(SERCOM_TMC51xx_NUMBER);
#else
// The pins are already set up for SPI in the pins table
- ConfigurePin(TMC51xxMosiPin);
- ConfigurePin(TMC51xxMisoPin);
- ConfigurePin(TMC51xxSclkPin);
+ SetPinFunction(TMC51xxMosiPin, TMC51xxMosiPinPeriphMode);
+ SetPinFunction(TMC51xxMisoPin, TMC51xxMosiPinPeriphMode);
+ SetPinFunction(TMC51xxSclkPin, TMC51xxMisoPinPeriphMode);
// Enable the clock to the USART or SPI
pmc_enable_periph_clk(ID_TMC51xx_SPI);
diff --git a/src/Platform.cpp b/src/Platform.cpp
index 63fffefc..b82d029c 100644
--- a/src/Platform.cpp
+++ b/src/Platform.cpp
@@ -47,7 +47,9 @@
#endif
#if SAME70
+# include <AnalogIn.h>
# include <DmacManager.h>
+using LegacyAnalogIn::AdcBits; // for compatibility with CoreNG, which doesn't have the AnalogIn namespace
static_assert(NumDmaChannelsUsed <= NumDmaChannelsSupported, "Need more DMA channels in CoreNG");
#elif SAME5x
# include <AnalogIn.h>
@@ -805,7 +807,11 @@ void Platform::Init() noexcept
AnalogIn::EnableTemperatureSensor(1, tcFilter.CallbackFeedIntoFilter, &tcFilter, 1, 0);
TemperatureCalibrationInit();
# else
- filteredAdcChannels[CpuTempFilterIndex] = GetTemperatureAdcChannel();
+ filteredAdcChannels[CpuTempFilterIndex] =
+#if SAME70
+ LegacyAnalogIn::
+#endif
+ GetTemperatureAdcChannel();
# endif
#endif
@@ -870,13 +876,13 @@ void Platform::ReadUniqueId()
memset(uniqueId, 0, sizeof(uniqueId));
const bool cacheWasEnabled = Cache::Disable();
- const uint32_t rc = flash_read_unique_id(uniqueId);
+ const bool success = Flash::ReadUniqueId(uniqueId);
if (cacheWasEnabled)
{
Cache::Enable();
}
- if (rc == 0)
+ if (success)
{
# endif
// Put the checksum at the end
@@ -5078,6 +5084,9 @@ GCodeResult Platform::EutProcessM569(const CanMessageGeneric& msg, const StringR
void Platform::Tick() noexcept
{
#if !SAME5x
+# if SAME70
+ LegacyAnalogIn::
+# endif
AnalogInFinaliseConversion();
#endif
@@ -5195,7 +5204,7 @@ void Platform::Tick() noexcept
// On Duet 3, AFEC1 is used only for thermistors and associated Vref/Vssa monitoring. AFEC0 is used for everything else.
// To reduce noise, we use x16 hardware averaging on AFEC0 and x256 on AFEC1. This is hard coded in file AnalogIn.cpp in project CoreNG.
// There is enough time to convert all AFEC0 channels in one tick, but only one AFEC1 channel because of the higher averaging.
- AnalogInStartConversion(0x0FFF | (1u << filteredAdcChannels[currentFilterNumber]));
+ LegacyAnalogIn::AnalogInStartConversion(0x0FFF | (1u << (uint8_t) filteredAdcChannels[currentFilterNumber]));
#elif !SAME5x
AnalogInStartConversion();
#endif
diff --git a/src/RepRap.cpp b/src/RepRap.cpp
index 192b4e33..b93018d5 100644
--- a/src/RepRap.cpp
+++ b/src/RepRap.cpp
@@ -98,7 +98,7 @@ extern "C" void HSMCI_Handler() noexcept
#if SAME70
// HSMCI DMA complete callback
-void HsmciDmaCallback(CallbackParameter cp) noexcept
+void HsmciDmaCallback(CallbackParameter cb, DmaCallbackReason reason) noexcept
{
HSMCI->HSMCI_IDR = 0xFFFFFFFF; // disable all HSMCI interrupts
XDMAC->XDMAC_CHID[DmacChanHsmci].XDMAC_CID = 0xFFFFFFFF; // disable all DMA interrupts for this channel
@@ -2835,7 +2835,7 @@ void RepRap::StartIap() noexcept
WatchdogReset(); // kick the watchdog one last time
#if SAM4E || SAME70
- rswdt_restart(RSWDT); // kick the secondary watchdog
+ WatchdogResetSecondary(); // kick the secondary watchdog
#endif
// Modify vector table location
diff --git a/src/Tasks.cpp b/src/Tasks.cpp
index 917e4d7e..77348a66 100644
--- a/src/Tasks.cpp
+++ b/src/Tasks.cpp
@@ -102,7 +102,7 @@ extern "C" void ReleaseMallocMutex() noexcept
}
// Application entry point
-#if SAME5x // if using CoreN2G
+#if SAME5x || SAME70 // if using CoreN2G
[[noreturn]] void AppMain() noexcept
#else // using CoreNG
extern "C" [[noreturn]] void AppMain() noexcept
diff --git a/src/bossa/Device.cpp b/src/bossa/Device.cpp
index 6cfda0be..d3abc9e8 100644
--- a/src/bossa/Device.cpp
+++ b/src/bossa/Device.cpp
@@ -47,7 +47,7 @@ Device::readChipId(uint32_t& chipId, uint32_t& extChipId)
void
Device::create() THROWS(GCodeException)
{
- Flash* flashPtr;
+ BossaFlash* flashPtr;
#if ORIGINAL_BOSSA_CODE
uint32_t chipId = 0;
uint32_t cpuId = 0;
diff --git a/src/bossa/Device.h b/src/bossa/Device.h
index 9509acb4..f0a2e5b7 100644
--- a/src/bossa/Device.h
+++ b/src/bossa/Device.h
@@ -84,13 +84,13 @@ public:
Family getFamily() noexcept { return _family; }
- Flash* getFlash() noexcept { return _flash; }
+ BossaFlash* getFlash() noexcept { return _flash; }
void reset() THROWS(GCodeException);
private:
Samba& _samba;
- Flash* _flash;
+ BossaFlash* _flash;
Family _family;
#if ORIGINAL_BOSSA_CODE
diff --git a/src/bossa/EefcFlash.cpp b/src/bossa/EefcFlash.cpp
index 346d43e1..153e38b7 100644
--- a/src/bossa/EefcFlash.cpp
+++ b/src/bossa/EefcFlash.cpp
@@ -68,7 +68,7 @@ EefcFlash::EefcFlash(Samba& samba,
uint32_t stack,
uint32_t regs,
bool canBrownout) THROWS(GCodeException)
- : Flash(samba, name, addr, pages, size, planes, lockRegions, user, stack),
+ : BossaFlash(samba, name, addr, pages, size, planes, lockRegions, user, stack),
_regs(regs), _canBrownout(canBrownout), _eraseAuto(true)
{
diff --git a/src/bossa/EefcFlash.h b/src/bossa/EefcFlash.h
index cd0f72ee..58ea811c 100644
--- a/src/bossa/EefcFlash.h
+++ b/src/bossa/EefcFlash.h
@@ -33,7 +33,7 @@
#include "Flash.h"
-class EefcFlash : public Flash
+class EefcFlash : public BossaFlash
{
public:
EefcFlash(Samba& samba,
diff --git a/src/bossa/Flash.cpp b/src/bossa/Flash.cpp
index 58d7f24d..953a9f5d 100644
--- a/src/bossa/Flash.cpp
+++ b/src/bossa/Flash.cpp
@@ -28,7 +28,7 @@
///////////////////////////////////////////////////////////////////////////////
#include "Flash.h"
-Flash::Flash(Samba& samba,
+BossaFlash::BossaFlash(Samba& samba,
const char* name,
uint32_t addr,
uint32_t pages,
@@ -52,7 +52,7 @@ Flash::Flash(Samba& samba,
}
void
-Flash::setLockRegions(const Vector<bool, 16>& regions) THROWS(GCodeException)
+BossaFlash::setLockRegions(const Vector<bool, 16>& regions) THROWS(GCodeException)
{
if (regions.Size() > _lockRegions)
throw FlashRegionError("Flash::setLockRegions: regions.Size() > _lockRegions");
@@ -61,34 +61,34 @@ Flash::setLockRegions(const Vector<bool, 16>& regions) THROWS(GCodeException)
}
void
-Flash::setSecurity() noexcept
+BossaFlash::setSecurity() noexcept
{
_security.set(true);
}
void
-Flash::setBor(bool enable) noexcept
+BossaFlash::setBor(bool enable) noexcept
{
if (canBor())
_bor.set(enable);
}
void
-Flash::setBod(bool enable) noexcept
+BossaFlash::setBod(bool enable) noexcept
{
if (canBod())
_bod.set(enable);
}
void
-Flash::setBootFlash(bool enable) noexcept
+BossaFlash::setBootFlash(bool enable) noexcept
{
if (canBootFlash())
_bootFlash.set(enable);
}
void
-Flash::loadBuffer(const uint8_t* data, uint16_t bufferSize) THROWS(GCodeException)
+BossaFlash::loadBuffer(const uint8_t* data, uint16_t bufferSize) THROWS(GCodeException)
{
_samba.write(_onBufferA ? _pageBufferA : _pageBufferB, data, bufferSize);
}
diff --git a/src/bossa/Flash.h b/src/bossa/Flash.h
index 9f7f9b0c..afc03664 100644
--- a/src/bossa/Flash.h
+++ b/src/bossa/Flash.h
@@ -60,10 +60,10 @@ private:
bool _dirty;
};
-class Flash
+class BossaFlash // manuel: required to rename to avoid clash with CoreN2G namespace Flash
{
public:
- Flash(Samba& samba,
+ BossaFlash(Samba& samba,
const char* name,
uint32_t addr, // Flash base address
uint32_t pages, // Number of pages
@@ -72,7 +72,7 @@ public:
uint32_t lockRegions, // Number of flash lock regions
uint32_t user, // Address in SRAM where the applet and buffers will be placed
uint32_t stack) THROWS(GCodeException); // Address in SRAM where the applet stack will be placed
- virtual ~Flash() {}
+ virtual ~BossaFlash() {}
const char* name() noexcept { return _name; }
diff --git a/src/bossa/Flasher.h b/src/bossa/Flasher.h
index b9a4935b..5198e2a0 100644
--- a/src/bossa/Flasher.h
+++ b/src/bossa/Flasher.h
@@ -64,7 +64,7 @@ public:
private:
Samba& _samba;
- Flash* _flash;
+ BossaFlash* _flash;
FlasherObserver& _observer;
uint32_t pageNum;