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
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/Hardware
parented1f834bc57412ab58f3a9abb647e13f11e4b809 (diff)
Fix all compiler bugs (linker still unhappy)
Diffstat (limited to 'src/Hardware')
-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
6 files changed, 73 insertions, 14 deletions
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]);