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-22 18:31:28 +0300
committerManuel Coenen <manuel@duet3d.com>2021-01-22 18:31:28 +0300
commit9df7f438ed60813fab0e6303b0302fe1b1a1121b (patch)
tree7e630ade47ae7b1db0e1d06a366198aeb734c05f /src/DuetNG
parent837875d24b3bb657245eafa9f22db1a23cfba6da (diff)
Fix all compiler and linker errors for SAM4E+CoreN2G
Note: PinTable still empty
Diffstat (limited to 'src/DuetNG')
-rw-r--r--src/DuetNG/DueXn.cpp5
-rw-r--r--src/DuetNG/DueXn.h2
-rw-r--r--src/DuetNG/Pins_DuetNG.cpp16
-rw-r--r--src/DuetNG/Pins_DuetNG.h84
-rw-r--r--src/DuetNG/SX1509.cpp11
-rw-r--r--src/DuetNG/SX1509.h7
6 files changed, 98 insertions, 27 deletions
diff --git a/src/DuetNG/DueXn.cpp b/src/DuetNG/DueXn.cpp
index e343ce0d..c73cdb24 100644
--- a/src/DuetNG/DueXn.cpp
+++ b/src/DuetNG/DueXn.cpp
@@ -12,6 +12,7 @@
#include "Wire.h"
#include "Hardware/I2C.h"
#include <TaskPriorities.h>
+#include <Interrupts.h>
namespace DuetExpansion
{
@@ -135,7 +136,7 @@ ExpansionBoardType DuetExpansion::DueXnInit() noexcept
const uint16_t stopBits = (dueXnBoardType == ExpansionBoardType::DueX5) ? AllStopBitsX5 : AllStopBitsX2; // I am assuming that the X0 has 2 endstop inputs
dueXnExpander.pinModeMultiple(stopBits | AllGpioBits, INPUT); // Initialise the endstop inputs and GPIO pins (no pullups because 5V-tolerant)
dueXnInputMask = stopBits | AllGpioBits;
- dueXnExpander.enableInterruptMultiple(dueXnInputMask, INTERRUPT_MODE_CHANGE);
+ dueXnExpander.enableInterruptMultiple(dueXnInputMask, InterruptMode::change);
}
return dueXnBoardType;
@@ -148,7 +149,7 @@ void DuetExpansion::DueXnTaskInit() noexcept
if (dueXnBoardType != ExpansionBoardType::none)
{
// Set up the interrupt on any input change
- attachInterrupt(DueX_INT, DueXIrq, InterruptMode::INTERRUPT_MODE_FALLING, nullptr);
+ attachInterrupt(DueX_INT, DueXIrq, InterruptMode::falling, nullptr);
// Clear any initial interrupts
(void)dueXnExpander.interruptSourceAndClear();
diff --git a/src/DuetNG/DueXn.h b/src/DuetNG/DueXn.h
index c129a0cb..22efdb36 100644
--- a/src/DuetNG/DueXn.h
+++ b/src/DuetNG/DueXn.h
@@ -9,7 +9,7 @@
#define SRC_DUETNG_DUEXN_H_
#include "ecv.h"
-#include "Core.h"
+#include "CoreIO.h"
#include "MessageType.h"
enum class ExpansionBoardType : uint8_t
diff --git a/src/DuetNG/Pins_DuetNG.cpp b/src/DuetNG/Pins_DuetNG.cpp
index a96f3508..5fa45a32 100644
--- a/src/DuetNG/Pins_DuetNG.cpp
+++ b/src/DuetNG/Pins_DuetNG.cpp
@@ -9,9 +9,15 @@
// Hardware-dependent pins functions
-// Function to look up a pin name pass back the corresponding index into the pin table
+// Return a pointer to the pin description entry. Declared in and called from CoreN2G.
+const PinDescriptionBase *AppGetPinDescription(Pin p) noexcept
+{
+ return (p < ARRAY_SIZE(PinTable)) ? &PinTable[p] : nullptr;
+}
+
+// Function to look up a pin name and pass back the corresponding index into the pin table
// On this platform, the mapping from pin names to pins is fixed, so this is a simple lookup
-bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted) noexcept
+bool LookupPinName(const char *pn, LogicalPin &lpin, bool &hardwareInverted) noexcept
{
if (StringEqualsIgnoreCase(pn, NoPinName))
{
@@ -22,7 +28,11 @@ bool LookupPinName(const char*pn, LogicalPin& lpin, bool& hardwareInverted) noex
for (size_t lp = 0; lp < ARRAY_SIZE(PinTable); ++lp)
{
- const char *q = PinTable[lp].names;
+ const char *q = PinTable[lp].pinNames;
+ if (q == nullptr)
+ {
+ continue;
+ }
while (*q != 0)
{
// Try the next alias in the list of names for this pin
diff --git a/src/DuetNG/Pins_DuetNG.h b/src/DuetNG/Pins_DuetNG.h
index 63232587..de3e9ede 100644
--- a/src/DuetNG/Pins_DuetNG.h
+++ b/src/DuetNG/Pins_DuetNG.h
@@ -1,6 +1,8 @@
#ifndef PINS_DUETNG_H__
#define PINS_DUETNG_H__
+#include <PinDescription.h>
+
// Pins definition file for Duet 2 WiFi/Ethernet
// This file is normally #included by #including RepRapFirmware.h, which includes this file
@@ -187,6 +189,7 @@ constexpr IRQn TMC2660_SPI_IRQn = USART1_IRQn;
constexpr Pin TMC2660MosiPin = PortAPin(22);
constexpr Pin TMC2660MisoPin = PortAPin(21);
constexpr Pin TMC2660SclkPin = PortAPin(23);
+constexpr GpioPinFunction TMC2660PeriphMode = GpioPinFunction::A;
constexpr uint32_t DefaultStandstillCurrentPercent = 100; // it's not adjustable on Duet 2
@@ -266,6 +269,17 @@ constexpr Pin LcdBeepPin = PortDPin(21); // connlcd.10 -> exp1.10
#define USART_SSPI USART0
#define ID_SSPI ID_USART0
+// List of assignable pins and their mapping from names to MPU ports. This is indexed by logical pin number.
+// The names must match user input that has been concerted to lowercase and had _ and - characters stripped out.
+// Aliases are separate by the , character.
+// If a pin name is prefixed by ! then this means the pin is hardware inverted. The same pin may have names for both the inverted and non-inverted cases,
+// for example the inverted heater pins on the expansion connector are available as non-inverted servo pins on a DueX.
+constexpr PinDescription PinTable[] =
+{
+};
+
+#if 0
+
// Enum to represent allowed types of pin access
// We don't have a separate bit for servo, because Duet PWM-capable ports can be used for servos if they are on the Duet main board
enum class PinCapability: uint8_t
@@ -396,12 +410,50 @@ constexpr PinEntry PinTable[] =
{ 234, PinCapability::rwpwm, "sx1509b.14" },
{ 235, PinCapability::rwpwm, "sx1509b.15" }
};
+#endif
constexpr unsigned int NumNamedPins = ARRAY_SIZE(PinTable);
// Function to look up a pin name pass back the corresponding index into the pin table
bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted) noexcept;
+// USARTs used for SPI
+constexpr Pin APIN_USART_SSPI_MOSI = PortAPin(27);
+constexpr Pin APIN_USART_SSPI_MISO = PortAPin(26);
+constexpr Pin APIN_USART_SSPI_SCK = PortAPin(30);
+constexpr GpioPinFunction USARTSSPIPeriphMode = GpioPinFunction::C;
+
+constexpr Pin APIN_USART1_MOSI = PortAPin(22);
+constexpr Pin APIN_USART1_MISO = PortAPin(21);
+constexpr Pin APIN_USART1_SCK = PortAPin(23);
+constexpr GpioPinFunction USART1SSPIPeriphMode = GpioPinFunction::A;
+
+// SD Card
+constexpr Pin HsmciPins[] = { PortAPin(26), PortAPin(27), PortAPin(28), PortAPin(29), PortAPin(30), PortAPin(31) };
+constexpr auto HsmciPinsFunction = GpioPinFunction::C;
+
+/*
+ * TWI Interfaces
+ */
+constexpr Pin TWI_Data = PortAPin(3);
+constexpr Pin TWI_CK = PortAPin(4);
+constexpr GpioPinFunction TWIPeriphMode = GpioPinFunction::A;
+
+#define WIRE_INTERFACE TWI0
+#define WIRE_INTERFACE_ID ID_TWI0
+#define WIRE_ISR_HANDLER TWI0_Handler
+#define WIRE_ISR_ID TWI0_IRQn
+
+// Serial
+constexpr Pin APIN_Serial0_RXD = PortAPin(9);
+constexpr Pin APIN_Serial0_TXD = PortAPin(10);
+constexpr GpioPinFunction Serial0PeriphMode = GpioPinFunction::A;
+
+// Serial1
+constexpr Pin APIN_Serial1_RXD = PortAPin(5);
+constexpr Pin APIN_Serial1_TXD = PortAPin(6);
+constexpr GpioPinFunction Serial1PeriphMode = GpioPinFunction::C;
+
// Duet pin numbers to control the WiFi interface on the Duet WiFi
#define ESP_SPI SPI
#define ESP_SPI_INTERFACE_ID ID_SPI
@@ -412,10 +464,16 @@ bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted) noe
const uint32_t DMA_HW_ID_SPI_TX = 1;
const uint32_t DMA_HW_ID_SPI_RX = 2;
-constexpr Pin APIN_ESP_SPI_MOSI = APIN_SPI_MOSI;
-constexpr Pin APIN_ESP_SPI_MISO = APIN_SPI_MISO;
-constexpr Pin APIN_ESP_SPI_SCK = APIN_SPI_SCK;
-constexpr Pin APIN_ESP_SPI_SS0 = APIN_SPI_SS0;
+constexpr Pin SPI_MOSI = PortAPin(13);
+constexpr Pin SPI_MISO = PortAPin(12);
+constexpr Pin SPI_SCK = PortAPin(14);
+constexpr Pin SPI_SS0 = PortAPin(11);
+constexpr GpioPinFunction SPIPeriphMode = GpioPinFunction::A;
+
+constexpr Pin APIN_ESP_SPI_MOSI = SPI_MOSI;
+constexpr Pin APIN_ESP_SPI_MISO = SPI_MISO;
+constexpr Pin APIN_ESP_SPI_SCK = SPI_SCK;
+constexpr Pin APIN_ESP_SPI_SS0 = SPI_SS0;
constexpr Pin EspResetPin = PortEPin(4); // Low on this in holds the WiFi module in reset (ESP_RESET)
constexpr Pin EspEnablePin = PortEPin(5); // High to enable the WiFi module, low to power it down (ESP_CH_PD)
@@ -429,10 +487,10 @@ constexpr Pin SamCsPin = PortAPin(11); // SPI NPCS pin, input from WiFi modul
#define W5500_SPI_IRQn SPI_IRQn
#define W5500_SPI_HANDLER SPI_Handler
-constexpr Pin APIN_W5500_SPI_MOSI = APIN_SPI_MOSI;
-constexpr Pin APIN_W5500_SPI_MISO = APIN_SPI_MISO;
-constexpr Pin APIN_W5500_SPI_SCK = APIN_SPI_SCK;
-constexpr Pin APIN_W5500_SPI_SS0 = APIN_SPI_SS0;
+constexpr Pin APIN_W5500_SPI_MOSI = SPI_MOSI;
+constexpr Pin APIN_W5500_SPI_MISO = SPI_MISO;
+constexpr Pin APIN_W5500_SPI_SCK = SPI_SCK;
+constexpr Pin APIN_W5500_SPI_SS0 = SPI_SS0;
constexpr Pin W5500ResetPin = PortEPin(4); // Low on this in holds the W5500 module in reset (ESP_RESET)
constexpr Pin W5500InterruptPin = PortDPin(31); // W5500 interrupt output, active low
@@ -444,10 +502,10 @@ constexpr Pin W5500SsPin = PortAPin(11); // SPI NPCS pin, input from W5500 mod
#define SBC_SPI_INTERFACE_ID ID_SPI
#define SBC_SPI_IRQn SPI_IRQn
#define SBC_SPI_HANDLER SPI_Handler
-constexpr Pin APIN_SBC_SPI_MOSI = 13;
-constexpr Pin APIN_SBC_SPI_MISO = 12;
-constexpr Pin APIN_SBC_SPI_SCK = 14;
-constexpr Pin APIN_SBC_SPI_SS0 = 11;
+constexpr Pin APIN_SBC_SPI_MOSI = SPI_MOSI;
+constexpr Pin APIN_SBC_SPI_MISO = SPI_MISO;
+constexpr Pin APIN_SBC_SPI_SCK = SPI_SCK;
+constexpr Pin APIN_SBC_SPI_SS0 = SPI_SS0;
constexpr Pin SbcTfrReadyPin = PortDPin(31);
@@ -483,7 +541,7 @@ namespace StepPins
static inline uint32_t CalcDriverBitmap(size_t driver) noexcept
{
return (driver < NumDirectDrivers)
- ? g_APinDescription[STEP_PINS[driver]].ulPin
+ ? 1u << (STEP_PINS[driver] & 0x1Fu)
: 0;
}
diff --git a/src/DuetNG/SX1509.cpp b/src/DuetNG/SX1509.cpp
index 3b725909..ffbd8744 100644
--- a/src/DuetNG/SX1509.cpp
+++ b/src/DuetNG/SX1509.cpp
@@ -26,6 +26,7 @@ Distributed as-is; no warranty is given.
#include "SX1509.h"
#include "SX1509Registers.h"
#include "Hardware/I2C.h"
+#include <Interrupts.h>
SX1509::SX1509() noexcept : _clkX(0)
{
@@ -245,12 +246,12 @@ void SX1509::analogWrite(uint8_t pin, uint8_t iOn) noexcept
writeByte(REG_I_ON[pin], ~iOn);
}
-void SX1509::enableInterrupt(uint8_t pin, uint8_t riseFall) noexcept
+void SX1509::enableInterrupt(uint8_t pin, InterruptMode riseFall) noexcept
{
enableInterruptMultiple(1u << pin, riseFall);
}
-void SX1509::enableInterruptMultiple(uint16_t pins, uint8_t riseFall) noexcept
+void SX1509::enableInterruptMultiple(uint16_t pins, InterruptMode riseFall) noexcept
{
// Set REG_SENSE_XXX
// Sensitivity is set as follows:
@@ -261,13 +262,13 @@ void SX1509::enableInterruptMultiple(uint16_t pins, uint8_t riseFall) noexcept
uint8_t sensitivity;
switch (riseFall)
{
- case INTERRUPT_MODE_CHANGE:
+ case InterruptMode::change:
sensitivity = 0b11;
break;
- case INTERRUPT_MODE_FALLING:
+ case InterruptMode::falling:
sensitivity = 0b10;
break;
- case INTERRUPT_MODE_RISING:
+ case InterruptMode::rising:
sensitivity = 0b01;
break;
default:
diff --git a/src/DuetNG/SX1509.h b/src/DuetNG/SX1509.h
index c119f012..b5934190 100644
--- a/src/DuetNG/SX1509.h
+++ b/src/DuetNG/SX1509.h
@@ -24,7 +24,8 @@ Distributed as-is; no warranty is given.
#ifndef SX1509_H
#define SX1509_H
-#include "Core.h"
+#include "CoreIO.h"
+#include <Interrupts.h>
const int ReceiveTimeout = 1000; // Timeout for I2C receive
const uint8_t DefaultOscDivider = 5; // a clock divider of 2 ^ (5 - 1) = 16 gives a PWM frequency of 2MHz / (16 * 255) = 488Hz
@@ -205,7 +206,7 @@ public:
// Note: This function does not set up a pin as an input, or configure its
// pull-up/down resistors! Do that before (or after).
// -----------------------------------------------------------------------------
- void enableInterrupt(uint8_t pin, uint8_t riseFall) noexcept;
+ void enableInterrupt(uint8_t pin, InterruptMode riseFall) noexcept;
// -----------------------------------------------------------------------------
// enableInterruptMultiple(uint16_t pins, uint8_t riseFall): This function sets up an interrupt
@@ -224,7 +225,7 @@ public:
// Note: This function does not set up a pin as an input, or configure its
// pull-up/down resistors! Do that before (or after).
// -----------------------------------------------------------------------------
- void enableInterruptMultiple(uint16_t pins, uint8_t riseFall) noexcept;
+ void enableInterruptMultiple(uint16_t pins, InterruptMode riseFall) noexcept;
// -----------------------------------------------------------------------------
// interruptSource(void): Returns an unsigned int representing which pin caused