MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / UpdatePorts

Method UpdatePorts

src/Platform/PortControl.cpp:89–111  ·  view source on GitHub ↗

Set the ports to the requested state

Source from the content-addressed store, hash-verified

87
88// Set the ports to the requested state
89void PortControl::UpdatePorts(IoBits_t newPortState) noexcept
90{
91 if (newPortState != currentPortState)
92 {
93 const IoBits_t bitsToClear = currentPortState & ~newPortState;
94 const IoBits_t bitsToSet = newPortState & ~currentPortState;
95 Platform& platform = reprap.GetPlatform();
96 for (size_t i = 0; i < numConfiguredPorts; ++i)
97 {
98 GpOutputPort& port = platform.GetGpOutPort(gpOutPortNumbers[i]);
99 const IoBits_t mask = 1u << i;
100 if ((bitsToClear & mask) != 0)
101 {
102 port.WriteDigital(false);
103 }
104 else if ((bitsToSet & mask) != 0)
105 {
106 port.WriteDigital(true);
107 }
108 }
109 currentPortState = newPortState;
110 }
111}
112
113#endif
114

Callers 1

Calls 1

WriteDigitalMethod · 0.45

Tested by

no test coverage detected