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:
authorDavid Crocker <dcrocker@eschertech.com>2018-02-06 02:38:47 +0300
committerDavid Crocker <dcrocker@eschertech.com>2018-02-06 02:38:47 +0300
commitc5a8315c2d0ab6eb6a7c961e0f44cea198bee38d (patch)
treec15f0b8d3d7eb6a378992816a4b4223f56d858ef /src/IoPorts.cpp
parent1448121041393c9a878c3dd84ddd97dff2a4687f (diff)
More work on SAM4S port
Renamed IoPort{.cpp,.h} to avoid name clash with ASF Fixes to 12864 display Support beeper on 12864 display Encoder parameters are now configurable (M918)
Diffstat (limited to 'src/IoPorts.cpp')
-rw-r--r--src/IoPorts.cpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/IoPorts.cpp b/src/IoPorts.cpp
new file mode 100644
index 00000000..097cdc7c
--- /dev/null
+++ b/src/IoPorts.cpp
@@ -0,0 +1,116 @@
+/*
+ * IoPort.cpp
+ *
+ * Created on: 30 Sep 2017
+ * Author: David
+ */
+
+#include "IoPorts.h"
+#include "RepRap.h"
+#include "Platform.h"
+#include "Configuration.h"
+
+#ifdef DUET_NG
+# include "DuetNG/DueXn.h"
+#endif
+
+// members of class IoPort
+IoPort::IoPort()
+{
+ Clear();
+}
+
+void IoPort::Clear()
+{
+ logicalPort = NoLogicalPin;
+ pin = NoPin;
+ invert = false;
+}
+
+bool IoPort::Set(LogicalPin lp, PinAccess access)
+{
+ const bool ret = reprap.GetPlatform().GetFirmwarePin(lp, access, pin, invert);
+ if (!ret)
+ {
+ Clear();
+ }
+ return ret;
+}
+
+
+/*static*/ void IoPort::SetPinMode(Pin pin, PinMode mode)
+{
+#ifdef DUET_NG
+ if (pin >= DueXnExpansionStart)
+ {
+ DuetExpansion::SetPinMode(pin, mode);
+ }
+ else
+ {
+ pinMode(pin, mode);
+ }
+#else
+ pinMode(pin, mode);
+#endif
+}
+
+/*static*/ bool IoPort::ReadPin(Pin pin)
+{
+#ifdef DUET_NG
+ if (pin >= DueXnExpansionStart)
+ {
+ return DuetExpansion::DigitalRead(pin);
+ }
+ else
+ {
+ return digitalRead(pin);
+ }
+#else
+ return digitalRead(pin);
+#endif
+}
+
+/*static*/ void IoPort::WriteDigital(Pin pin, bool high)
+{
+#ifdef DUET_NG
+ if (pin >= DueXnExpansionStart)
+ {
+ DuetExpansion::DigitalWrite(pin, high);
+ }
+ else
+ {
+ digitalWrite(pin, high);
+ }
+#else
+ digitalWrite(pin, high);
+#endif
+}
+
+/*static*/ void IoPort::WriteAnalog(Pin pin, float pwm, uint16_t freq)
+{
+#ifdef DUET_NG
+ if (pin >= DueXnExpansionStart)
+ {
+ DuetExpansion::AnalogOut(pin, pwm);
+ }
+ else
+ {
+ AnalogOut(pin, pwm, freq);
+ }
+#else
+ AnalogOut(pin, pwm, freq);
+#endif
+}
+
+// Members of class PwmPort
+PwmPort::PwmPort()
+{
+ frequency = DefaultPinWritePwmFreq;
+}
+
+void PwmPort::SetFrequency(float freq)
+{
+ frequency = (uint16_t)constrain<float>(freq, 1.0, 65535);
+}
+
+// End