Skip to content

Commit cd90393

Browse files
committed
fix(#1686): throw an argument out range exception if gpio port is not in allowed range
1 parent 8ac7ce0 commit cd90393

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ using var rxChannel = new ReceiverChannel(rxChannelSettings);
7373
rxChannel.Start(clearBuffer: true);
7474
```
7575

76+
## GPIO Pin Restrictions
77+
78+
The ESP32 MCU restricts which GPIO pins can be used for the Transmit Channel (TX). Ports 34 to 39 (inclusive) cannot be used for TX. Attempting to use these ports will cause the `TransmitChannelSettings` class to throw an `ArgumentOutOfRangeException`.
79+
7680
## Build status
7781

7882
| Component | Build Status | NuGet Package |

nanoFramework.Hardware.Esp32.Rmt/TransmitChannelSettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,15 @@ public TransmitChannelSettings(int pinNumber) : this(channel: -1, pinNumber)
144144
/// <param name="channel">The channel number to use. Valid value range is 0 to 7 (inclusive).</param>
145145
/// <param name="pinNumber">The GPIO Pin number to use with the channel.</param>
146146
/// <exception cref="ArgumentOutOfRangeException"><paramref name="channel"/> must be between 0 and 7.</exception>
147+
/// <exception cref="ArgumentOutOfRangeException"><paramref name="pinNumber"/> must not be between 34 and 39.</exception>"
147148
public TransmitChannelSettings(int channel, int pinNumber) : base(channel, pinNumber)
148149
{
150+
// ESP32 RMT TX channels cannot use GPIO pins 34-39
151+
if (pinNumber >= 34 && pinNumber <= 39)
152+
{
153+
throw new ArgumentOutOfRangeException();
154+
}
155+
149156
_enableCarrierWave = true;
150157
_carrierLevel = true;
151158
_carrierWaveFrequency = 38_000;

0 commit comments

Comments
 (0)