Set the ports to the requested state
| 87 | |
| 88 | // Set the ports to the requested state |
| 89 | void 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 |
no test coverage detected