diff options
author | Manuel Coenen <manuel@duet3d.com> | 2021-01-12 18:30:28 +0300 |
---|---|---|
committer | Manuel Coenen <manuel@duet3d.com> | 2021-01-19 13:22:32 +0300 |
commit | ed1f834bc57412ab58f3a9abb647e13f11e4b809 (patch) | |
tree | 2207d22bc4feb20d596ebb8216ed784b539cd8bf /src/Hardware/SAME70 | |
parent | bd8d82f7f23534905c1d574d70b1f5c2d453b7c1 (diff) |
Start converting Duet3 build to CoreN2G (not compiling yet)
Diffstat (limited to 'src/Hardware/SAME70')
-rw-r--r-- | src/Hardware/SAME70/Devices.cpp | 51 | ||||
-rw-r--r-- | src/Hardware/SAME70/Devices.h | 23 | ||||
-rw-r--r-- | src/Hardware/SAME70/Main.cpp | 34 | ||||
-rw-r--r-- | src/Hardware/SAME70/PinDescription.h | 49 |
4 files changed, 157 insertions, 0 deletions
diff --git a/src/Hardware/SAME70/Devices.cpp b/src/Hardware/SAME70/Devices.cpp new file mode 100644 index 00000000..23a7391e --- /dev/null +++ b/src/Hardware/SAME70/Devices.cpp @@ -0,0 +1,51 @@ +/* + * Devices.cpp + * + * Created on: 11 Aug 2020 + * Author: David + */ + +#include "Devices.h" + +AsyncSerial serialUart0(UART2, UART2_IRQn, ID_UART2, 512, 512, [](AsyncSerial*) noexcept { }, [](AsyncSerial*) noexcept { }); + +constexpr Pin APIN_Serial0_RXD = PortDPin(25); +constexpr Pin APIN_Serial0_TXD = PortDPin(26); +constexpr auto Serial0PinFunction = 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) +{ + serialUart0.IrqHandler(); +} + + +void SerialInit() noexcept +{ + SetPinFunction(APIN_Serial0_RXD, Serial0PinFunction); + SetPinFunction(APIN_Serial0_TXD, Serial0PinFunction); + SetPullup(APIN_Serial0_RXD, true); +} + +void SdhcInit() noexcept +{ + SetPinFunction(HcmciMclkPin, HsmciMclkPinFunction); + for (Pin p : HsmciOtherPins) + { + SetPinFunction(p, HsmciOtherkPinsFunction); + } +} + + +// Device initialisation +void DeviceInit() noexcept +{ + SerialInit(); + SdhcInit(); +} + +// End diff --git a/src/Hardware/SAME70/Devices.h b/src/Hardware/SAME70/Devices.h new file mode 100644 index 00000000..0e5f3e89 --- /dev/null +++ b/src/Hardware/SAME70/Devices.h @@ -0,0 +1,23 @@ +/* + * Devices.h + * + * Created on: 11 Aug 2020 + * Author: David + */ + +#ifndef SRC_HARDWARE_SAME70_DEVICES_H_ +#define SRC_HARDWARE_SAME70_DEVICES_H_ + +#include <AsyncSerial.h> +typedef AsyncSerial UARTClass; + +extern AsyncSerial serialUart0, serialUart1; + +#define SUPPORT_USB 1 // needed by SerialCDC.h +#include "SerialCDC.h" + +extern SerialCDC serialUSB; + +void DeviceInit() noexcept; + +#endif /* SRC_HARDWARE_SAME70_DEVICES_H_ */ diff --git a/src/Hardware/SAME70/Main.cpp b/src/Hardware/SAME70/Main.cpp new file mode 100644 index 00000000..5851ca16 --- /dev/null +++ b/src/Hardware/SAME70/Main.cpp @@ -0,0 +1,34 @@ +/* + * Main.cpp + * Program entry point + * Created on: 11 Jul 2020 + * Author: David + * License: GNU GPL version 3 + */ + +#include <Core.h> + +// Program initialisation +void AppInit() noexcept +{ +} + +// syscalls.h must be included by exactly one .cpp file in the project +#include <syscalls.h> + +[[noreturn]] void OutOfMemoryHandler() noexcept +{ + while (true) { } +} + +extern "C" [[noreturn]] void __cxa_pure_virtual() noexcept +{ + while (true) { } +} + +extern "C" [[noreturn]] void __cxa_deleted_virtual() noexcept +{ + while (true) { } +} + +// End diff --git a/src/Hardware/SAME70/PinDescription.h b/src/Hardware/SAME70/PinDescription.h new file mode 100644 index 00000000..77c80971 --- /dev/null +++ b/src/Hardware/SAME70/PinDescription.h @@ -0,0 +1,49 @@ +/* + * PinDescription.h + * + * Created on: 10 Jul 2020 + * Author: David + */ + +#ifndef SRC_HARDWARE_SAME70_PINDESCRIPTION_H_ +#define SRC_HARDWARE_SAME70_PINDESCRIPTION_H_ + +#include <CoreIO.h> + +// 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 +{ + // Individual capabilities + none = 0, + read = 1, + ain = 2, + write = 4, + pwm = 8, + + // Combinations + ainr = 1|2, + rw = 1|4, + wpwm = 4|8, + rwpwm = 1|4|8, + ainrw = 1|2|4, + ainrwpwm = 1|2|4|8 +}; + +constexpr inline PinCapability operator|(PinCapability a, PinCapability b) noexcept +{ + return (PinCapability)((uint8_t)a | (uint8_t)b); +} + +// The pin description says what functions are available on each pin, filtered to avoid allocating the same function to more than one pin.. +// It is a struct not a class so that it can be direct initialised in read-only memory. +struct PinDescription : public PinDescriptionBase +{ + PinCapability cap; + const char* pinNames; + + PinCapability GetCapability() const noexcept { return cap; } + const char* GetNames() const noexcept { return pinNames; } +}; + +#endif /* SRC_HARDWARE_SAME70_PINDESCRIPTION_H_ */ |